reddit - lazy evaluation of function arguments
Manfred_Nowak
svv1999 at hotmail.com
Tue Jul 1 01:01:05 PDT 2008
Georg Wrede wrote:
> (not too much reduction in code lines or complexity)
For me it is not a main goal to have few lines to read.
Often I found myself entangled in analyzing some code that turned out
to be of minor priority because it only guarded the main aspect of the
code from unusual cases. Putting those guards texually behind the main
aspect of the code seems canonical, because it supports my way of
turning to the main aspect first.
So I tried to use the deferring capability of lazy parameters for
annotating and beautifying this common pattern, but it turned out that
the extra three lines are still too distracting.
guarded( // the guards are actually evaluated here
{
writefln( "This is the guarded part of the code.");
writefln( "It is not executed if one of the boolean");
writefln( "guards encounters that its expression");
writefln( "evaluates to true.");
}
(), // list of guards:
guard( false, writefln( "this is the always failing guard.")),
guard( i==42, writefln( "this is a hitchhiking guard."))
);
-manfred
More information about the Digitalmars-d-announce
mailing list