This seems like a simple question; perhaps it is so simple that it is difficult to find a search that will find the answer. In Scheme (specifically, the Guile implementation if that makes any difference) how do I evaluate something that has been quoted?
Here's what I'm trying to do.
I basically need to ensure that a function I define gets its arguments evaluated in a specific order, because side effects caused by evaluating one argument are depended on during the evaluation of other arguments. However, Scheme says arguments can be evaluated in any order, so I want to manually force it by quoting the arguments and then manually evaluating them in the order that is needed.
It appears that "eval" is supposed to do what I want, but it has two problems:
- Its use is discouraged, so I feel like there should be a better way to accomplish what I want to do here.
- In Scheme it appears that eval takes a second parameter which is the environment. This is confusing to me. I want it to eval in the same environment the statement appears in, so why I should need a second parameter? Is this even possible? I've played with eval a bit and it appears that some implementations requires different parameters (e.g. mit-scheme doesn't even know what (interaction-environment) is!!!)
I've tried other tricks, like building up a lambda:
(list 'lambda '() '(car (b c)))
but it appears that this would then have to be evaluated to generate a procedure. I also tried:
(list lambda '() '(car (b c)))
but this returns a "primitive-builtin-macro" which doesn't work either.
Edit: Looks like a macro will work for controlling order of evaluation: (defmacro test1 (a b) `(begin ,b ,a))