Syntax for arrays?
I'm a little confuzzled on what my syntax for my language should be. Mainly when it comes to arrays.
I don't know if I want predefined functions, or built in syntax. Like this:
The built in syntax definitely looks shorter, but it doesn't really look clean when you're working with an r-value array:
I personally prefer the built in functions for r-value arrays, but the built in syntax for variables.
So which one should I chose? I can't do both
Entirely depends on your language paradigm. If it's OO in some capacity then builtin functions is the way to go. If it's not, then the custom syntax might be a better option. However, even if your language isn't OO you could also make it so that
x.y(<params>) is sugar for
You could also go haskell-style and make it so that custom syntax is basically just defining another function. I really like approaches like this since custom syntax is so arbitrary and not extendable.