AST: Rearrange do
to sit inside call
/macrocall
#322
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
do
syntax is represented inExpr
with thedo
outside the call. This makes some sense syntactically (do appears as "an operator" after the function call).However semantically this nesting is awkward because the lambda represented by the do block is passed to the call. This same problem occurs for the macro form
@f(x) do \n body end
where the macro expander needs a special rule to expand nestings of the formExpr(:do, Expr(:macrocall ...), ...)
, rearranging the expression which are passed to this macro call rather than passing the expressions up the tree.In this PR, we change the parsing of
to tack the
do
onto the end of the call argument list:This achieves the following desirable properties
do
is nested inside the call which improves the match between AST and semanticsdo
head is used uniformly for both call and macrocallFix #319