C++ Logo

sg7

Advanced search

Re: [SG7] Metaprogramming

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 24 Oct 2020 19:34:27 +0300
On Sat, 24 Oct 2020 at 19:17, David Rector via SG7 <sg7_at_[hidden]> wrote:
> # 3
> I think only strings should be injectible. Get rid of fragments — they are a source of needless complexity. IIUC, Andrew proposes the ability to inject arbitary code strings via `|# … #|` syntax. E.g. `consteval { |# "private: int i = 42;" #| }` would inject a private `i` into the enclosing class context (and result in a parse error if not in a class).

That doesn't seem to be correct. The paper says that a |# ... #| is an
identifier splice, not an arbitrary string.

I am under the impression that building injected code with just
strings or with just tokens is rather horrible
for implementations? For syntax validation and semantic analysis, most
likely. Token-soup-injection
as a possibility sure made our clang friends balk in Toronto.

Received on 2020-10-24 11:34:46