Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 13 12:50:38 PDT 2014


On Sunday, 12 October 2014 at 09:29:08 UTC, Joseph Rushton
Wakeling via Digitalmars-d wrote:
> On 11/10/14 11:16, Walter Bright via Digitalmars-d wrote:
>> On 10/10/2014 4:16 PM, Joseph Rushton Wakeling via 
>> Digitalmars-d wrote:
>>> I agree with that general sentiment, but doesn't this patch 
>>> only deprecate
>>> left-hand-side function attributes?
>>
>> Only some of them, others remain:
>>
>>     pure int foo() { ... }
>
> Not good.  If LHS function attributes are to be deprecated, it 
> really ought to be all or nothing.
>

No. Let me explain. In
qualifier(type) identifier();
qualifier apply to type. This is all good, as expected.

In
attribute type identifier();

attribute apply to identifier. identifier is a function here, and
it make sense to apply pure on a function.

The problem with type qualifier on a function, is that they do
not make any sense. For some reason, a type qualifier used on a
function will qualify the implicit parameter.

It is confusing the hell out of everybody as there is a thing on
which is make sense to apply the qualifier to (the return type)
and a thing where it does not make sense (the function) but for
some reason, when you apply it on the function it has a "magic"
meaning. That is the surprise effect.


More information about the Digitalmars-d mailing list