Would you mind opening an issue about it? https://github.com/JuliaLang/issues/new
On Wed, Apr 23, 2014 at 8:46 AM, Klaus-Dieter Bauer < [email protected]> wrote: > I noticed that the "do" keyword behaves weirdly when trying to use it on a > single line, e.g. in the REPL: > > When the "do" keyword is used to create a function with one or more > arguments everything works fine. > julia> map([1,2,3]) do x 1+x end > map([1,2,3]) do x 1+x end > 3-element Array{Int64,1}: > 2 > 3 > 4 > > Without arguments, multi-line usage works fine ... > julia> cd("c:/tmp") do > cd("c:/tmp") do > > println(1) > end > 1 > > ... but single line usage fails ... > julia> cd("c:/tmp") do println(1) end > cd("c:/tmp") do println(1) end > ERROR: syntax: malformed function arguments (call println 1) > > ... and a ; cannot be used to fix it: > julia> cd("c:/tmp") do; println(1) end > cd("c:/tmp") do; println(1) end > ERROR: syntax: unexpected ; > > Is this an actual inconsistency in the parsing or am I getting something > wrong about how julia handles single-line code? So far it is the first > example where I found a line-break to be both significant and not > replaceable by a semi-colon. > > I am using the julia-0.2.1-win64 binary release. >
