You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: docs/src/reference.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,7 @@ class of tokenization errors and lets the parser deal with them.
64
64
65
65
### Improvements for AST inconsistencies
66
66
67
+
* Field access syntax like `a.b` is parsed as `(. a b)` rather than `(. a (quote b))` to avoid the inconsistency between this and actual quoted syntax literals like `:(b)` and `quote b end` ([#342](https://github.com/JuliaLang/JuliaSyntax.jl/issues/324))
67
68
* Dotted call syntax like `f.(a,b)` and `a .+ b` has been made consistent with the `K"dotcall"` head (#90)
68
69
* Standalone dotted operators are always parsed as `(. op)`. For example `.*(x,y)` is parsed as `(call (. *) x y)` (#240)
69
70
* The `K"="` kind is used for keyword syntax rather than `kw`, to avoid various inconsistencies and ambiguities (#103)
0 commit comments