Abdulaziz Ghuloum <[email protected]> writes:
> 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.
Excellent.
>> 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.
That'd be nice to have; if you find the time to implement it in ikarus,
i'll definitely add that functionality to geiser.
[...]
> 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.
Well, that'd be awesome :)
[...]
>>>> - 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?
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. :-)
Right. In your example above, what Ikarus would see is a call like
(geiser:macroexpand '(define (call x) (x)) '(foo))
In other lisp modes for emacs, it's typical to provide an alternate
keybinding that, instead of the enclosing definition, sends the sexp
before point:
(define (call x)
(x) ))
^
In such a situation, the expected behaviour is to send to the inferior
scheme something like
(geiser:macroexpand '(x) '(foo))
*without the surrounding context*, so ikarus will answer as this were a
top level expression. As you rightly point out, this will actually be
the wrong answer, only that experienced emacs users won't be surprised
by that :) Of course, if we can implement the right thing, we would just
rock :)
jao
--
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"