Using ()s in @property functions
Leandro Lucarella
luca at llucax.com.ar
Tue Jun 29 07:15:10 PDT 2010
Steven Schveighoffer, el 29 de junio a las 08:13 me escribiste:
> >>There is one thing that bugs me about this solution though. What if the
> >>user does this:
> >>(1) Grab the pointer. *ptr = prop;
> >(1) Grab the pointer. T* ptr = ∝
> >
> >>(2) assigns to it. *ptr = val;
> >>(3) expects the result to be updated in prop. assert(val == prop);
> >
>
> Why would this assert fail? If a property returns a ref
What if it doesn't? If returns a temporary calculated value?
> then you
> set through that ref. What you did is no different, you just
> delayed the assignment for a bit.
>
> You can reduce your test case to:
>
> (1) assign to the property. prop = val;
Is not the same at all! prop = val will call the setter function, *ptr
= val will not!
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
¿Qué será lo que hace que una brújula siempre marque el norte?
- Ser aguja, nada más, y cumplir su misión.
-- Ricardo Vaporeso
More information about the Digitalmars-d
mailing list