Proposal: Extension Methods

Chris Wright dhasenan at gmail.com
Sun May 18 18:19:24 PDT 2008


Chris Wright wrote:
> Nick Sabalausky wrote:
>> "Chris Wright" <dhasenan at gmail.com> wrote in message 
>> news:g0pcpm$14f2$1 at digitalmars.com...
>>> Or: auto a = "file.txt".readText.split.map!(to!(int)));
>>>
>>> Now, since "file.txt" is an array, readText returns an array, and 
>>> split returns an array, you can currently do this. Were any of those 
>>> a class, struct, or scalar, you'd be SOL until uniform call syntax is 
>>> implemented.
>>>
>>
>> Heh, true, I wasn't thinking about that example using all arrays. Bad 
>> example :)
>>
>> Does eliminating the no-argument parentheses like that currently work, 
>> or are you proposing that?
> 
> It works currently. In dunit assertions, for instance, you can do:
> expect(foo).not.sameAs(bar);
> // equivalent to expect(foo).not().sameAs(bar);
> 

Oops, that works because expect is a UDT. It doesn't work with array 
stuff. My mistake.



More information about the Digitalmars-d mailing list