unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* `eval'ing form in the current lexical environment
@ 2024-07-07 18:55 Thuna
  2024-07-07 19:16 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 7+ messages in thread
From: Thuna @ 2024-07-07 18:55 UTC (permalink / raw)
  To: help-gnu-emacs

How would I `eval' a form as though it were where the `(eval ...)' form
was?  That is, is there an argument to LEXICAL I can pass such that
  (... (eval form LEXICAL) ...)
becomes identical to
  (... <value-of-form> ...)

Let me state my problem as well, in case anyone knows of a solution to
that: I have a macro which modifies the form fed to it, macroexpanding
it as necessary.  Functions are handled specifically, in that its
arguments are computed and the call to the function replaced by
  (func arg1 arg2...)
If, however, `func' is then redefined as a macro, and uses one of its
args without evaluating it, then this would understandably break.  At
the same time, the process the original form went through in my macro is
one that this now-macro form needs to go through as well, so I expand
into a form which *during evaluation* calls this process on the literal
form which is fed to it and evals it.  This all looks something like
  (defmacro (lambda-list head &rest args)
    `(defun ,lambda-list
       ...
       (if (macrop #',head)
           (eval (<processor> '(,head ,@args)))
         (,head ,@argsyms))))
and it is absolutely expected for the forms in ARGS to be aware of and
reference the variables established in LAMBDA-LIST, but because of the
above problem that is not the case (as far as I could tell).



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-07-08 22:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-07 18:55 `eval'ing form in the current lexical environment Thuna
2024-07-07 19:16 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-07-08  2:07   ` Thuna
2024-07-08  2:49     ` Stefan Monnier
2024-07-08 21:38       ` Thuna
2024-07-08 22:03         ` Stefan Monnier
2024-07-08 22:42           ` Thuna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).