Struct polymorphism?
Era Scarecrow
rtcvb32 at yahoo.com
Mon Oct 8 15:19:27 PDT 2012
On Monday, 8 October 2012 at 15:23:58 UTC, Era Scarecrow wrote:
> Error: function expected before (), not
> 'this.polyBase.opDispatch!("orig")'
I think this is a compiler bug. It complains about calling
opDispatch, however it doesn't complain if you explicitly call
'this'. Should adding 'this' be required? I am using the
-property switch so it's a little more strict, but that doesn't
seem to change the results. I can't just start adding 'this' to
all my function as outside normal functions/variables won't ever
be seen.
struct S {
Something polyBase;
alias polyBase this; //opDispatch
string callsOrig() {
return orig; //works but misleading
return orig(); //breaks
return orig(1); //breaks too
return this.orig(); //works
}
}
struct Something {
auto ref opDispatch(string fun, Args ...)(auto ref Args args)
@property;
}
My experiments concentrating on this part rather than with
arguments, those will come later when this works.
More information about the Digitalmars-d-learn
mailing list