Skip to content
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

No way to define builtins used in host code in hosted code #126

Open
mattbierner opened this issue Sep 25, 2013 · 1 comment
Open

No way to define builtins used in host code in hosted code #126

mattbierner opened this issue Sep 25, 2013 · 1 comment

Comments

@mattbierner
Copy link
Owner

It is not currently possible to define a builtin in hosted code if this builtin must be called from host code. Part of the problem is that changes to the value in hosted code should not be reflected in the host reference.

This is currently not possible:

NativeError = function() {}
NativeError.prototype = new Error();

and then have the host code do something like:

 object.construct(native_error.NativeError, {});

because the value references will be different between the host and hosted.

Additionally some evil Javascripter could do:

NativeError = null;

And now host code that throws native errors stops functioning.

Some way to enable this would be nice.

@mattbierner
Copy link
Owner Author

One possible solution is to evaluate the hosted language builtin impls with a special set of exported functionality not available to running code.

 __set(NativeError, function() {});
 NativeError.prototype = new Error();

Where double underscore methods like __set are special internal operations. In this case, __set would change the actual underlying value reference of the environment instead of just changing the environment reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant