Accessors, byLine, input ranges

Steven Schveighoffer schveiguy at yahoo.com
Fri Jan 29 08:39:43 PST 2010


On Fri, 29 Jan 2010 11:29:22 -0500, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> Steven Schveighoffer wrote:
>> On Fri, 29 Jan 2010 11:21:28 -0500, Andrei Alexandrescu  
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>
>>> How is f.byLine clearer and less ambiguous than f.byLine()? Or vice  
>>> versa for that matter?
>>  Note that properties can be named things other than byLine.
>>  -Steve
>
> What I meant to say is that in the @property landscape the following two  
> conventions become suddenly attractive:
>
> * Do not use @property at all
>
> * Use @property for all nullary functions
>
> And they're bound to save a lot of time to everyone involved.
>

I think we all agree that setters the way D1 does them are very prone to  
abuse.  So all that is left is no-argument functions.

There are other alternative conventions to what you stated.  This is my  
convention:

* use @property where the main purpose of the function is to fetch a value  
(computed or not, modifying the container or not)

There are others mentioned in this thread.  A property convention is  
useful to readers of the code.  The existence of the property feature  
makes it *possible* to define conventions -- it doesn't define a  
convention itself.

-Steve



More information about the Digitalmars-d mailing list