[Article Submission] Have Your Efficiency, and Flexibility Too

Nick Sabalausky a at a.a
Tue May 31 03:01:12 PDT 2011


"Lars T. Kyllingstad" <public at kyllingen.NOSPAMnet> wrote in message 
news:is2aah$29pf$1 at digitalmars.com...
> On Tue, 31 May 2011 02:36:58 -0400, Nick Sabalausky wrote:
>
>> Getting in just under the wire here. I seem to have misjudged the scope
>> of my topic, it ended up a bit large... Anyway, here's my entry:
>>
>> http://www.semitwist.com/articles/EfficientAndFlexible/SinglePage/
>
> Nice article. :)  Some of the code snippets were a bit on the longish
> side, but I can't really say how they could be reduced.  The narrative is
> a nice touch.
>

Thanks :)

> May I make two small suggestions regarding the ex5_meta_deadDuck1.d
> snippet?  Firstly, I cringe whenever I see is(typeof((){...})) being used
> to test whether something compiles or not.  I'd much prefer
>
>    immutable bool isIGizmo = __traits(compiles,
>    {
>        ...
>    });
>
> Granted, __traits() is pretty ugly too, but at least you have the
> "compiles" directive making it clear what's going on.
>
> Secondly, you could replace the immutable(void[0]) member with an enum,
> which also doesn't take up any space.  I find
>
>    enum _this_implements_interface_IGizmo_ = true;
>
> a lot more descriptive of its purpose.  Then you could also replace the
> "auto dummy = T._this_implements..." line with
>
>    static assert (T._this_implements_interface_IGizmo_);
>
> which will fail if _this_implements... isn't declared or if it's declared
> to be false.
>

All good points.






More information about the Digitalmars-d mailing list