Dynamic method example in TDPL

Philippe Sigaud philippe.sigaud at gmail.com
Wed Sep 1 13:25:42 PDT 2010


On Wed, Sep 1, 2010 at 01:24, Joel Christensen <joelcnz at gmail.com> wrote:

> Thanks for the fix up Philippe.
>
> Just a little note. Where it says 'DynMethod m', you can put 'auto m', but
> I'm wondering is it some times clearer to have the class name even though
> 'auto' works.
>

It depends on what you prefer. auto adds flexibility: if you use auto a lot,
you can change the 'typed' parts of your code and the parts with auto will
likely stay the same, propagating the change without hiccup, which is well
and good. But you also loose sight of what the 'current' type is. The
compiler knows it perfectly well, though, and you can count on static typing
to help you when it can.

Personally, I'm a bit leery of using auto in complex, recursive, templated
code: not so long ago, auto regularly created nasty forward declaration
errors. I think some were squashed recently, but I'm still testing the water
here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100901/766663b0/attachment.html>


More information about the Digitalmars-d-learn mailing list