nothrow function callbacks in extern(C) code - solution

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 19 15:36:53 PDT 2014


On 06/19/2014 10:29 PM, Dicebot wrote:
> +1
> I have always wondered why `inout` is limited to const when problem is
> almost identical with all other restrictive attributes.

I have furthermore always wondered why there can always only be one 
`inout' wildcard in scope. This is not the best existing way to solve 
this kind of problem: Parametric (i.e. not query-able at either runtime 
or compile time inside the function) compile-time arguments do it better.

I.e. instead of:

inout(int)[] foo(inout(int)[] arg){ return arg; }

do:

T foo![T <: const(int)[]](T arg){ return arg; }

this can be extended to other attributes, for example in the following 
way (this is just an example):

void evaluate![transitive_attributes a](void delegate()@a dg)@a{
     dg();
}


{void foo()@safe{}
evaluate(&foo);} // evaluate is @safe

{void foo()pure{}
evaluate(&foo);} // evaluate is pure

{void foo()pure @safe{}
evaluate(&foo); // evaluate is pure @safe
evaluate![pure](&foo);} // argument explicitly specified, @system pure


More information about the Digitalmars-d mailing list