Re: delegates, lambdas and functions pitfall

2016-09-05 Thread dom via Digitalmars-d-learn
On Monday, 5 September 2016 at 12:32:49 UTC, Lodovico Giaretta wrote: On Monday, 5 September 2016 at 12:15:35 UTC, dom wrote: [...] You misunderstood the error message and the lambda syntax (it also happened to me the first time). The grammar says that you can use one of these syntaxes:

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread dom via Digitalmars-d-learn
On Monday, 5 September 2016 at 12:30:37 UTC, Daniel Kozak wrote: Dne 5.9.2016 v 14:15 dom via Digitalmars-d-learn napsal(a): ... but what is the difference between a lambda (=>) and a functions/delegates? i think this is a major pitfall for newcomers, and should be adressed somehow. Yes,

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread Lodovico Giaretta via Digitalmars-d-learn
On Monday, 5 September 2016 at 12:15:35 UTC, dom wrote: [...] You misunderstood the error message and the lambda syntax (it also happened to me the first time). The grammar says that you can use one of these syntaxes: 1) `(arguments) {block of code}` 2) `(arguments) => expression`, which

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
Dne 5.9.2016 v 14:30 Daniel Kozak napsal(a): Dne 5.9.2016 v 14:15 dom via Digitalmars-d-learn napsal(a): ... but what is the difference between a lambda (=>) and a functions/delegates? i think this is a major pitfall for newcomers, and should be adressed somehow. Yes, RTFM :) But to be

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
Dne 5.9.2016 v 14:15 dom via Digitalmars-d-learn napsal(a): ... but what is the difference between a lambda (=>) and a functions/delegates? i think this is a major pitfall for newcomers, and should be adressed somehow. Yes, RTFM :)

Re: delegates, lambdas and functions pitfall

2016-09-05 Thread Daniel Kozak via Digitalmars-d-learn
Dne 5.9.2016 v 14:15 dom via Digitalmars-d-learn napsal(a): I am about to write my own stupid and simple http client .. and i have added a callback function that has the received content as a parameter. class AsyncHttpGet { this(string host, ushort port, string path, void delegate(string)

delegates, lambdas and functions pitfall

2016-09-05 Thread dom via Digitalmars-d-learn
I am about to write my own stupid and simple http client .. and i have added a callback function that has the received content as a parameter. class AsyncHttpGet { this(string host, ushort port, string path, void delegate(string) callback ) { ... } } My first attempt was to write: