AaronBallman wrote:

> 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.

There's a part of me that wonders whether this should actually be part of the 
function interface (in a viral manner) so that the control is left to the 
interface designer. e.g., if you have a side effecting operation, the interface 
designer could have a way to say "side effects happen once regardless of how 
many calls to this function are made" or "these effects happen each time the 
call is made". (There could be a default behavior, I would learn towards "these 
effects happen each time the call is made".) This would allow for both 
idempotency and not, depending on the programmer's needs. The downside is, it's 
more complicated and viral annotations are sometimes not appreciated by 
everyone.

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