-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add support for angle bracket ⟨ ⟩ #27712
base: master
Are you sure you want to change the base?
Conversation
Should julia> dump(:( ⟨a,b⟩ ))
Expr
head: Symbol call
args: Array{Any}((3,))
1: Symbol anglebracket
2: Symbol a
3: Symbol b and then if someone tries to evaluate that, they get and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable and useful to me, I think this was just forgotten. Are you still interested in this?
@test Meta.lower(@__MODULE__, :(⟨a;⟩)) == Expr(:error, "unexpected semicolon inside ⟨ ⟩") | ||
@test_throws ParseError Meta.parse("⟨a b⟩") | ||
@test_throws ParseError Meta.parse("⟨1 2;3 4⟩") | ||
@test Meta.parse("f⟨x⟩") == :(f * $(Expr(:anglebracket, :x))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether it would make more sense to give this its own expression head, like we already do with vect
/ref
, braces
/curly
, or [typed_]h/vcat
, instead of parsing this as juxtaposition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a good idea. :anglecall
? :anglegetindex
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, anglecall
probably seems most natural to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One reason we might want to call it :anglegetindex
is because it seems natural to also want a :anglesetindex
for the expression f⟨x⟩ = 1
, but I don't have a strong feeling either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be called angleref
then? With this PR, your example should still be valid surface syntax for use in macros. I don't think we want to do anything special for this in lowering though, at least for now, since it's not really clear what this should do.
I agree with @MasonProtter that |
Yes definitely has interests and I need some instructions. |
Ok, awesome!
I am not so sure whether angle brackets should behave more like regular parentheses or square brackets,
Your current implementation looks good to me overall, you probably want to have a look at the function
Yeah, that's always the hardest part! 😆 I think |
By not defining anglebracket in base though it means that packages exporting it will conflict with each other. It seems to me that |
Then they should coordinate with each other via a lightweight ____base package that defines the meaning they want for the angled brackets.
That seems like a huge waste of this syntax, if it’s only purpose would be to be a other way to spell |
This is part of #27697, in which we decided to add brackets one by one.
On this pr:
Note, this pr implements the angle bracket as function call
anglebracket
. No other functionality is implemented. Especially,⟨1; 2⟩
⟨1 2⟩
⟨1 2; 3 4⟩
f⟨x⟩