Skip to content

Parse do syntax without desugaring the closure#98

Merged
c42f merged 1 commit intomainfrom
cjf/flatter-do-ast
Sep 14, 2022
Merged

Parse do syntax without desugaring the closure#98
c42f merged 1 commit intomainfrom
cjf/flatter-do-ast

Conversation

@c42f
Copy link
Copy Markdown
Member

@c42f c42f commented Sep 14, 2022

The reference parser represents do syntax with a closure for the second
argument. That is,

f(x) do y
    body
end

becomes (do (call f x) (-> (tuple y) (block body))) in the reference parser.

However, the nested closure with -> head is implied here rather than present
in the surface syntax, which suggests this is a premature desugaring step.

Instead this PR changes things to emit the flatter structure (do (call f x) (tuple y) (block body)).

Discussed with @JeffBezanson today on a call.

Part of #88

The reference parser represents `do` syntax with a closure for the second
argument. However, the nested closure with `->` head is implied rather
than present in the surface syntax, which suggests this is a premature
desugaring step. Instead we emit a flatter three-argument form for `do`.
@c42f c42f mentioned this pull request Sep 14, 2022
33 tasks
@c42f c42f merged commit 74f7137 into main Sep 14, 2022
@c42f c42f deleted the cjf/flatter-do-ast branch September 14, 2022 19:53
@c42f c42f added the trees label Sep 21, 2022
c42f added a commit to JuliaLang/julia that referenced this pull request Oct 17, 2025
…ax.jl#98)

The reference parser represents `do` syntax with a closure for the second
argument. However, the nested closure with `->` head is implied rather
than present in the surface syntax, which suggests this is a premature
desugaring step. Instead we emit a flatter three-argument form for `do`.
topolarity pushed a commit to JuliaLang/julia that referenced this pull request Nov 14, 2025
…ax.jl#98)

The reference parser represents `do` syntax with a closure for the second
argument. However, the nested closure with `->` head is implied rather
than present in the surface syntax, which suggests this is a premature
desugaring step. Instead we emit a flatter three-argument form for `do`.
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 this pull request may close these issues.

1 participant