Revised RFC on range design for D2

Bruno Medeiros brunodomedeiros+spam at com.gmail
Thu Oct 2 08:00:11 PDT 2008


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?... :(

-- 
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D


More information about the Digitalmars-d-announce mailing list