Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse \langle and \rangle as valid brackets #35288

Open
simeonschaub opened this issue Mar 28, 2020 · 2 comments
Open

Parse \langle and \rangle as valid brackets #35288

simeonschaub opened this issue Mar 28, 2020 · 2 comments
Labels
parser Language parsing and surface syntax

Comments

@simeonschaub
Copy link
Member

simeonschaub commented Mar 28, 2020

I think it would make sense to parse and as valid bracket syntax, like we currently do {} and [] with its own AST representation (maybe Expr(:angle, ...)?), so that this can be used inside macros for DSLs. The reason, I was initially a bit hesitant about just treating these as brackets is that I thought it would be very cool to support bras and kets as syntax on their own. But with | already being a very common infix operator, I wasn't able to come up with an intuitive parsing rule for when | starts a ket vs. when it denotes the infix or, so I think supporting these only as matching brackets makes the most sense here. Since this is quite common notation in mathematics and physics, I believe it could be of great use in DSLs for linear algebra, quantum computing or statistics. I think it would also be worth considering lowering this syntax to a function call, maybe even overloading the two- and three-argument methods as LinearAlgebra.dot, but this can be a separate discussion.
I know, this has been discussed in #25565 and #8934, but there never really was a follow-up.

@KristofferC
Copy link
Member

Ref #27697, #27712

@JeffBezanson JeffBezanson added the parser Language parsing and surface syntax label Mar 30, 2020
@JeffBezanson
Copy link
Member

I think we should add parsing for all of these, with their own expression heads. That way macros can start using them right away, and if we want to add associated functions later we can, but in the meantime it should be totally harmless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

3 participants