Why is std.algorithm so complicated to use?

Timon Gehr timon.gehr at gmx.ch
Tue Jul 10 13:04:17 PDT 2012


On 07/10/2012 09:36 PM, Jesse Phillips wrote:
> On Tuesday, 10 July 2012 at 00:17:12 UTC, Timon Gehr wrote:
>> I have heard that rumour, but TDPL wisely specifies the behaviour of
>> the @property attribute as follows:
>>
>> 'In particular "property" is recognized by the the compiler
>> and signals the fact that the function bearing such an attribute must
>> be called without the trailing ().'
>>
>> That is exactly the behaviour I described.
>>
>> Note that this sentence includes the notion of _calling a function_
>> without the trailing () and it even seems to express that the trailing
>> () is usually optional.
>
> No it doesn't. It does have emphasis with 'must' and this likely comes
> from D having such a long history of the optional (), but that does not
> make this statement include such a notion.
>

I'm sure a lawyer could make a good case out of it. Anyway, TDPL
clearly does not document the broken -property behaviour.

>> So TDPL actually describes a subset of what I have in mind. (it seems
>> to leave out the function = argument case completely.) We should
>> therefore change where we are headed.
>
> The -property is an implementation of what is to come. I was never
> greatly for property but since we have it it should be fully enforced,
> otherwise we may as well just drop it.

I think you may be misunderstanding what @property is about.

Given:

@property int delegate() foo(){ ... }
@property int bar(){ ... }
int baz(){ ... }

foo(); // calls the delegate.
bar(); // illegal
baz;   // ok, call baz

dmd -property gets every single one of these wrong. -property does _not_
enforce @property semantics. It only adds a silly rule that was never
part of the @property design. I am astonished that it made it into the
compiler.


More information about the Digitalmars-d mailing list