Custom Blocks
Stanislav Blinov
blinov at loniir.ru
Tue Aug 10 02:35:46 PDT 2010
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();
}
}
--
**
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100810/ffb435c7/attachment.html>
More information about the Digitalmars-d
mailing list