Go and generic programming on reddit, also touches on D

Simen Kjaeraas simen.kjaras at gmail.com
Sun Sep 18 13:54:57 PDT 2011


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

> On 9/18/11 3:19 PM, dsimcha wrote:
>> On 9/18/2011 4:09 PM, Andrei Alexandrescu wrote:
>>> opDollar is more powerful because it can be made to work with infinite
>>> ranges.
>>>
>>> Andrei
>>
>> Yes, this is important. IMHO, though, the default behavior of the $
>> operator should be to call range.length if it exists and opDollar isn't
>> explicitly overloaded. This would save a lot of boilerplate.
>
> struct MyRange
> {
>    ...
>    alias length opDollar;
> }
>
> I do agree that most of the time this is what you want anyway, so that  
> line would occur a lot of times...

This works if opDollar is expected to be a niladic function. For multi-
dimensional structures, it would have to be monadic.

-- 
   Simen


More information about the Digitalmars-d mailing list