Custom Search
|
Date: December 07, 2004
From: Christophe Rhodes <csr21@xxxxxxxxx>
In-reply-to:
<187DB748-48A2-11D9-9C9B-000A95A6A95C@xxxxxxx> (Raffael Cavallaro's message of "Tue, 7 Dec 2004 17:48:21 -0500")
References:
<187DB748-48A2-11D9-9C9B-000A95A6A95C@xxxxxxx>
Raffael Cavallaro <raffaelcavallaro@xxxxxxx> writes:
> * (defstruct (v3 (:type (vector double-float 3)))
> x y z)
>
> Is this a valid type specifier for defstruct?
Good question.
CLtS on DEFSTRUCT is confused. In the "Arguments and Values" section,
it specifies that the type-option is of the form (:type foo), where
foo is
one of the type specifiers list, vector, or (vector size), or some
other type specifier defined by the implementation to be
appropriate.
In the main body ("Description") section, however, it states that the
:type should be
vector
This produces the same result as specifying (vector t). The
structure is represented as a general vector, storing
components as vector elements. The first component is vector
element 1 if the structure is :named, and element 0 otherwise.
(vector element-type)
The structure is represented as a (possibly specialized)
vector, storing components as vector elements. Every component
must be of a type that can be stored in a vector of the type
specified. The first component is vector element 1 if the
structure is :named, and element 0 otherwise. The structure
can be :named only if the type symbol is a subtype of the
supplied element-type.
list
The structure is represented as a list. The first component is
the cadr if the structure is :named, and the car if it is not
:named.
I believe that it's fairly clear that the "Arguments and Values"
section is in error here, and that the only valid syntax for compound
vector types is (vector element-type) -- in this case, (vector
double-float) -- and that (vector double-float 3) is non-conforming
syntax. Whether CLISP and LispWorks are non-conforming in not
signalling an error is not clear.
Cheers,
Christophe
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
Date: December 07, 2004
From: Marco Antoniotti <marcoxa@xxxxxxxxxx>
In-reply-to:
<187DB748-48A2-11D9-9C9B-000A95A6A95C@xxxxxxx>
References:
<187DB748-48A2-11D9-9C9B-000A95A6A95C@xxxxxxx>
My reading of the CLHS tells me that
(defstruct (foo (:type (vector double-float))) x y z)
is ok. But
(defstruct (foo (:type (vector double-float 3))) x y z)
may not.
Cheers
Marco
On Dec 7, 2004, at 5:48 PM, Raffael Cavallaro wrote:
In OpenMCL: ? (defstruct (v3 (:type (vector double-float 3))) x y z)> Error in process listener(1): Bad defstruct option (:TYPE (VECTOR DOUBLE-FLOAT 3)).> While executing: DEFSTRUCT > Type :POP to abort. Type :? for other options. In sbcl: * (defstruct (v3 (:type (vector double-float 3))) x y z) debugger invoked on a SB-KERNEL::ARG-COUNT-ERROR in thread 10167: error while parsing arguments to DESTRUCTURING-BIND: invalid number of elements in (VECTOR DOUBLE-FLOAT 3) to satisfy lambda list (VECTOR SB-KERNEL::VTYPE): exactly 2 expected, but 3 foundYou can type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.restarts (invokable by number or by possibly-abbreviated name):0: [ABORT ] Reduce debugger level (leaving debugger, returning to toplevel).1: [TOPLEVEL] Restart at toplevel READ/EVAL/PRINT loop. (SB-KERNEL::PARSE-1-DD-OPTION 2 (:TYPE (VECTOR DOUBLE-FLOAT 3)) #<SB-KERNEL:DEFSTRUCT-DESCRIPTION V3>)[:EXTERNAL] 0]However, clisp and LispWorks (Mac OS X) handle this defstruct type option just fine.Is this a valid type specifier for defstruct? regards, Ralph Raffael Cavallaro, Ph.D. raffaelcavallaro@xxxxxxx
-- Marco Antoniotti http://bioinformatics.nyu.edu NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 715 Broadway 10th FL fax. +1 - 212 - 998 3484 New York, NY, 10003, U.S.A. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users.Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
Date: December 07, 2004
From: Raffael Cavallaro <raffaelcavallaro@xxxxxxx>