property syntax strawman

John C johnch_atms at hotmail.com
Tue Aug 4 06:27:33 PDT 2009


Sjoerd van Leent wrote:
> Andrei Alexandrescu Wrote:
> 
>> Nick Sabalausky wrote:
>>> "Walter Bright" <newshound1 at digitalmars.com> wrote in message 
>>> news:h53g3i$elk$1 at digitalmars.com...
>>>>   bool empty { ... }
>>>>   void empty=(bool b) { ... }
>>>>
>>>> What do you think?
>>> I think that if D starts to make a habit of aping the ugly C++ approach to 
>>> adding new features (as this does), then we may as well just use C++. 
>> Let's not forget that C++ got very conservative about adding keywords 
>> after a keyword spree (class that is essentially same as struct, 
>> namespace, xyz_cast, oh yes typename, and, or, not plus other useful 
>> names that I probably forgot). We don't want to get there.
>>
>>
>> Andrei
> 
> I understand your point of view, but I am afraid that using an awkward syntax makes things difficult to understand. However, I could certainly live with the current proposal. But this has to do that I'm not afraid of symbolic ways to achieve something. Others might find it more difficult.
> 
> I think that a setter and a getter are two different things, but I would avoid to have an inconsistent property, such as setting an int and getting a bool, or something similar. Perhaps a compiler check could intercept?
> 
> But I think I can do it with the keywords that we already have in our possession:
> 
> bool in empty
> {
> }
> 
> bool out empty
> {
> }
> 
> Although perhaps this could be argued against, as in and out are used for contract programming. But this clearly is a different use.

in and out are also used for function parameters, remember.



More information about the Digitalmars-d mailing list