mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
Merge branch 'master' into preludes-and-subclassing
This commit is contained in:
commit
b3827b041a
@ -365,15 +365,20 @@ instance Evaluatable Namespace where
|
||||
where
|
||||
names = freeVariables (subterm namespaceName)
|
||||
go [] = fail "expected at least one free variable in namespaceName, found none"
|
||||
-- The last name creates a closure over the namespace body.
|
||||
go [name] = letrec' name $ \addr ->
|
||||
subtermValue namespaceBody *> makeNamespace name addr
|
||||
-- Each namespace name creates a closure over the subsequent namespace closures
|
||||
go (name:xs) = letrec' name $ \addr ->
|
||||
go xs <* makeNamespace name addr
|
||||
|
||||
-- Make a namespace closure capturing the current environment.
|
||||
makeNamespace name addr = do
|
||||
namespaceEnv <- Env.head <$> getEnv
|
||||
v <- namespace name namespaceEnv
|
||||
v <$ assign addr v
|
||||
|
||||
-- Lookup/alloc a name passing the address to a body evaluated in a new local environment.
|
||||
letrec' name body = do
|
||||
addr <- lookupOrAlloc name
|
||||
v <- localEnv id (body addr)
|
||||
|
Loading…
Reference in New Issue
Block a user