Revert attributes to their defaults with default keywords

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 9 23:13:09 PST 2015


On Sat, 10 Jan 2015 02:47:00 +0000
Meta via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> On Friday, 9 January 2015 at 14:26:26 UTC, aldanor wrote:
> > It could work both ways at the same time.
> >
> > Maybe even something like "default(pred) final(pred) nothrow" 
> > --> if pred is compile-time-true, reset all attributes and then 
> > add final/nothrow; if it's compile-time-false, disable final 
> > and enable nothrow.
> 
> @disable is also currently a keyword.
> 
> pure nothrow @safe @nogc immutable
> Test
> {
>      //doSomething is nothrow @safe @nogc immutable
>      @disable(pure) void doSomething() {}
> 
>      //getAnInt is pure @nogc immutable
>      @disable(nothrow, @safe) int getAnInt() {}
> 
>      //typeof(n) == int
>      @disable(immutable) int n;
> }
> 
> This is also useful for templated functions, methods, etc. It 
> allows one to tell the compiler that the function in question 
> should never have a particular attribute inferred for it.
> 
> //doSomethingElse will never be inferred as pure,
> //but may be inferred as nothrow, @safe, or @nogc
> @disable(pure) void doSomethingElse()() {}
i chose to go with `@impure`, `@canthrow` and `@gc`. the fact is that
adding new "inverted" attributes requres adding new STC flags into the
compiler. this is very intrusive change. yed UDAs can be checked just
before we set `FUNCFLAG*Inprocess`. this was ALOT easier than hunting
down all the places where i need to take care on new STC flags.

yes, this is ugly hack with ugly new set of attributes, but it's way
easier to support for me. and as i have no hope of taking something
like this into mainline (at least not sooner than another year pass),
maintenance costs becomes very important. complex PR will rot soon and
rotten PR will never make it into mainline.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150110/c4b63117/attachment-0001.sig>


More information about the Digitalmars-d mailing list