Negation of attributes (DIP 79)

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 2 08:44:14 PDT 2015


On 6/2/15 11:18 AM, Dejan Lekic wrote:
> On Tuesday, 2 June 2015 at 12:13:47 UTC, ref2401 wrote:
>> On Tuesday, 2 June 2015 at 10:29:35 UTC, Daniel Kozak wrote:
>>> I am working on dip which will try to addressed negation of
>>> attributes issue.
>>> http://wiki.dlang.org/DIP79
>>
>> You propose to add extra difficulty to the language and the only
>> reason is "If you need add few methods which are virtual or variables,
>> you are forced to put them before final:. This is too limiting.".
>> I think it's a bad idea.
>
> I agree.
> On top of that, we have final { /* your final methods here */ } as a
> good alternative already.

No, this is not good enough. Let's say we have 20 member functions of a 
struct/class. All of them are @safe and @nogc. All but a few are 
nothrow, all but a few (a different few) are pure. Some are const, some 
aren't.

The most verbose way to do this is to put attributes on each function, 
blowing up all the signatures.

The most effective way would be to do this:

pure @safe nothrow @nogc {
...
}

And put attribute negations on the few odd functions that are different 
(including adding const, which I think appropriately belongs on each 
method that needs it).

But your confusing mechanism is to pull out functions from their natural 
order outside the scope, and attribute them separately. But that screws 
up documentation, and it may separate overloads which naturally belong 
together.

The best way is to label the oddballs, and we don't have a good way of 
doing that for most of the cases since the oddballs need less attributes.

> Finally, as far as I know, D will change the behaviour to final by
> default. What happened with that? Anything decided?

That is not happening. It was nixed by Andrei.

-Steve


More information about the Digitalmars-d mailing list