__traits(compiles, ...) returns true for syntactic garbage and for semantically incorrect code

Pavel proger79 at gmail.com
Mon Dec 17 06:29:48 PST 2012


On Monday, 17 December 2012 at 14:18:25 UTC, David Nadlinger 
wrote:
> On Monday, 17 December 2012 at 14:15:42 UTC, Pavel wrote:
>> It seems to me handier to use it from templates manipulating 
>> code as strings than usage of __traits(compiles,...) directly.
>
> I'm not quite sure how this is nicer to use than »enum foo = 
> __traits(compiles, { mixin(bar); });«, but tastes differ…

Yup, it is only IMHO :) Useful for forgetful people as me: 
because without the utility template it is easy to forget to use 
'mixin' and to put the statements in the block.






More information about the Digitalmars-d mailing list