Custom Blocks

Chris Williams aahz at seanet.com
Tue Aug 10 05:49:54 PDT 2010


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s
article
> FWIW we've been talking a long time ago about a simple lowering - if
the
> last argument to a function is a delegate, allow moving the
delegate's
> body outside of the function:
> fun(a, b, c) { body }
>   |
>   V
> fun((a, b, c) { body });

I suppose that any method which works is fine. The advantage with a
more preprocessor-like methodology is that it doesn't incur two
function calls. Shipping delegates around to functions is nice for
self-modifying code, but that's overkill for this sort of
functionality. It has a fairly clear use for making complex thread
synchronization look prettier, but if you're doing that sort of fancy
footwork to begin with, then speed is probably a driving motive (or
you're making code that's more complex than it needs to be. ;) )

But again, like I said, any method which works is probably fine. And
possibly DMD is good at inlining such things.

-Chris


More information about the Digitalmars-d mailing list