On Tuesday, February 26, 2019 3:06:04 AM MST Simen Kjærås via Digitalmars-d- learn wrote: > On Monday, 25 February 2019 at 15:26:33 UTC, Jonathan M Davis > > wrote: > > On Monday, February 25, 2019 5:47:47 AM MST Simen Kjærås via > > > >> String functions can't access the local scope, and thus can't > >> see Dummy. Using lambdas works. (string functions were > >> basically a workaround for no decent lambda syntax back in the > >> time when dinosaurs roamed the earth) > > > > They're actually still useful in cases where you need to > > compare lambdas (since you can't compare actual lambdas, but > > you can compare strings), and in some cases, using a string > > lambda with a function that accepts it is less verbose than > > using a regular lambda, but in general, folks do tend to use > > regular lambdas now that we have the more concise lambda syntax > > - especially since string lambdas do have some annoying > > limitations like this. > > Lambdas can be compared, though: > > static assert(__traits(isSame, a => a, i => i)); > alias fn1 = a => a * 2; > alias fn2 = b => b * 2; > static assert(__traits(isSame, fn1, fn2)); > > There are limits, as specified on > https://dlang.org/spec/traits.html#isSame > > -- > Simen
Well, that must be a relatively recent addition. It certainly didn't used to exist. - Jonathan M Davis