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

patches to typep???

I am developing a database application which requires the ability to define
new data types and do a lot of type checking of pieces of data.  I would like
to be able to use (typep obj 'newtype) with new types I have defined such as 
new array and structure types.  Specifically if I type:

(deftype fvec3 () '(array float (3)))
(deftype ivec3 () '(array integer (3)))
(defvar *v3*)
(setf *v3* (make-array '(3) :element-type 'float :initial-element 0.0))
(typep *v3* 'fvec3)
(typep *v3* 'ivec3)

I would like the last two forms to return T and NIL respectively .They both 
return NIL.  Actually as I (and the Lisp gurus here) read Steele (p. 45) it 
appears to be implementation dependent whether T or NIL is returned for the
2nd to last form.

If obj is an array and newtype is an array type specifier and their
dimensions agree I would like (typep obj 'newtype) to check the types of the

Can anyone give me advise as to what modifications to typep would be required
to achieve this or if someone somewhere has done this already and I could get
ahold of their code.

Similarly for structures if I type:

(defstruct newstruct (a 0.0 :type 'float))
(defvar *s1*)
(setf *s1* (make-newstruct))
(typep *s1* 'newstruct)  =====> returns T

which is what I want, but then I can assign an object of some other type to 
slot a of *s1* and it still returns T:

(setf (newstruct-a *s1*) 'red)
(typep *s1* 'newstruct)  =====> returns T

I would like (typep ) to check the contents of the slots of structures as 

Any help on this subject will be welcome.
	Doug Ruth [ruth@sri-robotx.arpa]