C++ Logo

liaison

Advanced search

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

From: Jens Gustedt <jens.gustedt_at_[hidden]>
Date: Wed, 11 Mar 2020 08:19:44 +0100
Martin,

on Tue, 10 Mar 2020 22:44:47 +0000 you ("Uecker, Martin"
<Martin.Uecker_at_[hidden]>) wrote:

> 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]>) 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.

I have no idea how you come to that conclusion, but this is completely
wrong.

Lambda values contain all the frozen state from the point of the
evaluation of the lambda. So in the contrary they are extremely
usefull for any type of computation that has to do repeated operations
on some kind of frozen state.

But as JF said yesterday, this is the liaison mailing list, so we
probably should move this off-list. In any case, what you were
propagating/prefering was a C-only version, so it has no place here, I
think. The chances that C++ would adopt another local function model,
where they already have lambdas that do the job (and more) tends to
zero.

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-11 02:22:33