You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Token-based code injection does not solve metaprogramming problems. Consider a small class that wants to auto-generate accessors for its members:
structS2 {
int a, b, c;
constexpr {
for... (auto m : $S2.member_variables())
-> { intdeclname("get_" m.name())() const { return m.name(); } }
}
};
This results in an error claiming m is not found, which is not what we should expect.
As we expand the loop, we should expect to replace (by substitution) the m in the injection with each value of loop variable m in the expansion. This doesn't happen because we haven't done semantic analysis on the declaration in the injection statement. An we really don't want to try to make the substitution lexically because that can dramatically change the meaning of a fragment.
In short, we need to parse injected fragments and actually analyze them.
This is essentially the same as #22, except that it applies to any (potentially) bound identifier within the injection. That is, m in the injection statement should be bound, but isn't.
The text was updated successfully, but these errors were encountered:
Token-based code injection does not solve metaprogramming problems. Consider a small class that wants to auto-generate accessors for its members:
This results in an error claiming
m
is not found, which is not what we should expect.As we expand the loop, we should expect to replace (by substitution) the
m
in the injection with each value of loop variablem
in the expansion. This doesn't happen because we haven't done semantic analysis on the declaration in the injection statement. An we really don't want to try to make the substitution lexically because that can dramatically change the meaning of a fragment.In short, we need to parse injected fragments and actually analyze them.
This is essentially the same as #22, except that it applies to any (potentially) bound identifier within the injection. That is,
m
in the injection statement should be bound, but isn't.The text was updated successfully, but these errors were encountered: