String lambdas

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 27 08:44:22 PDT 2016


On 4/27/16 8:31 AM, Andrei Alexandrescu wrote:
> On 04/26/2016 03:45 PM, Jack Stouffer wrote:
>> I think that the drawback you mentioned does not outweigh the benefits
>> gained from using actual lambdas.
>
> Actually it turns out to be a major usability issue. -- Andrei

Yes, consider that RedBlackTree!(int, (a, b) => a > b) is going to be a 
different type every time you use it, even if they are 1 line apart!

There are actually 2 things the string lambdas have going for them: 1) 
common instantiation for every usage, and 2) avoiding parentheses with 
instantiation (impossible to do with a short lambda syntax).

I'd still vote for them to go, but we MUST fix the issue with common 
instantiation first.

There has been some discussion in general of using hashing to decrease 
the symbol size for templates, and some discussion about allowing the 
compiler to merge identical binary functions to reduce the size of the 
binaries. Both of those could play in nicely here.

-Steve


More information about the Digitalmars-d mailing list