parameterized lazy expression

BCS ao at pathlink.com
Tue Oct 2 12:53:24 PDT 2007


Reply to freeagle,

> Hello,
> 
> is it possible somehow, to pass as a lazy argument expression with
> argument/s?
> 
> something like
> foo((int x) x == 0);
> where x will be passed as parameter to the exp inside the foo
> function:
> 
> void foo(lazy bool dg)
> {
> if(dg(10)) {...}
> }
> i'd like not to have to use foo(bool delegate(int x) {return x == 0})
> if possible
> 
> I hope i made myself clear, thanks for advices in advance :)
> 
> freeagle
> 

the best you can do would be use the short form of delegates

foo((int x) {return x == 0;})

it's 3 char's longer than what you asked for but.


OTOH could the syntax be changed so that a delegate uses a statement rather 
than a block?

foo(bool delegate(int) a, int b);

foo((int x) return x == 0;, 5)




More information about the Digitalmars-d-learn mailing list