Closed zenon closed 4 years ago
Uhm... yes, I'd have to explain it better and actually check that everything works really... some of the stuff is there since the time dictionaries where a particular type of quotations...
That example is a way to essentially change the execution scope of a quotation: in that case I need to run import at ROOT level to import the modules so that they are available everywhere.
I found the example code in the prelude file, and think I now understand it better. We need the which because we have a quotation, i.e. a local scope, but want to import into ROOT scope. Some sample code:
; this defines a new module, without importing it yet {1 :uno 2 :due} +it
; let there be a test whether the symbol due is imported into ROOT. (ROOT 'due dhas?) :check
; After executing i1, check will give false, i.e. not imported into ROOT ; because the import is done inside of a local scope ('it import) :i1
; After i2, check will give true, i.e. now imported into ROOT. (('it import) ROOT with) :i2
; HOWEVER, after executing the below two lines, emp is still empty. ; So, I still miss something.
{} +emp ('it import) emp with
Additional question: Do I have any way to access the current scope? The function symbols acts on ROOT, scope-symbols on a dictionary. But I cannot interact with my current scope when, say, inside of a quotation.
Note: In "3.2.1 Quoting, dequoting, and applying", it reads "Essentially, this executes the quotation in the current context". I assume that context is the same as scope, right? (If right, I suggest to call it scope.)
The documentation has:
ROOT Returns an empty quotation holding a reference to the ROOT scope. z: What? How can something empty hold a reference? I see a dictionary.
Question: In the examples I've seen until now there is always only one scope, and it is called ROOT. If there are more, it would be nice to explain their logic, and ways to access them.
related?:
with Applies quotation quot1 within the scope of quot2. z: I may completely out of grasp here. I assumed that the second argument has to be a dictionary. (First because I don't understand how a quote can have a scope, second because ROOT looks like a dictionary.) So I tried
I'm surprised that it isn't executed. Maybe I have a wrong interpretation of the word "apply"?
The example for with uses ROOT, and changes ROOT. This makes it a bit confusing, as in general the environment is only used, not changed; as seen in the following example (Again, assuming that I at least remotely understand what I'm doing here ..)