Revised RFC on range design for D2

Bruno Medeiros brunodomedeiros+spam at com.gmail
Fri Sep 26 04:25:56 PDT 2008


Andrei Alexandrescu wrote:
> Sergey Gromov wrote:
>> In article <gbgpak$2q10$1 at digitalmars.com>, 
>> brunodomedeiros+spam at com.gmail says...
>>> Also, some more on important bike shed issues:
>>>      for (; !src.done; src.next)
>>>      {
>>>          tgt.put(src.head);
>>>      }
>>>
>>> As a matter of coding style conventions, I would say that using the 
>>> implicit property function call feature on a function that changes 
>>> state is *bad* style, and surely hope the community would agree on that.
>>> So "src.next" would be must better as "src.next()" as "src.next" 
>>> really just makes me cringe.
>>
>> I think that property function call feature in general adds an 
>> unnecessary ambiguity to the language.  I'd prefer functions to be 
>> callable only with regular function call syntax, and properties be 
>> usable only with member access syntax.  The same stands for 'unified 
>> function call' feature: if you want to inject a method into an 'array 
>> of chars' class you do so explicitly, and only the member call syntax 
>> is allowed on that method.  Otherwise code tends to become ambiguous 
>> and unreadable.
> 
> Experience with other languages has shown that using identical syntax 
> for genuine member access and member function access helps 
> maintainability because it allows a type implementer to switch back and 
> forth between implementing a property as a direct member or as a 
> function, transparently to that type's use.
> 

Yet, as Sergey mentioned, the switching back cannot be made safely if 
the field is a delegate (or any other callable type). If the delegate 
requires parameters, then the switch will cause the other code to not 
compile. But even worse, if the delegate has zero parameters, the switch 
will cause the code to compile, but not perform what it was supposed to 
do! I think this is a clear sign the feature as it is currently 
implemented is inadequate.
So either remove the feature (which I see you're not up to, and I 
understand why), or fix it, by removing such ambiguity.

-- 
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