On 2009-12-25 11:13:10 -0500, Andrei Alexandrescu
<[email protected]> said:
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.
If we ever get that "universal calling syntax" thing, where any
function can be called as if it were a member function, it would be
super simple:
void MyRange opSlice(MyRange this, int, int) {...}
Just don't put "ref" in front of the first argument.
--
Michel Fortin
[email protected]
http://michelf.com/