disable all member function calls for rvalues?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Dec 25 08:13:10 PST 2009


Michel Fortin wrote:
> On 2009-12-25 09:13:13 -0500, Andrei Alexandrescu 
> <SeeWebsiteForEmail at erdani.org> said:
> 
>> Anyway, I dropped the suggestion due to the array slice example, but I 
>> still think this is a serious problem with D.
> 
> If you could pass "this" by value instead of ref, it'd solve the problem 
> nicely:
> 
>     struct MyRange {
>         MyRange opSlice(int, int) @byvalue;
>         void length(int) @property;
>     }
> 
> Here you can call opSlice on a lvalue since it takes the "this" argument 
> by value, but you can't call length(int) because it takes it by ref.
> 

I've seen that. The only problem I see with that is that it complicates 
the language. Ideally some sort of inference could be applicable.

Andrei



More information about the Digitalmars-d mailing list