disable all member function calls for rvalues?

Michel Fortin michel.fortin at michelf.com
Fri Dec 25 07:41:53 PST 2009


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.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list