2008/8/1 Clinton Ebadi <[EMAIL PROTECTED]>:
>
> module-define! MODULE NAME VALUE
>
> e.g.
> (let ((foo 'bar))
>  (module-define! (current-module) foo 5)
>  bar)
> => 5
>
> Issue: this will be a top level binding, but a solution using `eval'
> would also produce a top level binding (as it executes there to allow
> lexical environments to be optimized...).

I've been trying to make it using local-eval to be able
to make a definition within a closure. There's only a
tiny problem: it's not working. When I execute:
(local-eval (list 'define a 5) (the-environment))
everything works fine, but when I make a function of it,
(define (define@ name value) (local-eval (list 'define name value)
(the-environment)))
and when I invoke it, it breaks with "Bad define placement".
The problem gets solved when I make a macro of it:
(define-macro (define@ name value) `(local-eval (list define ,name
,value)(the-environment)))
but it still breaks when called from a nested local-eval.

> Doing such things, however, is fairly unschemey.

What things and why?

What I'm trying to do is to understand the rules of making
and using environments. As for now, these rules seem to be quite
random and unpredictable (so it's rather hard to call them rules
actually), which is sad because closures are a very powerful
yet simple mechanism (definitely simpler than what GOOPS or
CLOS have to offer if it comes to OOP -- both in concepts and
implementation)

See you around :)
M.


Reply via email to