String lambdas

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 27 16:24:13 PDT 2016


On 4/27/16 1:04 PM, Andrei Alexandrescu wrote:
> On 04/27/2016 11:44 AM, Steven Schveighoffer wrote:
>> 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.
>
> Yes, you get it exactly right. I think a DIP would be warranted here to
> clarify how lambda equivalence is computed. Could you please draft one?

I started thinking about this, I'm probably not the best to do this by 
myself, as I'm not familiar with the compiler code. I'm thinking 
possibly we should talk about this next week in person?

BTW, one of the issues with the DIP system I see is that the table for 
DIPs is not auto-generated, so there is a stray dip which hasn't been 
finished and no entry in the table: http://wiki.dlang.org/DIP89

-Steve



More information about the Digitalmars-d mailing list