Why begin/end instead of { } for block delimiter

we already have begin and end for block delimiting though; feels like there must be a more interesting use floating out there…

I like Julia’s use of ()—it works unambiguously despite being used for all manner of things: evaluation precedence, function call, tuple, named tuple, and generator.

And then [] is pretty well-utilized for vectors, matrices, and the whole gamut of other arrays, as well as indexing.

Maybe Dict? It’s a built-in type that has no dedicated syntax. Maybe it deserves something? JavaScript uses {} for dynamic objects that organize into tree structures, which behave in many ways similarly to Dict, so this might make JavaScripters happy. Or maybe a PropDict (from PropDicts.jl) would be a bit nicer, with {a=1, b=2} being syntax sugar for PropDict(:a=>1, :b=>2); then JSON could almost be plugged in directly as Julia code.

Or, maybe Set? It’s tempting that set theory already uses curly braces for sets and for set builder notation, so maybe {item1, item2, item3} for Set(item1, item2, item3). I wonder if it’d be interesting to make lazily evaluated (possibly infinite) sets, e.g. evensquares = {x where y isa Int && x = y^2}. I have zero insight into programmatic set manipulation, I’m just spitballing.

Or, for the functional language aficionados, maybe use it for the lazily evaluated List object from Lazy.jl… maybe {1, 2, 3, ...} for a list? (and assume it’s an arithmetic or geometric sequence, perhaps)

Or, considering that curly braces are already heavily used in Julia’s type system, perhaps there’s some sort of “type arithmetic” that can be done… I’m still trying to figure out how to subtract a type, hah.

Or, maybe our machine learning friends can offer some ideas. Maybe it could be used as a data structure for neural nets, or maybe graphs more generally, who knows.

All I’m saying is, using {...} as a stand-in for begin...end seems wasteful. {} are such generally useful characters, to burn them on something that already has syntax would be a shame. (I remember as a kid how weird it felt to learn {} for block delimiting but eventually with practice coming to love it, and then many years later learning MatLab and feeling “hey, end feels fine too!”)

9 Likes