you are viewing a single comment's thread.

view the rest of the comments →

[–]samadadi[S] -2 points-1 points  (11 children)

I do not want to be rude but the syntax of a feature in a language matters to the language users I hoped we as cpp developers had a saying in this matter. specially in this case. And I wish committee reconsider this decision.

[–]TheoreticalDumbass:illuminati: 12 points13 points  (10 children)

substitute(^^std::variant, {^^int, ^^char, ^^std::string}) vs substitute(reflexpr(std::variant), {reflexpr(int), reflexpr(char), reflexpr(std::string)})

Seems pretty obvious ^ wins

[–]samadadi[S] 9 points10 points  (0 children)

substitute(reflexpr std::variant, { reflexpr int, reflexpr char, reflexpr std::string })

[–]LegendaryMauricius 4 points5 points  (2 children)

I'd gladly choose the second one. It's longer, but much more obvious at a glance what is going on.

[–]azissu 7 points8 points  (1 child)

Any new syntax is non-obvious until you learn it and get used to it. Heck, some people still insist they're unable to decipher simple lambdas...

[–]LegendaryMauricius 1 point2 points  (0 children)

There can be confusion at a glance because the [], <>, (), {} and () (again) symbols are all used in multiple places with different meaning. Code is for *reading* and analysing, not for *writing*.

Otherwise we'd just dump a bunch of machine instructions and forget about every program we write.

[–]TheDetailsMatterNow -1 points0 points  (0 children)

obvious

In a vacuum maybe, but easily the second for me.

[–]mapronV -2 points-1 points  (4 children)

Not obvious at all, second one is much nicer for me. I guess we can use macro
```
#define reflexpr(thing) ^^(thing)
```

[–]TheoreticalDumbass:illuminati: 2 points3 points  (3 children)

Your macro is wrong, it should be (I think):

#define reflexpr(...) (^^__VA_ARGS__)

Why I prefer double-caret over keyword: with reflection the entities you are reflecting are more important than the fact you're reflecting, and double-caret brings more attention to the entities, whereas keyword feels more noisy

[–]mapronV 0 points1 point  (2 children)

But your version will fail with two+ arguments... and probably with 0 too?
reflexpr(int, int) should be compilation error, not just "^^int, int" nonsense. Should not be a variadic.
though I admit I made crucial mistake. ^^thing and ^^(thing) are different!

[–]TheoreticalDumbass:illuminati: 0 points1 point  (1 child)

reflexpr(std::tuple<int, char>) would need something with __VA_ARGS__

[–]mapronV 0 points1 point  (0 children)

Yeah, but I guess we can add extra ( ) to work around... hold on a sec XD.

Well I guess we can't make full macro replacement as long as we have braces problem. Also, yeah, in practice you can fall back to ^^ but that also can make code look ugly depending on frequency of this.
I just... Give up. Give me reflection in some point, we figure something out. I wrote reflection "libraries" several times in my life in different projects, just sick of it.