Go and generic programming on reddit, also touches on D

Simen Kjaeraas simen.kjaras at gmail.com
Sun Sep 18 13:46:12 PDT 2011


On Sun, 18 Sep 2011 22:09:19 +0200, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 9/18/11 2:46 PM, Nick Sabalausky wrote:
>> "Timon Gehr"<timon.gehr at gmx.ch>  wrote in message
>> news:j55h4f$1ia5$1 at digitalmars.com...
>>>
>>>> The only advantages slices have left
>>>> are (a) type syntax, i.e. T[] instead of Slice!T, (b) literal syntax,
>>>> i.e. [ 1, 2, 3 ] instead of slice(1, 2, 3), and (c) a couple of stray
>>>> language bugs such as '$'.
>>>
>>> I am thankful for $, as it is a great feature, and it really should be
>>> made accessible to user defined types. Either through opDollar or the
>>> rewrite a[foo($)] =>  a[foo(a.length)]. What makes it qualify as a  
>>> stray
>>> language bug to you?
>>>
>>
>> He's saying that one of the few advantages slices have left over
>> user-defined types is that, for slices, $ actually works. The bug is  
>> that it
>> doesn't work for user-defined types.
>>
>> FWIW, I like the rewrite idea far better than opDollar.
>
> opDollar is more powerful because it can be made to work with infinite  
> ranges.

Also, multi-dimensional structures:

     RectangularArray!int a = [[1,2,3], [4,5,6,7]];
     int b = a[$-1, $-2];

Those are obviously different $s.

-- 
   Simen


More information about the Digitalmars-d mailing list