In discussions on X and in telegram, it became apparent that some people have reservations about the “code that writes code” aspect of the current CHIP-2025-05 Functions: Function Definition and Invocation Operations proposal.
I am thus amending Jason’s proposal, and submitting it as a set of two different mutually-exclusive proposals:
-
CHIP-2025-08 Functions Take 2 - This proposal introduces a new flag,
fCanDefineFunctionswhich is set totrueinitially and allows forOP_DEFINEto work. It gets set to false if opcodes that do anything other than push data items are encountered. Thus “code that writes code” is prevented by basically only allowingOP_DEFINEto work before any stack data item manipulations can occur. -
CHIP-2025-08.3 Functions Take 3 - This proposal which originally was an idea from @bitcoincashautist , introduces an “executable bit” to stack data items that essentially accomplishes the same thing by tracking stack data item provenance (only directly-pushed items or their copies can become function code for
OP_DEFINE).
The difference between the two proposals is that the “Take 3” one from @bitcoincashautist is a bit less restrictive than the “Take 2” one that I came up with. In the “Take 3” one, it’s possible for OP_INVOKE'd functions to also do OP_DEFINE and create new functions (which may or may not be what we want?).
I actually prefer the original proposal from Jason Dreyzehner.
If we can’t do that, then I prefer my proposal, only because implementation-wise on BCHN, @bitcoincashautist 's “Take 3” proposal would be a bit more invasive to the current code (only ever-so-slightly).
Let me know what you guys think!
