DMD 0.177 release [Length in slice expressions]

BCS BCS at pathilink.com
Wed Dec 20 13:41:03 PST 2006


Chris Nicholson-Sauls wrote:
> The "[..$]" syntax is also present in ColdC and its relatives (including 
> my Bovis), so it was familiar to me from the beginning.  (That said I 
> still harbor thoughts that $ could be used for other things... but 
> honestly, I think the syntax would be unambiguous: a lone $ as the right 
> hand side of a slice expression should easily enough be distinguishable 
> from a $ anywhere followed by something, like an identifier.)
> 

FWIW $ is not only used for the RHS of a slice

char[] str;
str[$/2..$];	// 2nd half of array
str[$-1];	// last element in array
str[$-5..$];	// last 5 things in array
str[$-10..10];	// um... well... you get the idea

> Which leads me to another thought.  One other operator that ColdC and 
> family posesses is the @ for list splicing.  Useless sample ColdC:
> 
> # var foo, bar, result;
> #
> # foo = {1, 2, 3};
> # bar = {4, 5, 6};
> # result = {@foo, @bar};
> 
> The 'result' variable now equals {1, 2, 3, 4, 5, 6}.

I would think this would be the same thing.

auto foo = [1,2,3];
auto bar = [4,5,6];
auto result = foo ~ bar;

am I missing somethign?
> 
> -- Chris Nicholson-Sauls



More information about the Digitalmars-d-announce mailing list