Future of string lambda functions/string predicate functions

Brian Rogoff brogoff at gmail.com
Wed Aug 14 13:11:09 PDT 2013


On Wednesday, 14 August 2013 at 19:24:43 UTC, w0rp wrote:
> As mentioned before, for very common lambdas that you don't 
> want to type yourself, you could define those functions as 
> generic functions with a given name, like a 'less' function.

Also as mentioned before, the issue is that (anonymous) lambda 
functions have some subtle issues in regards to templates, 
because lambda functions cannot be compared for equality (the 
problem in general is undecidable) while string lambdas can, even 
though they have the same problem as with some of the unwieldy 
attempts at comparison (AST comparison after normalization and 
renaming with De Bruijn indices, or whatever), namely that things 
that are obviously equal aren't seen as such. That's why you want 
to name functions, so that templates instantiated with the same 
function are interoperable.

It seems to me that the easiest solution for D would be to 
deprecate string lambdas, and declare that anonymous lambdas 
always compare to false. Is the workaround of naming lambdas 
being used in in separate template instantiations that need to 
work together so bad?




More information about the Digitalmars-d mailing list