Aliases as Properties

Jarrett Billingsley jarrett.billingsley at gmail.com
Mon Jul 27 16:50:35 PDT 2009


On Mon, Jul 27, 2009 at 7:49 PM, Jarrett
Billingsley<jarrett.billingsley at gmail.com> wrote:
> On Mon, Jul 27, 2009 at 7:33 PM, escalan<escalan at gmail.com> wrote:
>> Hi, I'm new here. A simple idea I've had is to simply use aliases for defining properties.
>>
>> If you allow writing aliases as expressions, you have get properties. Then a simple extension to the syntax would also allow for writing set properties.
>>
>> alias (a) property;
>> alias (a = n) property(n);
>>
>> foo(property); // Get
>> property = 32; // Set
>>
>> This virtually eliminates any problems with properties, and it doesn't require any new keywords. It won't break existing aliases either.
>>
>
> Except if you want to do anything more complex in your setter/getter
> than a simple expression.

Also, if your suggestion really did just replace any accesses to the
property with the aliased expression, there would be no way to
override it in subclasses, it would be invisible to the debugger, etc.



More information about the Digitalmars-d mailing list