Recursive attribute for virtual functions?

arturg var.spool.mail700 at gmail.com
Tue Mar 27 23:48:15 UTC 2018


On Tuesday, 27 March 2018 at 23:34:20 UTC, arturg wrote:
> On Tuesday, 27 March 2018 at 23:23:38 UTC, ag0aep6g wrote:
>>
>> DMD might accept that, but I don't think it works in a 
>> meaningful way. How do you call the @system one?
>>
>> Looks like the @safe one will always be called, even from 
>> @system code:
>>
>> ----
>> import std.stdio;
>>
>> void talk() @system { writeln("@system"); }
>> void talk() @safe { writeln("@safe"); }
>>
>> void main() @system
>> {
>>     talk(); /* Prints "@safe". */
>> }
>> ----
>
> you can call them with __traits(getOverloads, T, "name")[index];
>
> you can overload on types attributes and linkage, but seems 
> like you can only merge overloads based on types.

i have some templates which can be used like this:

type.dgAt!("name", index);
dgAt!("name", index, somemodule);
dgAt!("name", index, "somemodule");
alias fun = aAt!("name", index, someTypeOrModule);

type.dgOf!("name", void function(int)@safe);
dgOf!("name", void function(int)@safe, module);
dgOf!("name", void function(int)@safe, "module");

from!(type, "name").aAt!1;
from!(type, "name").aOf!(void function(int));
from!(type, "name").dgAt!1;
from!(type, "name").dgOf!(void function(int));

but this fails:
type.dgOf!("name", extern(C) void function(int)@safe);

and this works:
alias funtype = extern(C) void function(int)@safe;
type.dgOf!("name", funtype);


More information about the Digitalmars-d mailing list