Alternative to DIP1032

Steven Schveighoffer schveiguy at gmail.com
Fri Apr 3 17:38:14 UTC 2020


On 4/3/20 1:09 PM, jmh530 wrote:
> On Friday, 3 April 2020 at 15:47:19 UTC, Steven Schveighoffer wrote:
>> [snip]
> 
> Won't it be confusing to people that an attribute won't always mean what 
> it says?

Possibly. But the problem is that in order for this to work, everything 
*else* in the function must be compiled according to the stated 
attribute. It's just the delegate call that can trump the stated ones. 
So you can't just leave the attribute off.

The message for the failure also can be adjusted to be clearer. e.g.:

"Error calling `foo(someDelegate)` is not allowed in `@safe` function 
`bar`. `foo` is assumed `@system` due to delegate `someDelegate`."

Another mechanism would be to flag the tagged attributes as being 
"overridable" somehow by the delegate.

I think the concept is sound, but how to achieve, I don't really know 
the best way.

-Steve


More information about the Digitalmars-d mailing list