property syntax strawman

Robert Jacques sandford at jhu.edu
Sun Aug 2 17:18:51 PDT 2009


On Sun, 02 Aug 2009 09:39:41 -0400, Michel Fortin  
<michel.fortin at michelf.com> wrote:

> On 2009-08-02 03:43:43 -0400, Walter Bright <newshound1 at digitalmars.com>  
> said:
>
>> The alternative is to have a unique syntax for properties. Ideally, the  
>> syntax should be intuitive and mimic its use. After much fiddling, and  
>> based on n.g. suggestions, Andrei and I penciled in:
>>     bool empty { ... }
>>    void empty=(bool b) { ... }
>
> Looking at it more carefully, this looks like an invitation to omit  
> parenthesis for functions with no argument. I mean, look at this and  
> tell me what it is?
>
> 	T transform { ... }
>
> Is this a transform property (returning and affine transform) or an  
> action function returning transform? I'd guess it's a property since it  
> has no parenthesis, but nothing makes this very clear.
>
> And could you do this? Would Andrei be tempted by this?
>
> 	void popFront { ... }
>
> Note that I'm brigning this as an observation. Style guidelines can be  
> written mandating parenthesis for actions functions, which means my  
> problem of writing a coherent naming guideline is solved. But who read  
> the style guidelines?
>
> While I like this syntax, the "getProperty()"/"setProperty()" syntax  
> (and also the "property" keyword syntax) has one advantage over this  
> one: it forces the interface to explicitly say "this is a getter/setter"  
> or "this is a property", which I expect would reduce abuses. It's the  
> same difference between as "opAdd" vs. "op+".
>

I also like the idea of omitting parenthesis for functions with no  
argument.



More information about the Digitalmars-d mailing list