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

Add support for "global contour" #34

Closed
kriskowal opened this issue Oct 28, 2020 · 1 comment
Closed

Add support for "global contour" #34

kriskowal opened this issue Oct 28, 2020 · 1 comment

Comments

@kriskowal
Copy link
Member

kriskowal commented Oct 28, 2020

The global contour is a scope that overshadows globalThis when evaluating “global code”. The global contour is the scope that persists variable declarations between calls to evaluate global code. Framed as a feature of compartments, we could add a “global” option to compartment.evaluate that signifies this evaluation mode and persists the global contour between calls.

compartment.evaluate("const example = 42;");
compartment.evaluate("example"); // 42
compartment.evaluate("const example = 101;"); // throws SyntaxError: Identifier 'example' has already been declared

Ideally, we could reconcile the global lexicals and global contour. However, evaluating global code should not be able to introduce variables that would overshadow globals in modules from the same compartment.

The global contour is a mutable property bag that must enforce rules for the order and behavior variable declarations.

The name “global contour” is reviled by all, but thankfully need not appear in code. Alternative suggestions are very welcome.

The global contour bears some similarity to global lexicals #35

@kriskowal
Copy link
Member Author

kriskowal commented Oct 28, 2020

Dup #33 on account of a Github form resubmission.

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

No branches or pull requests

1 participant