C++ Logo

sg7

Advanced search

Re: Scalable reflection - questions / comments

From: Matus Chochlik <chochlik_at_[hidden]>
Date: Tue, 1 Feb 2022 18:30:37 +0100
On Tue, Feb 1, 2022 at 6:20 PM Peter Dimov <pdimov_at_[hidden]> wrote:

> Matus Chochlik wrote:
> > On Tue, Feb 1, 2022 at 6:01 PM Peter Dimov <pdimov_at_[hidden]
> > <mailto:pdimov_at_[hidden]> > wrote:
> >
> >
> > Matus Chochlik wrote:
> > > template <std::meta::info mo> auto baz() {
> > > return do_something([: mo :]);
> > > }
> > >
> > > template <std::meta::info mo> auto bar(auto arg1, auto arg2) {
> > > return bar<transform1<transform2<mo>(arg2)>(arg1)>();
> > > }
> >
> > I suppose P1240 is betting that it would be possible to still do
> >
> > template <std::meta::info mo> auto bar(auto arg1, auto arg2) {
> > return baz<transform1(transform2(mo, arg2), arg1)>();
> > }
> >
> > with transform1 and transform2 being consteval.
> >
> >
> >
> > My concern is not that this would not be doable, more like that it's
> *ugly* :)
>
> Aesthetics aside, I understand how the hypothetical consteval-only-meta
> world looks in principle, but my concern is that everything needs to buy
> into
> it for it to work well.
>

Code readability (and aesthetics) is very important. I think that we'd get
more "nice mentions" on stackoverflow/twitter about horrible syntax (which
this will lead to in most non-trivial use-cases) than about the fact that a
program compiles a couple of hundred milliseconds faster or slower :)


>
> We have tons of already existing is_foo_v<T> / concept foo<T> primitives,
> and unless we rewrite all of them as consteval is_foo(info) functions,
> we'll
> need an instantiation context in order to use them.
>

Agreed.

>
> So half of our functions will take the meta::info as a normal parameter,
> and
> half as a template parameter, for no legitimate reason other than
> implementation details.
>

This I want to avoid and I know for a fact that reflection code that is
readable and is not having terrible compile-times is possible.

Received on 2022-02-01 17:30:48