[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EIEIO and CL
Eric M. Ludlam
Re: EIEIO and CL
Fri, 09 Oct 2009 16:05:40 -0400
On Fri, 2009-10-09 at 12:51 -0400, Chong Yidong wrote:
> Currently, the EIEIO library requires CL at runtime. This is mainly due
> to needing `deftype' and `typep' (EIEIO implements a subset of the CLOS
> spec, which demand their existence). If possible, it would be nice to
> reduce this to a compile-time dependency, so that loading Semantic or
> EDE does not load the CL library.
> The `typep' requirement is solvable; the `deftype' requirement is the
> more interesting. Currently, eieio-defclass contains this code:
> ;; When using typep, (typep OBJ 'myclass) returns t for objects which
> ;; are subclasses of myclass. For our predicates, however, it is
> ;; important for EIEIO to be backwards compatible, where
> ;; myobject-p, and myobject-child-p are different.
> ;; "cl" uses this technique to specify symbols with specific typep
> ;; test, so we can let typep have the CLOS documented behavior
> ;; while keeping our above predicate clean.
> (eval `(deftype ,cname ()
> ,(intern (concat (symbol-name cname) "-child-p")))))
> The problem here is that the `cname' argument to the deftype CL macro
> is, in general, determined at run-time.
> Another possibility is to change eieio-defclass so that it defers this
> deftype form till CL is loaded, by putting it on cl-macs-load-hook.
> This assumes that the deftype is only useful if some later code calls
> typep or typecase; if this assumption is wrong, that could lead to
> subtle bugs.
> Or, there may be a way to change `deftype' (or to provide a different CL
> macro) that can do the right thing at compile-time.
> Any suggestions?
The defclass operation in EIEIO is a macro that calls out to a helper
function. This is because I have found that I'm just not that good at
writing macros. I would guess that if the entirety of eieio-defclass
were turned into a macro, then the whole eval thing you quoted above
would become a compile time requirement only. Would it then be a
requirement during compilation of code that uses defclass, as opposed to
a compile time requirement of eieio.el?
Alternately, it would be cool if typep, or something similar was a part
of Emacs core. Wouldn't the widget/custom setup like that?
- EIEIO and CL, Chong Yidong, 2009/10/09
- Re: EIEIO and CL,
Eric M. Ludlam <=