Proposal: __not(keyword)

Steven Schveighoffer schveiguy at gmail.com
Sat Sep 15 19:43:45 UTC 2018


On 9/14/18 11:06 AM, Adam D. Ruppe wrote:

> 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
> }

Aside from Jonathan's point, which I agree with, that the cost(bool) 
mechanism would be preferable in generic code (think not just negating 
existing attributes, but determining how to forward them), the above is 
different then just negation.

Making something unshared *inside* something that is shared breaks 
transitivity, and IMO the above simply would be the same as not having 
any attribute there.

In other words, I would expect:

shared foo f;

static assert(is(typeof(f.b)) == shared(int));

I'm not sure how the current behavior works, but definitely wanted to 
clarify that we can't change something like that without a major 
language upheaval.

-Steve


More information about the Digitalmars-d mailing list