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

AST: parse a.b as (. a b) #325

Merged
merged 1 commit into from
Jul 8, 2023
Merged

AST: parse a.b as (. a b) #325

merged 1 commit into from
Jul 8, 2023

Conversation

c42f
Copy link
Member

@c42f c42f commented Jul 8, 2023

Fix #324 as described there.

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`.

* 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
  JuliaLang/julia#15032

Here we simplify by parsing `a.b` as `(. a b)` instead, with the second
argument implied to be a field name.
@codecov
Copy link

codecov bot commented Jul 8, 2023

Codecov Report

Merging #325 (50a4403) into main (5aad812) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #325      +/-   ##
==========================================
- Coverage   96.56%   96.54%   -0.03%     
==========================================
  Files          14       14              
  Lines        4139     4140       +1     
==========================================
  Hits         3997     3997              
- Misses        142      143       +1     
Impacted Files Coverage Δ
src/parser.jl 98.03% <ø> (-0.01%) ⬇️
src/expr.jl 99.68% <100.00%> (-0.32%) ⬇️

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

Successfully merging this pull request may close these issues.

Rethinking the . AST
1 participant