DIP4: Properties

Nick Sabalausky a at a.a
Sun Jul 26 21:24:19 PDT 2009


"BLS" <windevguy at hotmail.de> wrote in message 
news:h4ilju$1m51$1 at digitalmars.com...
>
> well, the  one liner assumes that the compiler will do code generation. 
> (maybe I should figure that out...
>
>
> imutable property uint theAnswer = 42:
> ======================================
>
> ie.
> class universe
> {
>
>   inmutable property uint theAnswer = 42:
>
>   /* expands to !!
>
>   pure uint get_theAnswer() nothrow()
>   {
>     return theAnswer;
>   }
>
>
>   private inmutable int theAnswer = 42
>
>   */
>
> }
>
>
> and :
>
> property bool has_cojones;
> ==========================
>
> class manorweeny
> {
>
>   property bool has_cojones;
>
>   /* expands to !!
>
>   bool get_has_cojones()
>   {
>     return has_cojones;
>   }
>
>   void set_has_Cojones(bool yep)
>   {
>     has_cjojones = yep;
>   }
>
>   private bool has_cojones = false;
>  */
>
> }
>
> ---- I just can imagine two property situations :
> Read + Write OR  Read Only...
>
> thanks for you feedback Michiel,
> Björn
>
>

I still don't see how any of that allows any of the things that properties 
are actually used for (as opposed to just an ordinary variable). Under what 
you're proposing, how does one actually write their own getter/setter for 
the property?





More information about the Digitalmars-d mailing list