Review of std.signal

ilya-stromberg ilya-stromberg-2009 at yandex.ru
Sun Nov 10 04:01:07 PST 2013


On Sunday, 10 November 2013 at 11:32:45 UTC, Robert wrote:
> On Sunday, 10 November 2013 at 10:37:41 UTC, Jacob Carlborg 
> wrote:
>> On 2013-11-09 23:50, Robert wrote:
>> 1
>>> Nice. But you trade it for protection having a default value, 
>>> making the
>>> syntax more verbose in the general case.
>>
>> You can overload it:
>>
>> template signal (string name, Args...)
>>
>
> Smartass! ;-) Of course this would work, not bad! I am not sure 
> whether this additional wrapper it is worth its salt, but it is 
> definitely a nice alternative. I will absolutely think about 
> it. Thanks!

You can use this syntax:

template signal (ProtectionType protection = 
ProtectionType.private_, string name, Args...)
{
     mixin(signalImpl!(Args)(name, protection));
}

enum ProtectionType
{
     none,
     private_,
     //...
}

It combines both Jacob's suggestions.

Also, it looks like that you don't need `string mixin` at all. 
You can use `static if`.


More information about the Digitalmars-d mailing list