Date: Tue, 10 Mar 2020 20:59:58 +0100
on Tue, 10 Mar 2020 19:49:01 +0000 you ("Uecker, Martin via Liaison"
<liaison_at_[hidden]>) wrote:
> Am Dienstag, den 10.03.2020, 20:16 +0100 schrieb Florian Weimer via
> Liaison:
> > Do you think there is a mechanical way to capture types and values
> > so that each macro argument is expanded exactly once? Perhaps using
> > lambdas?
>
> You can do this today using popular extensions:
>
> #define FOO(x) ({ __auto_type __x = (x); _Generic(__x, ... ); })
Yes, with lambdas and "auto" we just would have a standardized version
of that as
#define FOO(x) [](auto __x){ return _Generic(__x, ... ); }(x)
which has several advantages: a clearly marked `return` statement and
encapsulation against inadvertedly reading state from the surrounding
code.
Thanks
Jens
<liaison_at_[hidden]>) wrote:
> Am Dienstag, den 10.03.2020, 20:16 +0100 schrieb Florian Weimer via
> Liaison:
> > Do you think there is a mechanical way to capture types and values
> > so that each macro argument is expanded exactly once? Perhaps using
> > lambdas?
>
> You can do this today using popular extensions:
>
> #define FOO(x) ({ __auto_type __x = (x); _Generic(__x, ... ); })
Yes, with lambdas and "auto" we just would have a standardized version
of that as
#define FOO(x) [](auto __x){ return _Generic(__x, ... ); }(x)
which has several advantages: a clearly marked `return` statement and
encapsulation against inadvertedly reading state from the surrounding
code.
Thanks
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 15:02:46