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

Rethinking the . AST #324

Closed
c42f opened this issue Jul 8, 2023 · 3 comments · Fixed by #325
Closed

Rethinking the . AST #324

c42f opened this issue Jul 8, 2023 · 3 comments · Fixed by #325
Labels

Comments

@c42f
Copy link
Member

c42f commented Jul 8, 2023

I was working a bit on macro expansion - particularly quote (quasiquote) expansion with $ interpolations - and I've found that it's weird and inconvenient that we parse a.b into (. a (quote b)).

Specifically, the part that's weird here is that we emit (quote b) for the field name even though this is "not quote syntax": this should not yield a syntax literal during lowering, and is thus a semantic mismatch with actual quote syntax of the form :(a + b) or quote a+b end.

Q & A:

  • Why is this a problem? It means we need special rules to distinguish actual syntax literals from field names.
  • But can we really change this? Surely this AST form had a purpose? Yes! A long time ago Julia supported a.(b) syntax to mean getfield(a, b), which would naturally have been parsed as (. a b). However this was deprecated as part of adding broadcast syntax in WIP: implement f.(args...) as a synonym for broadcast(f, args...) julia#15032

I propose we just parse a.b as (. a b) with the second argument implied to be a field name.

@c42f c42f added the AST label Jul 8, 2023
@c42f
Copy link
Member Author

c42f commented Jul 8, 2023

CC @BenChung - I imagine you might have encountered this AST inconsistency before :-)

@BenChung
Copy link

BenChung commented Jul 8, 2023

I wholeheartedly support the idea of parsing a.b as (. a b) - the old (. a (quote b)) syntax doesn't add anything in my opinion and needs to be special cased out downstream.

@c42f
Copy link
Member Author

c42f commented Jul 8, 2023

Thanks for the second opinion!! PR almost done :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants