Why begin/end instead of { } for block delimiter

There’s another thing I forgot: in the early days of Julia, {a; b; c} and {a, b, c} were syntax for what is now Any[a; b; c] or Any[a, b, c], e.g. in Julia 0.3:

julia> {3,4,5}
3-element Array{Any,1}:
 3
 4
 5

julia> {3;4;5}
3-element Array{Any,1}:
 3
 4
 5

This was directly taken from Matlab’s cell array syntax. In Julia 0.4, this was deprecated in favor of Any[...] for literal arrays of arbitrary-type elements (which aren’t used that often anyway). As you say, this could have freed up the {a; b; c} syntax for blocks, but it would have been a big upheaval at that point, with not a huge benefit.

Now, we are free to to use {a; b; c} for a really cool new feature (if we can think of one) without breaking anything. It’s already available for people to use in macros for domain-specific languages because it parses:

julia> ex = Meta.parse("{a;b;c}")
:({a; b; c})

julia> dump(ex)
Expr
  head: Symbol bracescat
  args: Array{Any}((3,))
    1: Symbol a
    2: Symbol b
    3: Symbol c
14 Likes