Contexts work a bit like environments - or, at least, they look and are meant for similar things. The current context can be gotten at any time from the var context.
Here are the properties contexts would have:
env or environment: Returns the environment living in the same place as the context.
args: Returns the arguments passed to the function. If the context is not inside a function, returns undefined (or whatever Tulun's equivalent is).
origin: Returns the context that created this context. If this is the top-level context, returns undefined (or whatever Tulun's equivalent is).
top: Returns the top-level context.
Possible uses:
Return value from parent function: context.origin.return("something").
Define globals from anywhere: context.top.var -> "something"
Get variables from anywhere: someContext.environment
etc.
I think they work great alongside environments. Maybe they're stupid and non-programming-like though. :P Discuss them.
(dis is suggestion btw)
Contexts work a bit like environments - or, at least, they look and are meant for similar things. The current context can be gotten at any time from the var
context
. Here are the properties contexts would have:env
orenvironment
: Returns the environment living in the same place as the context.args
: Returns the arguments passed to the function. If the context is not inside a function, returnsundefined
(or whatever Tulun's equivalent is).origin
: Returns the context that created this context. If this is the top-level context, returnsundefined
(or whatever Tulun's equivalent is).top
: Returns the top-level context.Possible uses: Return value from parent function:
context.origin.return("something")
. Define globals from anywhere:context.top.var -> "something"
Get variables from anywhere:someContext.environment
etc.I think they work great alongside environments. Maybe they're stupid and non-programming-like though. :P Discuss them.