C++ Logo

liaison

Advanced search

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

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Tue, 10 Mar 2020 22:54:27 +0100
Martin,

on Tue, 10 Mar 2020 21:35:18 +0000 you ("Uecker, Martin"
<Martin.Uecker_at_[hidden]>) 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

Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

Received on 2020-03-10 16:57:16