Optional tags and attributes

Stanislav Blinov stanislav.blinov at gmail.com
Fri Jan 17 16:57:26 PST 2014


On Saturday, 18 January 2014 at 00:42:35 UTC, Rikki Cattermole 
wrote:
> Perhaps using template if statements and pure functions. A 
> little like how I implemented some of Dvorm's[0] utility 
> functions. That way it can execute at compile time. You can 
> pass the type to it and check any method you would call if its 
> nothrow or not via traits.

Obviously I didn't explain myself clearly. I know how to 
determine if a function is nothrow or pure or @safe or anything 
else thanks to D's awesomeness :) But what I want is a way to 
*use* that knowledge when declaring my own functions. Or rather, 
tell the compiler "Wait, I really want this to be nothrow, but I 
don't know if that function will throw. Here's a check for you, 
please make me nothrow if it passes". After all, tags are not 
just for enforcing correctness at compile time, they can be used 
(once verified) for optimization too. So it'd be nice to find a 
way to provide all the nice info to the compiler whenever 
possible. It's not just about nothrow, but also pure, 
@safe/@system/@trusted, hell, even public/protected/private for 
that matter. :)

> That way you can have two declarations but with one being 
> opposite of the if.

...Or four in case I'd also want pure/not pure, or nine if I'd 
also want @safe/not @safe...


More information about the Digitalmars-d mailing list