Re: Lazy evaluation of function pointers.

2016-04-10 Thread Ryan Frame via Digitalmars-d-learn
On Sunday, 10 April 2016 at 19:02:06 UTC, Alex Parrill wrote: A parameter declared as `lazy T` has the type `T delegate()`, which, when called, evaluates the expression that was passed into the function. So effectively, this: void foo(lazy int x) { auto i = x(); } foo(a+b); Is the same as

Re: Lazy evaluation of function pointers.

2016-04-10 Thread Alex Parrill via Digitalmars-d-learn
On Sunday, 10 April 2016 at 18:08:58 UTC, Ryan Frame wrote: Greetings. The following code works: void main() { passfunc(); } void passfunc(void function(string) f) { f("Hello"); } void func(string str) { import std.stdio : writeln; writeln(str); } Now if I change passfunc's

Lazy evaluation of function pointers.

2016-04-10 Thread Ryan Frame via Digitalmars-d-learn
Greetings. The following code works: void main() { passfunc(); } void passfunc(void function(string) f) { f("Hello"); } void func(string str) { import std.stdio : writeln; writeln(str); } Now if I change passfunc's signature to "void passfunc(lazy void function(string) f)" I