Open axch opened 8 years ago
Given that eval
doesn't report errors all that well anyway (#562), option 2 above looks like the way to go.
This definition of eval
will be difficult to port to Puma, because the latter would need to either replicate or call out to the macro expander, which is written in Python. I am inclined to just break Puma's eval
, possibly renaming it to eval_no_macros
or something (and possibly also renaming the eval
currently in Lite to the same, to retain compatibility in the Puma->Lite direction).
Alternative: Provide smart expression constructors that do the macro expansion themselves as the expression is built. In other words, instead of writing (list 'if p c a)
and relying on eval
to expand the macros, write (if_form p c a)
and rely on if_form
to produce an output in the detailed syntax eval
will understand.
It might even be possible to write a version of quasiquote
that will do that conversion, so that (quasiquote (if (foo? ,p) (,c bar) ,a))
would expand into (if_form (app_form (ref_form 'foo?) p) (app_form c (ref_form 'bar)) a)
.
In order to do so, it must expand macros in its argument, which causes trouble because macro expansion is currently associated with
Status quo is that
eval
evaluates the post-macro-expansion language, which is pretty annoying when trying to write program-generating programs as @luac is doing for the inverse compilation paper.Status quo is somewhat papered over by the fact that
quote
does not suppress macro expansion (thoughquasiquote
effectively does #76), so(eval (quote .....))
looks reasonable, but this is not really a solution.Independently, after fixing this and making
quote
suppress macro expansion the way it should (which may fix #295 also), if it turns out that we actually want the current behavior ofquote
, we can give that thing another name.Options:
_compute_inference_prelude
does and break error reporting inside expressions passed toeval
(which may not be so terrible because they are presumably programmatically constructed anyway)VentureSIVM
intoeval