Closed iacore closed 11 months ago
In the embedded example, it looks like (curenv)
and root-env
evaluate to the same value. hash
returns the same value for both and (= root-env (curenv))
returns true
too.
IIUC, that may contribute to the if
succeeding here (during marshalling):
...resulting in an early return and hence the buffer result of (make-image (curenv))
being @"\xD8\broot-env"
.
For the non-embedded cases, root-env
and (curenv)
evaluate to different tables and the if
does not appear to succeed.
Within boot.janet
/ the janet
executable, there often appears to be an environment constructed via make-env
involved in evaluating code (whereas that doesn't appear to be occurring in the embedded case here). Perhaps this is part why the behaviors differ.
So the correct usage should be setting the prototype of a new table as core_env, and use that as environment?
You are running the environment table return from janet_core_env(), which is the root environment.
Janet version: 1.30.0-bfb60fdb
When calling
(make-image (curenv))
when embedded, the output buffer is wrong.1. embedded in C
Output: (The output is wrong)
2. script
this is correct
Output:
3. REPL
This is also correct.