[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
equality of structures, or *default-structure-type*
- To: common-lisp@SAIL.STANFORD.EDU
- Subject: equality of structures, or *default-structure-type*
- From: Hiroshi "Gitchang" Okuno <Okuno@SUMEX-AIM.STANFORD.EDU>
- Date: Sun, 8 Nov 87 14:26:27 PST
- Address: 701 Welch Road, Building C, Palo Alto, CA 94304-1703
- Group: Heuristic Programming Project
- Organization: Knowledge Systems Laboratory, CSD, Stanford University
- Phone: +1 (415)725-4854
- Project: Advanced Architectures Project
If the :type option is not specified in defstruct, the structure is
represented in an implementation-dependent manner (CLtL p.314).
However, this implementation-dependentness introduces the ambiguity of
equality of structures. Suppose that one implementation uses an array
for the default representation of a structure, while the other
implementation uses a list for it (of course, it's a silly
implementation). The equality of structures may differ on these two
implementations, since equality of array is checked by the 'eq'ness
and that of list is checked by the equality of corresponding elements
(CLtL p.80). For example,
(defstruct foo a b c)
default :type = :array
(equal (make-foo) (make-foo)) ===> nil
default :type = :list
(equal (make-foo) (make-foo)) ===> t
This observation proves that we need introduce a new global variable,
say *default-structure-type*, in order to raise the portability of
COMMON Lisp programs.
Since I cannot find any messages on this matter in the archived
files at sumex, I post this message.
- Gitchang -
-------