[Openmcl-devel] Unknown Type Specifier and structs

Michael Maul mike.maul at gmail.com
Mon Jun 23 20:49:46 PDT 2014


Thanks for the illuminating and correct answer. 'eval-when'  fixed the
issue. The code is non-portablish it was coded for Allegro as a majority
platform and contained some SBCL support.


On Mon, Jun 23, 2014 at 9:35 PM, Gary Byers <gb at clozure.com> wrote:

> It's hard to say anything useful without knowing when the error occurs.
> Did it occur during compilation, after loading a compiled file, or
> at some other time ?
>
> From what I can tell, you're getting the error while trying to make
> a POINT structure whose OWNER slot is NIL but is declared to be a
> CLUSTER, and this happens in an environment in which the CLUSTER
> type isn't yet defined.  What do you think should happen in this
> case ?  What do you think after you read section 3.2.3.1.1 of CLHS ?
>
> If I'm guessing correctly about what's happening, then your code
> is wrong (or at least non-portable) in a couple of ways:
>
> You can more portably ensure that the type CLUSTER is defined
> later in the compilation process by surrounding the CLUSTER definition
> with EVAL-WHEN:
>
> (eval-when (:compile-toplevel :load-toplevel :execute)
>   (defstruct cluster ...))
>
> This would at least ensure that the type CLUSTER is defined when you
> try to try to make a POINT whose OWNER is NIL.  What happens when you
> do the latter (violate a type declaration) is undefined; I'm a little
> surprised if CCL would check that declaration if (SPEED 3) (SAFETY 1)
> is in effect, but I don't know if it indeed was in effect.
>
>
>
> On Mon, 23 Jun 2014, Michael Maul wrote:
>
>  Any ideas on the code below causing 'Unknown Type Specifier' condition.
>> Works fine on SBCL however CCL throws condition. I think it may relate to
>> the :type specification referencing cluster in the point struct
>> definition.
>> As if I eval just the cluster struct then reload the module the condition
>> is
>> not thown.
>>
>> Unknown type specifier: HJS.LEARN.K-MEANS:CLUSTER
>> ?? [Condition of type SIMPLE-ERROR]
>>
>>
>> Backtrace:
>> ? 0: (CCL::%%TYPEP NIL #<UNKNOWN-CTYPE HJS.LEARN.K-MEANS:CLUSTER>)
>> ? 1: (TYPEP NIL HJS.LEARN.K-MEANS:CLUSTER NIL)
>>
>>
>>
>> ;; Code Fragment
>> (declaim (optimize (speed 3) (debug 1) (safety 1)))
>> ;;;; data and type definition
>> (deftype id () 'fixnum)
>>
>>
>> (defstruct (cluster (:conc-name c-)
>> ???????????????????
>> ??????????????????? (:constructor %make-cluster (id center))
>> ???????????????????
>> ??????????????????? (:copier copy-cluster))
>> ? (id -1 :type id)
>> ? (center #.(make-dvec 0) :type dvec)
>> ? (old-center #.(make-dvec 0) :type dvec)
>> ? (size 0 :type fixnum)
>> ? (points nil :type list)
>> ? )
>>
>>
>> (defun make-cluster (id center)
>> ? (let ((center (coerce center 'dvec)))
>> ??? (check-type id id)
>> ??? (check-type center dvec)
>> ??? (let ((result (%make-cluster id (copy-seq center))))
>> ????? (setf (c-old-center result) (copy-seq center))
>> ????? result)))
>>
>>
>> (defstruct (point (:conc-name p-)
>> ????????????????? (:constructor %make-point (id pos))
>> ????????????????? (:copier copy-point))
>> ? (id -1 :type id)
>> ? (pos #.(make-dvec 0) :type dvec)
>> ? (owner nil :type cluster)?????????????????????????? ;
>> ? )
>> ...
>>
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20140623/bafd0e1a/attachment.htm>


More information about the Openmcl-devel mailing list