C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] a common C/C++ core specification

From: Uecker, Martin <Martin.Uecker_at_[hidden]>
Date: Tue, 10 Mar 2020 22:44:47 +0000
Am Dienstag, den 10.03.2020, 22:54 +0100 schrieb Jens Gustedt via Liaison:
> Martin,
>
> on Tue, 10 Mar 2020 21:35:18 +0000 you ("Uecker, Martin"
> <Martin.Uecker_at_[hidden].uni-goettingen.de>) wrote:
>
> > The most useful thing about lambda/nested function
> > is that you can capture a local variable and then
> > pass the lambda to another function. But exactly
> > this seems impossible using your proposed scheme.
> > If you capture a varable then the type depends
> > on the specifics of the captured variables and
> > you can not pass such lambdas to a common
> > interface anymore. Or am I missing something?
>
> I have the impression, yes, you are missing something.
>
> Lambda values can be passed around. Only their type cannot be
> declared, so the only way to pass them around is with `auto` variables
> and parameters (which you don't seem to want).
>
> This passing through `auto` has advantages:
>
> - the provenance of the context that is needed to call the "real"
> function underneath must always be visible, this helps a lot for
> optimization (all about the lambda expression can at least
> potentially be known at the point of the call)
>
> - since these auto parameters can only be done with lambdas (at
> least in my current proposal) implementations are free to choose
>     their way to implement this, no ABI change is needed

Essentially, these lambdas are only useful for compile time
computation.

Best,
Martin

Received on 2020-03-10 17:47:39