Using comma for tupple/array literal operator may bring some problems
not just with "for" comma-sequence expressions, but also with function
call argument lists. Hum... then again maybe not, as it didn't with
comma-sequence expressions.
Anyway, here's an alternative ideia for tupple/array construction, which
uses the '~' concatenation operator for that purpose:
auto arr = 1 ~ 2 ~ 3; // arr type is int[3]
(1 ~ 4 ~ 9)[2]; // value: 9
One could also use it for slices instead of the slice operator:
"Whatever"[4~8]; // value: "ever"
slice = 4~7; // slices are now first class entities.
str[slice]; // value: "eve"
I'm not sugesting this syntax, just presenting it, as it has some
disadvantages besides it's advantages.
Advantages:
* Short syntax allow to replace the slice operator [ .. ]
* Makes some conceptual sense because '~' is already used as a
concatenation operator
Disadvantages:
* Cannot construct literals of arrays of arrays, just arrays of
primitives/references.
* Doesn't visually look as clean/meaningful as the ',' comma operator.
One could have a similar syntax with the ',' token, changing some of the
advantages and disadvantages. One would unfortunately maintain the first
disadvantage, which is why I think something better should tried to be
found.
Has this issue been discussed in the past, with any reasonable ideias
brought up?
--
Bruno Medeiros - CS/E student
"Certain aspects of D are a pathway to many abilities some consider to
be... unnatural."