@property - take it behind the woodshed and shoot it?
deadalnix
deadalnix at gmail.com
Thu Jan 24 22:57:51 PST 2013
On Friday, 25 January 2013 at 06:21:59 UTC, Jonathan M Davis
wrote:
> If you make opDispatch @property, then you can't use it with
> normal functions,
> and if you don't make it @property, then it can't be used with
> property
> functions. And you can't overload on @property, so opDispatch
> is pretty much
> screwed with regards to properties at this point. It's
> certainly fixable, but
> there will need to be a (small) change in the language to do so.
>
OK, so opDispatch must definitively be transformed ! I have to
say I didn't saw that coming.
It isn't that big of a deal if we consider we rewrite that way :
a.b => a.opDispatch!"b"
a.b!T => a.opDispatch!("b", T)
No need for opDispatch to actually be a function.
According to what is passed as string, opDispatch can resolve
itself as a function or a delegate. See example :
class Madness {
private void function(Madness)[string] fun;
@property
auto opDispatch(string name)() {
immutable f = fun[name];
return {
return f(this);
};
}
}
A proper inlining mechanism should handle that.
More information about the Digitalmars-d
mailing list