zygoloid wrote:

> @zygoloid would it be correct to say that you want the Standard to leave 
> idempotency of functions with side effects up to implementations, and, 
> consequently, you want the model of how side effects are integrated into 
> constant evaluation to work for both idempotent and non-idempotent functions?

No, I think the standard should specify the exact semantics of its 
metaprogramming primitives. And for metaprogramming actions that generate code 
in particular, I think they should behave the same as the source code they are 
intended to be equivalent to -- and thus should produce redefinition errors as 
usual if the same definition is created more than once, regardless of whether 
one or both of the definitions came from a metaprogram. For other side effects, 
the rules for that primitive should specify what the behavior is -- and for 
example, whether we want some kind of deduplication or not.

Separately, I think if an interpreter wants to apply some level of idempotency 
to redefinitions that the standard says are invalid, in order to better support 
things like re-parsing the same code (but with, say, a function body changed), 
it should do so consistently across different kinds of entity and regardless of 
whether they come directly from parsing source code or from metaprogramming. 
But that's out of scope for current standardization efforts (one could imagine 
explicit support for REPL-style interpreters in the C++ standard, but we don't 
have any such thing right now).

https://github.com/llvm/llvm-project/pull/115168
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to