Is there a way to call the expander?

Asked by Michael D. Adams

Is there a way to call the expander in ikarus? I'm unable to figure out how the "expand" function works especially with regard to it's environment argument.

Question information

Language:
English Edit question
Status:
Solved
For:
Ikarus Scheme Edit question
Assignee:
No assignee Edit question
Solved by:
Abdulaziz Ghuloum
Solved:
Last query:
Last reply:
Revision history for this message
Best Abdulaziz Ghuloum (aghuloum) said :
#1

The environment argument that expand takes is similar to the one that eval takes. It can be constructed with a call to the environment procedure. Here is an example:

> (print-gensym #f)
> (expand '(let f ((i 1000) (j 0)) (if (zero? i) j (f (- i 1) (+ j i))))
    (environment '(rnrs)))
(letrec ((f
          (case-lambda
            ((i j)
             (if ((primitive zero?) i)
                 j
                 (f ((primitive -) i '1) ((primitive +) j i)))))))
  (f '1000 '0))
()

Note that the output of expand is not valid scheme code. It's just some small core form that the compiler accepts. Also note that expand, just like eval, takes a single expression--definitions are not allowed.

Revision history for this message
Michael D. Adams (mdmkolbe) said :
#2

Thanks Abdulaziz Ghuloum, that solved my question.

Revision history for this message
Michael D. Adams (mdmkolbe) said :
#3

It wasn't clear from Aziz's example, but it appears that "environment" can take multiple arguments (e.g. (environment '(rnrs) '(ikarus))).

Revision history for this message
dsmith (dalepsmith) said :
#4

What is the proper environment argument to expand a macro I've just defined while talking to ikarus interactively? In other Schemes I would use something like (interaction-environment).

Thanks,
  -Dale

Revision history for this message
Abdulaziz Ghuloum (aghuloum) said :
#5

On Apr 3, 2008, at 1:26 PM, dsmith wrote:

> What is the proper environment argument to expand a macro I've just
> defined while talking to ikarus interactively? In other Schemes I
> would
> use something like (interaction-environment).

I don't think there is a way at the moment, sorry. This will be
fixed as part of the REPL reconstruction effort that I did not
undertake yet.