JuliaLang / JuliaSyntax.jl

The Julia compiler frontend
Other
272 stars 35 forks source link

Additional :block for non-standard for loops compared to flisp #403

Open pfitzseb opened 9 months ago

pfitzseb commented 9 months ago

flisp:

julia> Meta.show_sexpr(Meta.parse("for f() = 1:3; f(); end"))
(:for, (:(=), (:call, :f), (:call, :(:), 1, 3)), (:block,
    :(#= none:1 =#),
    (:call, :f),
    :(#= none:1 =#)
  ))

JuliaSyntax#main:

julia> Meta.show_sexpr(JuliaSyntax.parse(Expr, "for f() = 1:3; f(); end"))
(:for, (:(=), (:call, :f), (:block,
      :(#= line 1 =#),
      (:call, :(:), 1, 3)
    )), (:block,
    :(#= line 1 =#),
    (:call, :f),
    :(#= line 1 =#)
  ))

Is this an intentional change?

c42f commented 4 months ago

This was kind of intentional - normally function definitions in short form like f() = 1:3 get a block on the right hand side to hold the definition location of the function.

In a for loop, that definition location just goes missing with the flisp parser for no good reason.