C++ Logo

SG7

Advanced search

Subject: Re: [isocpp-ext] P2320: "The Syntax of Static Reflection" feedback request
From: David Vandevoorde (daveed_at_[hidden])
Date: 2021-04-07 13:42:51


> On Apr 7, 2021, at 10:15 AM, René Ferdinand Rivera Morell via Ext <ext_at_[hidden]> wrote:
>
> First, sorry for the late reply, I blame slow paper reading :-) Can someone clarify something that I must be missing about the proposed splice syntax. Is there rationale for why one needs any splice syntax at all given that the reflections are strongly typed? At a, probably very ignorant, high level it appears to me that you could just have the reflected names without the "[:R:]". What am I missing?

There are at least two reasons. First, in non-expression contexts it allows us to know that we should switch to an expression context. E.g.:

        struct D1
           : X::B { // Currently, “X::B” is assumed not to be an expression here.
           â€¦
        };

and the parallel:

        struct D2
           : [: X::R :] { // The operand of splicers are expressions. So X::R can be assumed to be an expression.
          â€¦
        };

Second, reflection-expression vs. spliced-expression disambiguation. Consider:

        consteval info f() { … }
        constexpr auto r1 = f();
        constexpr auto f2 = [: f() :];

Suppose f() returns a reflection of an expression. Clear r1 and r2 mean different things and one shouldn’t be assumed to be equivalent to the other (r1 is initialized with the expression reflection itself; r2 is initialized with the expression reflected by that expression reflection (which itself may or may not be an expression reflection, or some other reflection, etc.).

        Daveed


SG7 list run by sg7-owner@lists.isocpp.org

Older Archives on Google Groups