DIP23 Counter Proposal

Timon Gehr timon.gehr at gmx.ch
Tue Feb 5 19:15:40 PST 2013


On 02/06/2013 03:45 AM, Steven Schveighoffer wrote:
> ...
>
> There are a couple of clarifications I was curious about:
>
> 1. Does &prop work?  If so, what does it do?

It attempts to take the address of the result of the getter call.

> 1a. if &prop doesn't work, does &__traits(propertyAccessors, prop) work
> (and give you the delegate to the property function overload set)?  I
> can only imagine this is the reason you have the rewrite to a __traits
> call...

Yes, exactly, &__traits(propertyAccessors, prop) gives delegate/function 
pointer access to the @property function overload set.

> 2. Inside the rules for when you do prop = exp, you specify that if the
> return is void, the expression is rewritten as
> (__traits(propertyAccessors, prop)(exp), prop).  I see some issues with
> this:
>     2a. If you are NOT using the expression beyond the assignment, why
> call the accessor again?
>     2b. This would preclude write-only properties (as the second element
> of the comma expression is invalid).  Is that intentional?

Not really. Good catch. Refined.

>     2c. What about ref returning properties?  In those cases, the
> rewrite should be __traits(propertyAccessors, prop)() = exp;
>

I had forgotten to specify this. (The setter rewrite should be performed 
only if it makes sense.)

I also had forgotten to treat alias declarations and template alias 
parameters. This is fixed now as well.


More information about the Digitalmars-d mailing list