I suppose we are getting away from the original topic, except by the thin thread that includes concatenation operators.
Suppose it is handy to represent a wide range of things as a count indexed array, that is, an array with keys 1, 2, 3....
If we embrace overloading comma, then we can see the meaning of comma depending on the context. Contexts are function parameters, perhaps the above sequence builder notation with brackets, and the general expression context. Other clear contexts can be added.
I assume something like this is meaningful in this notation:
Code: Select all
put [ [ "a", "b" ], [ "c", f(x)] ] into y
As I mentioned, a function could do that but a long function name can make it harder to read. Also, the brackets mixed with parentheses (as in the above example) make reading easier than a lot of parentheses. I'm not sure that a comma in a special context is the way to go or,if it is,whether [] is the way to indicate that context; I'm speaking in abstractions.
(When there is a special context, the comma might not be needed; maybe juxtaposition, that is, adjacent elements will suffice.)
This could be used to create a singleton like this:
That might be easier to read than, say:
Code: Select all
put "reset"->[1] into cmds
put 1:"reset" into cmds
put *"reset" into cmds
I'm not sure which really looks best.
There should be a way to concatenate such a count indexed array. And if there is a singleton operator and not a builder for a count indexed array then that should be simple and maybe built-in. The much coveted colon could be used or '&' could be overloaded for concatenating count-indexed arrays. Like this:
Code: Select all
put goHomeCmds : *"reset" : cleanRoomCmds(room) into cmds
put goHomeCmds & [ "reset" ] & cleanRoomCmds(room) into cmds
put { goHomeCmds ["reset"] cleanRoomCmds(room) } into cmds
That doesn't really look like LiveCode any more.
Maybe those can be compared to what we might do now:
Code: Select all
put catSeq( goHomeCmds, sequence("reset"), cleanRoomCmds(room) ) into cmds
It might be possible to automatically convert nonarrays to singletons, but there will still need to be a way to make an array an element of the resulting concatenated sequence and not concatenated by the operation. So the last one above might optionally be written like this:
Code: Select all
put { goHomeCmds "reset" cleanRoomCmds(room) } into cmds
And an example of making an array an element might look like this:
Code: Select all
put (goHomeCmds "reset" "do twice" [cleanRoomCmds(room)] } into cmds
There might be a way to do that without using up special characters.
We might be losing a lot of ways to make typos that create errors. If almost everything we type looks good, then many typos will not be caught.