www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - opCat request

reply "Ben Hinkle" <bhinkle mathworks.com> writes:
Can we get an operator (or perhaps tweak an existing operator) that does
concatentation but allows multiple values or maybe binds left-to-right
instead of right-to-left? Suppose I have
 int[] x;
and want to write something like
 x ~= 1;
 x ~= 2;
 x ~= 3;
more compactly. I can't use ~= like
 x ~= 1 ~= 2 ~= 3
since 2 isn't an lvalue. I also can't write something like
 x ~= 1 ~ 2 ~ 3
since 1 ~ 2 isn't allowed. It would be nice to get some compact way of
expressing "append 1,2,3". Maybe a new syntax like
 x ~= [1,2,3];
that is sugar for the expression "x~=1,x~=2,x~=3". I haven't thought too
hard about general solutions but the current situation gets pretty wordy.

Nov 04 2004
parent "Walter" <newshound digitalmars.com> writes:
I think doing array literals would solve the problem. Array literals are on
the list for 2.0.
Nov 04 2004