non-lambda overloads for lambda-only things
Paul Backus
snarwin at gmail.com
Fri Apr 16 14:14:09 UTC 2021
On Friday, 16 April 2021 at 14:02:24 UTC, Steven Schveighoffer
wrote:
> On 4/16/21 7:23 AM, Jacob Carlborg wrote:
>> BTW, what's stopping us from supporting the above syntax? Why
>> do we still pass the lambda as a template argument? In that
>> past, before proper support for lambdas, there was a use case
>> to pass a string literal, which must be passed as a template
>> argument. If DMD cannot inline the lambda, who cares, use LDC
>> instead.
>>
>
> It could possibly work, if you specify the type. But I haven't
> thought about the ramifications. I want to avoid creating
> closures, and as you say, inlining might be affected.
You'd have to use `&` if you wanted to pass a named function
rather than a lambda (e.g., `map(&fun)`), and you wouldn't be
able to pass template functions (e.g., `map(&to!string)` would be
a compile-time error).
More information about the Digitalmars-d
mailing list