[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18494: 24.4.50; defclass creates undocumented *-list-p function

From: Eric Ludlam
Subject: bug#18494: 24.4.50; defclass creates undocumented *-list-p function
Date: Sat, 20 Sep 2014 15:53:58 -0400
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a1pre) Gecko/20091222 Shredder/3.1a1pre

 On 09/20/2014 06:41 AM, David Engster wrote:
[add CC Eric]

Tom Tromey writes:

(defclass zzz-whatever () ((hi)))

Now notice there is a new function:

(symbol-function 'zzz-whatever-list-p)
(lambda (obj) "Test OBJ to see if it a list of objects which are a child of type 
zzz-whatever" (when (listp obj) (let ((ans t)) (while (and obj ans) (setq ans (and 
(eieio-object-p (car obj)) (object-of-class-p (car obj) zzz-whatever))) (setq obj (cdr 
obj))) ans)))

This new -list-p function is not documented in the EIEIO manual.

It seems to me that it would be a bit better not to define it.
It doesn't seem generally useful enough, to me.
I agree it's not generally useful. It was added as a helper function to
validate a slot which should hold a list of objects (as part of the
EIEIO/EDE security fix for Emacs 23.4).

At least that's what I remember. I was under the impression that
eieio-persistent-validate/fix-slot-value would use this, but I cannot
see it; maybe it's just hidden very well. If it is not used, I'd agree
that it should better be removed or at least renamed to X--list-p.


I found that many of my programs that use EIEIO have slots that are of :type that is an object of some class, which is why there are base predicates. Thus, if I have some object class foo, I can set to the :type of some other class to foo, instead of some other more complex type. Having another predicate that also handles the list of objects that include subclasses is just handy.

David is right about the time when it was introduced, where only slots with a constrained :type for an object were allowed to be loaded in, allowing the loader to never 'eval anything, only read.

Technically, I could hand write a few of those predicates for the EDE loader, but I thought it would be generally useful, especially if other folk want to save their objects. I'm not sure how widely used it is outside of EDE, semanticdb, and cogre which all have save files. I certainly think it should be documented if consensus is that it stays. Perhaps an extra option for the defclass to add extra predicates along with :method-invocation-order.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]