Custom Blocks

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Aug 10 06:27:19 PDT 2010


Wow! That looks sweet. I Imagine this could be put to good use inside
template constraints.. or so I think.

Thumbs up from me.

On Tue, Aug 10, 2010 at 6:40 AM, dsimcha <dsimcha at yahoo.com> wrote:

> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s
> article
> > Chris Williams wrote:
> > > I'm not sure whether the design of D 2.0 has stabilized as yet, but if
> not,
> > > I would like to suggest the ability to create custom block types.
> > [snip]
> > 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 });
> > As far as Walter and I could tell, there are no syntactical issues
> > created by such a lowering. But we've been wrong about that in the past
> > (me 10x more often than him).
> > Andrei
>
> So this would basically allow the creation of custom flow control
> constructs at
> least to a limited extent?  For example:
>
> void unless(T)(T condition, void delegate() executeThis) {
>    if(!condition) executeThis();
> }
>
> void until(T)(T condition, void delegate() executeThis) {
>    while(!condition) executeThis();
> }
>
> void main() {
>    until(someoneKnowsWhetherPequalsNP() ) {
>        writeln("Who knows?");
>    }
>
>    unless(P == NP) {
>        writeln("P != NP");
>    }
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100810/4308e049/attachment.html>


More information about the Digitalmars-d mailing list