You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The line (compile e #f e #f) in the internal parse-expression means that when we eval some code, it is compiled without a module, and only executed in the given module?
So if I try, for example, to create a macro define or set! in a module in order to shadow the original define or the original set!, then if I eval some code in the module, it won't see my new definition, right?
stklos> (define-module x (define-macro (set! . args) (error "no set!")))
;; x
stklos> (select-module x)
x> (set! a 1)
**** Error:
error: no set!
stklos> (eval '(set! a 1) (find-module 'x))
**** Error:
%execute: variable `a' unbound
stklos> (eval '(set!car print) (find-module 'x))
stklos> (select-module x)
x> car
#[closure print]
x> (select-module stklos)
stklos> car
#[closure print]
Ok - and if I import SCHEME into the module x I get an error when I try to set car, because SCHEME is immutable.
I tried to change eval (naively -- I'm not sure what I'm doing) and it didn't work:
(define (parse-expression e)
(compile e (or env (current-module)) e #f)
(emit 'END-OF-CODE)
(assemble (reverse! *code-instr*)))
But this won't compile. (I also tried (or env #f)...)
I was looking into this because I have implemented SRFI-172 (which restricts the use of eval, define and some other things), and it seems to work fine if I enter the module and use it on the repl (my macros correctly shadow define, set!, %%set and so on)...
But if I use eval, then the STklos bindings are usable again, probably because the code is compiled in an empty environment, so my macros aren't visible and won't shadow define, set!, etc.
Although I ws looking into this because of SRFI 172, maybe it has to do with #368 also (by setting the value of an automatically imported symbol from the STklos module, I actually change its value in the STklos module!)
The text was updated successfully, but these errors were encountered:
@egallesio ...
I was reading STklos'
eval
:The line
(compile e #f e #f)
in the internalparse-expression
means that when weeval
some code, it is compiled without a module, and only executed in the given module?So if I try, for example, to create a macro
define
orset!
in a module in order to shadow the originaldefine
or the originalset!
, then if Ieval
some code in the module, it won't see my new definition, right?Ok - and if I import
SCHEME
into the modulex
I get an error when I try to setcar
, becauseSCHEME
is immutable.I tried to change
eval
(naively -- I'm not sure what I'm doing) and it didn't work:But this won't compile. (I also tried
(or env #f)
...)I was looking into this because I have implemented SRFI-172 (which restricts the use of eval, define and some other things), and it seems to work fine if I enter the module and use it on the repl (my macros correctly shadow
define
,set!
,%%set
and so on)...But if I use
eval
, then the STklos bindings are usable again, probably because the code is compiled in an empty environment, so my macros aren't visible and won't shadowdefine
,set!
, etc.Although I ws looking into this because of SRFI 172, maybe it has to do with #368 also (by setting the value of an automatically imported symbol from the STklos module, I actually change its value in the STklos module!)
The text was updated successfully, but these errors were encountered: