@property needed or not needed?

deadalnix deadalnix at gmail.com
Mon Nov 19 21:23:41 PST 2012


Le 19/11/2012 00:45, thedeemon a écrit :
> On Monday, 19 November 2012 at 08:23:43 UTC, Jonathan M Davis wrote:
>> On Monday, November 19, 2012 09:16:29 Rob T wrote:
>>> My guess is that if @property gets enforced, we'll see a lot of
>>> functions with empty parameter lists being defined as @property
>>> for the sole reason to get rid of having to type in the ().
>>
>> Which completely violates the concept of a property in the first
>> place. It's
>> intended to be an abstraction for a variable. Using @property just to
>> get rid
>> of parens would be like naming types with verbs instead of nouns. It's
>> completely backwards.
>>
>> - Jonathan M Davis
>
> I very much like the combination of UFCS, ranges and parens-free style
> which allows writing code like
>
> iota(0, 1000000).map!(to!string).retro.take(50).retro[10].writeln;
>
> So I like Andrei's idea to force @property only for those functions
> where it's absolutely necessary to fight ambiguity.

With opDispatch and clear semantic, the following is doable :

iota(0, 1000000).map!(to!string).retro.take(50).retro[10].writeln();

No need for an ambiguous situation where function get called implicitly.


More information about the Digitalmars-d mailing list