Revised RFC on range design for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Oct 2 08:04:20 PDT 2008


Bruno Medeiros wrote:
> Bill Baxter wrote:
>>
>> ---
>> Somewhat unrelated, but there still exists the annoyance in D that if
>> you have to functions with the same name and you want to take the
>> address of one of them, you can't.  Furthermore I can't think of a
>> reasonable syntax to do that easily.  For that reason,  I really think
>> the best getter and setter functionality in D would be something where
>> you have distinctly named *functions* getProp and setProp for when you
>> want/need functions mirroring samely-named *properties* for which only
>> property syntax would work.
>>
> 
> Hum, that reminds me of an idea I once had for properties: not using a 
> keyword, but only convention, just as the op* methods for operator 
> overload. Basicly one writes a property with getter and setter 
> functions, like Java:
> 
> class Foo {
>   SomeBar getSomeBar();
>   void setSomeBar(SomeBar someBar);
> }
> 
> one can then access those functions normally, like Java, but one would 
> then also be able to use a property with the same name of the 
> getter/setter methods, but without 'get' or 'set', and with the 
> capitalization of the first letter fixed, like this:
> 
>   Foo foo = ...;
>   SomeBar someBar = foo.someBar;
>   //same as: SomeBar someBar = foo.getSomeBar();
> 
>   foo.someBar = new SomeBar();
>   //same as: foo.setBar(new SomeBar());
> 
> This makes it easy to use Java-style code (for instance when porting 
> Java code, or using libs like DWT, etc.).
> What I don't like here, is that this solution involves working with the 
> capitalization/CamelCase of the property, which doesn't sound right. And 
> what about properties that start with a capital letter?... :(

What's going on now is pretty much that except that there's no more 
symbol changing - it's just someBar() and someBar(SomeBar).

Andrei



More information about the Digitalmars-d-announce mailing list