C++ Logo

sg7

Advanced search

Re: Update: P1240R2 — Scalable Reflection - Lifiting operator

From: Jonathan O'Connor <jonathan.oconnor_at_[hidden]>
Date: Mon, 31 Jan 2022 18:28:34 +0000
Daveed,
my brain works best when I see examples, but I appreciate that the paper could end up over 100 pages, if my wish was granted.

The lambda being included as a class is probably my misunderstanding of how lambdas are defined in the standard. As they are implemented as classes underneath, I thought they might be included as a class. Just so long as lambdas are liftable! Thanks for the confirmation.

Regards,
Jonathan

Sent with [ProtonMail](https://protonmail.com/) Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, January 31st, 2022 at 16:41, Daveed Vandevoorde <daveed_at_[hidden]> wrote:

>> On Jan 30, 2022, at 7:51 AM, Jonathan O'Connor via SG7 <sg7_at_[hidden]> wrote:
>>
>> Fellow elevator users,
>>
>> Page 5:
>>
>> In the discussion of `^f(x)` it is not clear if `f(x)` is evaluated.
>
> The sentence after the bullets describing what operands can be provided to the lifting operator says:
>
>> -
>
> -
>
> In the case where the name_or_postfix_expr is an expression, it is unevaluated but potentially constant evaluated.
>
>> -
>
>> From later discussion,
>> it would seem that it is evaluated if f(x) is constexpr. Presumably `^printf("hello")` is not evaluated.
>>
>> The final paragraph does not mention applying the lift operator to a lambda.
>
> I’m not sure which final paragraph you’re referring to?
>
> In C++ lambda-expressions are expressions, and a lambda-expression is a postfix-expression (via primary-expression). So, yes, you can reflect a lambda-expression.
>
> (We don’t list every possible expansion of the grammar for purposes of conciseness.)
>
>> Is
>> that possibility missing, or is it included as a class?
>
> I’m not sure what you mean by “is it included as a class?”. A lambda-expression is not a class, but it has class type. P1240 allows querying the type of an expression in general and so that includes lambda-expressions. So you can for example write:
>
> typename[: type_of(^[]{}) :] x;
>
> and that will produce a variable x of a closure type corresponding to that of the reflected lambda-expression.
>
>> Page 9: final code block:
>>
>> There should be a comment on `^printf("Hello, ")` stating the printf function is not invoked
>> before the lift operator.
>
> It seems a bit redundant, but sure, I can add that. (Done in my version now.)
>
> Daveed
>
>> Regards,
>> Jonathan
>>
>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>>
>> On Saturday, January 15th, 2022 at 17:41, Daveed Vandevoorde via SG7 <sg7_at_[hidden]> wrote:
>>
>>> SG7 mailing list
>>>
>>> SG7_at_[hidden]
>>>
>>> https://lists.isocpp.org/mailman/listinfo.cgi/sg7
>>
>> --
>> SG7 mailing list
>> SG7_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/sg7

Received on 2022-01-31 18:28:40