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
A pain point when writing macros is detecting all the types of things which might be lowered to functions and correctly extracting the formal arguments. This is due to
Existence of both short form and long form function definitions
The argument lists of anonymous functions being parsed into varying inconsistent Expr forms
JuliaSyntax already deals with part (2) of this.
I wonder if we should also deal with part (1) by emitting a clearer AST.
Currently we have
julia>parsestmt(SyntaxNode, "f()::T = 1")
line:col│ tree │ file_name
1:1 │[=]
1:1 │ [::-i]
1:1 │ [call]
1:1 │ f
1:6 │ T
1:10 │ 1
But it would be easy to change this into
julia>parsestmt(SyntaxNode, "f() = 1")
line:col│ tree │ file_name
1:1 │[function-=]
1:1 │ [call]
1:1 │ f
1:7 │ 1
And to have a syntax flag "=" set on the function node to indicate it was short-form syntax.
The text was updated successfully, but these errors were encountered:
Well this was easy and I nerd sniped myself. so I just went and implemented it.
@JeffBezanson thoughts? Could be nice if macro authors didn't have to simulate this bit of lowering. It does depart from the surface syntax a little by adding semantics during parsing. That's always a hard call but I feel like the AST might be an improvement in this case.
A pain point when writing macros is detecting all the types of things which might be lowered to functions and correctly extracting the formal arguments. This is due to
Expr
formsJuliaSyntax already deals with part (2) of this.
I wonder if we should also deal with part (1) by emitting a clearer AST.
Currently we have
But it would be easy to change this into
And to have a syntax flag "
=
" set on thefunction
node to indicate it was short-form syntax.The text was updated successfully, but these errors were encountered: