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

Implement namespaces #18

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Implement namespaces #18

wants to merge 7 commits into from

Conversation

lthibault
Copy link
Collaborator

@spy16 (cc @liefj)

This PR is a first attempt at implementing namespaces. I've only done cursory testing because I wanted to get feedback as early as possible.

The high-level strategy is for the NamespaceExpr to return a special error called NamespaceInterrupt, which contains a pointer to the new global namespace. The Evaluator catches NamespaceInterrupt and assigns the new env to itself.

On the env side of things, you will note significant changes to the core.Env interface. From a semantic perspective, one creates new interfaces using a persistent interface embodied by core.Env.WithNamespace. This has been implemented by splitting mapEnv into builtin.Env and builtin.childEnv. The builtin.Env type is responsible for managing namespaces, and children are bound to the namespace of their parents. Because the global scope of builtin.Env never changes, everything stays nice and consistent -- childEnvs will always see the same parent-namespace, even across NamespaceInterrupts.

Please let me know your thoughts! @spy16 If you feel this is mergeable, let me know, and I'll do so after writing a few more tests.

⏱️ Estimated review time: 1h.
❌ WIP. Do not merge.

@lthibault lthibault added the enhancement New feature or request label Mar 19, 2021
@lthibault lthibault added this to the v1.0 milestone Mar 19, 2021
@lthibault lthibault requested a review from spy16 March 19, 2021 20:47
@lthibault lthibault self-assigned this Mar 19, 2021
@lthibault lthibault marked this pull request as draft March 20, 2021 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant