Replies: 5 comments 1 reply
-
|
Possibly among other things, I think an environment is used for resolution of some names, e.g.: As for Lines 492 to 497 in 61769c8 |
Beta Was this translation helpful? Give feedback.
-
|
The current execution environment is realized by maintaining a series of simple tables, each of which links back to the previous environment in the stack as a table prototype. So when you evaluate any symbol, you’re essentially doing a
therefore, if you evaluate
The pretty printer avoids an infinite loop on displaying the table inside of itself with the cycle notation. |
Beta Was this translation helpful? Give feedback.
-
|
To demonstrate what I mean, here's an example of printing out the curenv without having bound |
Beta Was this translation helpful? Give feedback.
-
|
And to illustrate the (arguably more relevant) question of what environments are at all, you can evaluate |
Beta Was this translation helpful? Give feedback.
-
|
Thanks, @subsetpark ! It sounds like the primary purpose of the environment table is for looking up bindings. I realize that Janet of course does this automatically for us, but I see that it also provides some functions for inspecting and altering environments if we need to. It reminds me a little of environment variables in the shell (bash), since they (shell env vars) let us define names for the current shell. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What is the role played by an environment (the table returned by
(curenv))? What are they for in Janet?In:
what does
<cycle 0>mean?Beta Was this translation helpful? Give feedback.
All reactions