On Friday, 14 September 2018 at 18:06:55 UTC, Adam D. Ruppe wrote:
Here's the simple idea: __not(anything) just turns off whatever
`anything` does in the compiler.
__not(final) void foo() {} // turns off the final flag (if it
is set)
__not(@nogc) void foo() {} // turns off the @nogc flag (if it
is set)
__not(const)(int) a; // not const
All it does is invert the flags; the implementation would be
like `flags &= ~WHATEVER;` so unless it was already set, it
does nothing and does not check for contradictions.
const:
int b; // const
__not(const)(int) a; // not const
immutable:
int c; // immutable int
__not(const)(int) a; // still immutable int; there was no
const set to turn off.
It also affects attrs brought through definitions though:
shared class foo {
int a; // automatically shared cuz of the above line of code
__not(shared) int b; // no longer shared
}
This is just a generic way to get the flipped attributes WHICH
WE DESPERATELY NEED IN ALL SITUATIONS and I don't want to argue
over keywords line impure and whatever __not(shared) would be
called etc.
const:
int b; // const
__not(const)(int) a; // not const
immutable:
int c; // immutable int
__not(const)(int) a; // still immutable int; there was no
const set to turn off.
Makes the code unreadable. You have to count all attributes in
the file, then negate them. Nobody should write like this and
therefore it is good, that there isn't something like __not.
For @nogc, pure and so forth there were imho a better proposal
with a boolean value:
@gc(true), @gc(false), pure(true), pure(false) etc. It is also
consistent with the existing UDA syntax.