Possible @property compromise

Zach the Mystic reachBUTMINUSTHISzach at gOOGLYmail.com
Thu Jan 31 19:08:10 PST 2013


On Friday, 1 February 2013 at 01:53:05 UTC, TommiT wrote:
> On Friday, 1 February 2013 at 00:59:47 UTC, Zach the Mystic 
> wrote:
>> writeln(foo.n); // uses alias this to call __mightAsWellBeOpGet
>
> No it won't. It will print "n()".
>
> And that exactly (passing to a templated parameter) is the 
> insurmountable problem in using a variable to represent a 
> property.

to!string(foo.n)... hmmm... not that I know how to solve it right 
away, but is it possible to do:

alias template theFuncIActuallyWant this;

int theFuncIActuallyWant() { return 1; }

...in order to have it pass the right thing to the template 
parameter? That's just a jury rigged syntax which might help 
structs make more sense to the compiler when passed through 
templates. You say it's insurmountable, and I don't know enough 
about the details to know, but it seems like surely SOMETHING 
could be done to get the right result without messing up 
everything else in the process.


More information about the Digitalmars-d mailing list