New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FUNC can not be HIJACKed #1012
Comments
It ideally wouldn't panic (it's a fairly experimental feature). But what would happen in this case won't be good--as hijacking functions in an incompatible way is fairly dangerous. You're saying everywhere in the system--the console included--is now going to be using your version of FUNC, which takes one argument and not two. (It probably should have stopped you from doing that, but the test for legal/illegal might be tricky e.g. with variadics). It also doesn't actually make an ACTION! and return it, so the console will crash and burn. Consider doing some harmless tracing, that doesn't sacrifice the original FUNC's purpose to the point of breaking the console:
From that, I get this before the next console prompt:
We've got some level of safety in the console due to modularization, but it only protects you against func: func [...] [...] without a HIJACK. That's because console keeps its own copy of the FUNC function pointer (inside a value cell in its module context). So reassigning it in the user context doesn't cause a problem. But when you change the pointed-to function behavior itself, the consequences will be felt by all references. It would be possible to force the console to COPY all the functions it uses (which is relatively cheap), but that would undermine HIJACK's desire to really deeply hook an implementation for all clients. It's meant to be a power tool that's used sparingly, likely as a stopgap for a better solution. |
This was just a minimal version, my original code is:
|
Interesting idea--glad you're getting adventurous with the features. Looking into it... |
Simpler example:
The FRAME! which is generated for the call to ENCLOSE is not changed by the HIJACK. It's still a frame for the original function. Hence what you get is morally equivalent to a recursion. But imagine if you had written the function without enclose:
Same problem. You're implementing PLUSONE in terms of IDENTITY. Then you're hijacking identity as implemented via PLUSONE. Solve via copying. In your case:
|
Example:
and in the webconsole I get the following in the log:
The text was updated successfully, but these errors were encountered: