Getting the error from __traits(compiles, ...)

Yigal Chripun yigal100 at gmail.com
Fri Nov 13 05:44:32 PST 2009


grauzone wrote:
> Yigal Chripun wrote:
>>
>> I really wish this was folded into the language by allowing structs to 
>> implement interfaces.
>>
>> interface Range(T) {
>>   bool empty();
>>   void popFront();
>>   T front();
>> }
>>
>> struct MyRange(T) : Range!(T) { ... } // checked by compiler
>>
> 
> One problem with this was that arrays wouldn't automagically be ranges 
> anymore. Right now, "int[] a; a.popFront();" works, because std.array 
> has a global function popFront. Some old language hack turns a.popFront 
> into popFront(a).

you're talking about this construct:
int[] arr;
void foo(int[], params) {}  => arr.foo(params);

This should not be considered a hack but rather should be a feature 
extended for all types. see extension methods in C#.

I also think that arrays (containers) must be distinct from 
slices/ranges (views).



More information about the Digitalmars-d mailing list