10.08.2010 9:19, Kagamin пишет:
Andrei Alexandrescu Wrote:
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 don't think, doOnce will work. Though, it's a useful idiom.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Filtered-With-Copfilter: Version 0.84beta4 (ProxSMTP 1.8)
Copfilter-Filtered-With: SpamAssassin 3.2.5
Copfilter-Virus-Scanned: ClamAV 0.94.2
by Markus Madlener @ http://www.copfilter.org
Maybe this one would:
block_template doOnce(string F = __FILE__, int L = __LINE__)() {
static bool hasRun = false;
if (!hasRun) {
hasRun = true;
$
}
}
or this one (with proposed lowering syntax):
void doOnce(string F = __FILE__, int L = __LINE__)(void delegate() dg)
{
static bool hasRun = false;
if (!hasRun) {
hasRun = true;
dg();
}
}
--
**