* what's the order of evaluation of forms in the top level body?
@ 2020-02-19 20:36 Marco Maggi
0 siblings, 0 replies; only message in thread
From: Marco Maggi @ 2020-02-19 20:36 UTC (permalink / raw)
To: help-gnu-emacs
Ciao,
I would like to keep my "bootstrap macros" local to a file; so, rather
that using DEFMACRO to build CL-DEFSTRUCT and similar forms, I tried to
use CL-MACROLET. The code looks like this:
(require 'cl-lib)
(defun debug-print (&rest args)
(pp args 'external-debugging-output))
(cl-macrolet ((defit (NAME) `(cl-defstruct ,NAME val)))
(defit one)
(defit two))
(cl-defgeneric doit (arg))
(defmacro defmeth (TYPE)
`(progn
(cl-defmethod doit ((arg ,TYPE))
arg)))
(defmeth one)
(defmeth two)
(debug-print (doit (make-one :val 1)))
(debug-print (doit (make-two :val 2)))
this works fine, no error. But I have a case, with more code involved,
when a macro use like "(defmeth one)" above fails with an error
equivalent to "undefined argument type: one". So far I failed to
reproduce this error with smaller code.
But I see that if I turn the CL-MACROLET into a DEFMACRO, as in:
(defmacro defit (NAME)
`(cl-defstruct ,NAME val))
(defit one)
(defit two)
no error is raised.
So I wonder: what's the order of evaluation of forms in the top level
body of an Emacs Lisp source file? Are there special cases? I was not
able to find relevant documentation in the elisp manual.
TIA
--
Marco Maggi
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-19 20:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-19 20:36 what's the order of evaluation of forms in the top level body? Marco Maggi
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).