C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Simplified reflection with tuples

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Wed, 3 Jan 2024 10:25:47 -0500
On Tue, Jan 2, 2024 at 9:52 PM Franklin Yang via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Hello all,
>
> I am not sure if discussion about reflection is still in order. Regardless, I believe the usage is too complicated and the syntax somewhat messy.

There have been a lot of proposals for reflection. Are you
specifically talking about P2996? What about the proposal you're
talking about is "too complicated"? How is the "syntax somewhat
messy?"

Simply declaring something to be a problem isn't as convincing has
providing an argument showing how it is a problem.

> Instead of a dedicated language feature that creates yet another usage for `using`,

I've only skimmed P2996, but I don't see where they created "yet
another usage for `using`". So again, what proposal are you talking
about?

> I propose simply using the existing std::tuple type to hold member information. This not only reduces potential language clutter, but also provides programmers with a more familiar and “C++-like” interface to reflection.

... as opposed to what? And what does "C++-like" mean? If you use a
type's metadata to hold the information, you have to use template
metaprogramming techniques to access and manipulate it instead of
constexpr programming. I would consider the latter to be more
"C++-like" than the former.

> `reflexpr` will return a tuple containing `std::reflect::var`, `std::reflect::lambda`, `std::reflect::func`, `std::reflect::class`, among others, which represent objects. These “meta-types” will each contain their own specific members (e.g. `std::reflect::func` but not `std::reflect::var` may contain `get_parameters()`), and types for variables and classes could be provided through a type alias.

This sort of thing has been considered, and P2996 provides arguments
about why having a single reflection type is preferable. What do you
find unconvincing in those arguments?

> I do not see a need to alter the contents of the current reflection extensions, just how it is organized and presented. With my proposal, all existing meta-object operations shall simply be converted to members of the std::reflect types, except for those which are impractical.
>
>
>
> Any feedback or criticism is appreciated.
>
>
>
> Thanks,
>
> Franklin Yang
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-01-03 15:26:00