On May 26, 2009, at 1:28 AM, Jose A. Ortega Ruiz wrote:
[...]
This would be hard. Maybe the Ikarus back end would have to restrict
these forms to expressions, and no set!s to library variables.
Sounds like a plan, yes.
Note that the restriction is not too bad since one can make "mutable"
variables that can be set!ed *and* exported *and* have the set!ed
values appear in all use sites. Just a little macro magic.
As an aside, is it possible to get at run time
a graph of library dependencies, so that if the user wants to redefine
one of them we can reload all affected ones?
Definitely.
One has also the notion of 'current module' in the REPL, which
complements nicely the above functionality: when you send an
expression
from a scheme buffer for evaluation, it gets evaluated in the
buffer's
module or, if no module (library) is associated with the buffer, in
the 'current module'.
Doable, modulo the restriction above.
Excellent. I wasn't sure it was possible, even in the restricted send.
Evaluating expressions in a library is doable without implementation
support if the user is willing to define a small macro in the library.
Ikarus would just make this automatic.
Example:
$ ikarus
Ikarus Scheme version 0.0.4-rc1+ (revision 1792, build 2009-05-26)
Copyright (c) 2006-2009 Abdulaziz Ghuloum
> (library (library-inspector)
(export define-here)
(import (rnrs))
(define-syntax define-here
(lambda (x)
(syntax-case x ()
[(_ here) (identifier? #'here)
#'(define-syntax here
(lambda (stx)
(syntax-case stx ()
[(_ expr)
(datum->syntax #'here
(syntax->datum #'expr))])))]))))
> (library (foo)
(export in-foo) ;;; a and b "private"
(import (rnrs) (library-inspector))
(define a 12)
(define-syntax b
(syntax-rules ()
[(_ x) (+ x a)]))
(define-here in-foo))
> (import (foo))
> (in-foo a)
12
> (in-foo (b 13))
25
- ge:macroexpand (FORM MODULE FULL?)
Expands the given FORM, recursively when FULL? is #t.
How is this used from Geiser?
You put your cursor inside the form you want to expand, press a key
combination, and a window pops up containing the expansion.
So, this is informational only (like you don't feed it back into the
system), right?
But I still don't understand something. Suppose you have
(library (foo)
(export)
(import (rnrs))
(define-syntax x
(syntax-rules ()
[(_) 12]))
(define (call x)
(x)))
^--- put cursor here
this should not expand to 12, right? Somehow, you need to say which
form you're interested in (this may be a direction list in the form
of cars and cdrs that I can traverse to reach the desired form).
Sounds like fun, but we should probably save it to the last. :-)
Aziz,,,