1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/03_bdbb.htm
2024-04-01 10:24:07 +02:00

64 lines
16 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Section 3.2.4.2.2</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="03_bdba.htm">
<LINK REL=UP HREF="03_bdb.htm">
<LINK REL=NEXT HREF="03_bdc.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="03_bdba.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="03_bdb.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="03_bdc.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
3.2.4.2.2 Definition of Similarity</H2> <P>
Two <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A> S (in <A REL=DEFINITION HREF="26_glo_s.htm#source_code"><I>source code</I></A>) and C (in <A REL=DEFINITION HREF="26_glo_c.htm#compiled_code"><I>compiled code</I></A>) are defined to be <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if and only if they are both of one of the <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>types</I></A> listed here (or defined by the <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A>) and they both satisfy all additional requirements of <A REL=DEFINITION HREF="26_glo_s.htm#similarity"><I>similarity</I></A> indicated for that <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A>. <P>
<P><DL><P>
<DT><A REL=DEFINITION HREF="t_number.htm#number"><B>number</B></A> <P><DD>
Two <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>numbers</I></A> S and C are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if they are of the same <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> and represent the same mathematical value. <P>
<DT><A REL=DEFINITION HREF="t_ch.htm#character"><B>character</B></A> <P><DD>
Two <A REL=DEFINITION HREF="26_glo_s.htm#simple"><I>simple</I></A> <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>characters</I></A> S and C are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if they have <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> <A REL=DEFINITION HREF="26_glo_c.htm#code"><I>code</I></A> <A REL=DEFINITION HREF="26_glo_a.htm#attribute"><I>attributes</I></A>. <P>
<A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>Implementations</I></A> providing additional, <A REL=DEFINITION HREF="26_glo_i.htm#implementation-defined"><I>implementation-defined</I></A> <A REL=DEFINITION HREF="26_glo_a.htm#attribute"><I>attributes</I></A> must define whether and how <A REL=DEFINITION HREF="26_glo_n.htm#non-simple"><I>non-simple</I></A> <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>characters</I></A> can be regarded as <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A>. <P>
<DT><A REL=DEFINITION HREF="t_symbol.htm#symbol"><B>symbol</B></A> <P><DD>
Two <A REL=DEFINITION HREF="26_glo_a.htm#apparently_uninterned"><I>apparently uninterned</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbols</I></A> S and C are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if their <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>names</I></A> are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A>. <P>
Two <A REL=DEFINITION HREF="26_glo_i.htm#interned"><I>interned</I></A> symbols S and C are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if their <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>names</I></A> are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A>, and if either S is accessible in the <A REL=DEFINITION HREF="26_glo_c.htm#current_package"><I>current package</I></A> at compile time and C is accessible in the <A REL=DEFINITION HREF="26_glo_c.htm#current_package"><I>current package</I></A> at load time, or C is accessible in the <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> that is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the <A REL=DEFINITION HREF="26_glo_h.htm#home_package"><I>home package</I></A> of S. <P>
(Note that <A REL=DEFINITION HREF="26_glo_s.htm#similarity"><I>similarity</I></A> of <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbols</I></A> is dependent on neither the <A REL=DEFINITION HREF="26_glo_c.htm#current_readtable"><I>current readtable</I></A> nor how the <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="f_rd_rd.htm#read"><B>read</B></A> would parse the <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>characters</I></A> in the <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> of the <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A>.) <P>
<DT><A REL=DEFINITION HREF="t_pkg.htm#package"><B>package</B></A> <P><DD>
Two <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>packages</I></A> S and C are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if their <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>names</I></A> are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A>. <P>
Note that although a <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is an <A REL=DEFINITION HREF="26_glo_e.htm#externalizable_object"><I>externalizable object</I></A>, the programmer is responsible for ensuring that the corresponding <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> is already in existence when code referencing it as a <A REL=DEFINITION HREF="26_glo_l.htm#literal"><I>literal</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is <I>loaded</I>. The <A REL=DEFINITION HREF="26_glo_l.htm#loader"><I>loader</I></A> finds the corresponding <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> as if by calling <A REL=DEFINITION HREF="f_find_p.htm#find-package"><B>find-package</B></A> with that <A REL=DEFINITION HREF="26_glo_n.htm#name"><I>name</I></A> as an <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A>. An error is signaled by the <A REL=DEFINITION HREF="26_glo_l.htm#loader"><I>loader</I></A> if no <A REL=DEFINITION HREF="26_glo_p.htm#package"><I>package</I></A> exists at load time. <P>
<DT><A REL=DEFINITION HREF="t_rnd_st.htm#random-state"><B>random-state</B></A> <P><DD>
Two <A REL=DEFINITION HREF="26_glo_r.htm#random_state"><I>random states</I></A> S and C are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if S would always produce the same sequence of pseudo-random numbers as a <A REL=DEFINITION HREF="26_glo_c.htm#copy"><I>copy</I></A>[5] of C when given as the <I>random-state</I> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A> to the <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="f_random.htm#random"><B>random</B></A>, assuming equivalent <I>limit</I> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>arguments</I></A> in each case. <P>
(Note that since C has been processed by the <A REL=DEFINITION HREF="26_glo_f.htm#file_compiler"><I>file compiler</I></A>, it cannot be used directly as an <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A> to <A REL=DEFINITION HREF="f_random.htm#random"><B>random</B></A> because <A REL=DEFINITION HREF="f_random.htm#random"><B>random</B></A> would perform a side effect.) <P>
<DT><A REL=DEFINITION HREF="t_cons.htm#cons"><B>cons</B></A> <P><DD>
Two <A REL=DEFINITION HREF="26_glo_c.htm#cons"><I>conses</I></A>, S and C, are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if the <A REL=DEFINITION HREF="26_glo_c.htm#car"><I>car</I></A>[2] of S is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the <A REL=DEFINITION HREF="26_glo_c.htm#car"><I>car</I></A>[2] of C, and the <A REL=DEFINITION HREF="26_glo_c.htm#cdr"><I>cdr</I></A>[2] of S is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the <A REL=DEFINITION HREF="26_glo_c.htm#cdr"><I>cdr</I></A>[2] of C. <P>
<DT><A REL=DEFINITION HREF="t_array.htm#array"><B>array</B></A> <P><DD>
Two one-dimensional <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>arrays</I></A>, S and C, are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if the <A REL=DEFINITION HREF="26_glo_l.htm#length"><I>length</I></A> of S is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the <A REL=DEFINITION HREF="26_glo_l.htm#length"><I>length</I></A> of C, the <A REL=DEFINITION HREF="26_glo_a.htm#actual_array_element_type"><I>actual array element type</I></A> of S is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the <A REL=DEFINITION HREF="26_glo_a.htm#actual_array_element_type"><I>actual array element type</I></A> of C, and each <A REL=DEFINITION HREF="26_glo_a.htm#active"><I>active</I></A> <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> of S is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the corresponding <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> of C. <P>
Two <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>arrays</I></A> of <A REL=DEFINITION HREF="26_glo_r.htm#rank"><I>rank</I></A> other than one, S and C, are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if the <A REL=DEFINITION HREF="26_glo_r.htm#rank"><I>rank</I></A> of S is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the <A REL=DEFINITION HREF="26_glo_r.htm#rank"><I>rank</I></A> of C, each <A REL=DEFINITION HREF="26_glo_d.htm#dimension"><I>dimension</I></A>[1] of S is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the corresponding <A REL=DEFINITION HREF="26_glo_d.htm#dimension"><I>dimension</I></A>[1] of C, the <A REL=DEFINITION HREF="26_glo_a.htm#actual_array_element_type"><I>actual array element type</I></A> of S is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the <A REL=DEFINITION HREF="26_glo_a.htm#actual_array_element_type"><I>actual array element type</I></A> of C, and each <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> of S is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to the corresponding <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> of C. <P>
In addition, if S is a <A REL=DEFINITION HREF="26_glo_s.htm#simple_array"><I>simple array</I></A>, then C must also be a <A REL=DEFINITION HREF="26_glo_s.htm#simple_array"><I>simple array</I></A>. If S is a <A REL=DEFINITION HREF="26_glo_d.htm#displaced_array"><I>displaced array</I></A>, has a <A REL=DEFINITION HREF="26_glo_f.htm#fill_pointer"><I>fill pointer</I></A>, or is <A REL=DEFINITION HREF="26_glo_a.htm#actually_adjustable"><I>actually adjustable</I></A>, C is permitted to lack any or all of these qualities. <P>
<DT><A REL=DEFINITION HREF="t_hash_t.htm#hash-table"><B>hash-table</B></A> <P><DD>
Two <A REL=DEFINITION HREF="26_glo_h.htm#hash_table"><I>hash tables</I></A> S and C are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if they meet the following three requirements: <P>
<P><OL><LI> They both have the same test (e.g., they are both <A REL=DEFINITION HREF="f_eql.htm#eql"><B>eql</B></A> <A REL=DEFINITION HREF="26_glo_h.htm#hash_table"><I>hash tables</I></A>). <P>
<LI> There is a unique one-to-one correspondence between the keys of the two <A REL=DEFINITION HREF="26_glo_h.htm#hash_table"><I>hash tables</I></A>, such that the corresponding keys are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A>. <P>
<LI> For all keys, the values associated with two corresponding keys are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A>. <P></OL><P>
If there is more than one possible one-to-one correspondence between the keys of S and C, the consequences are unspecified. A <A REL=DEFINITION HREF="26_glo_c.htm#conforming_program"><I>conforming program</I></A> cannot use a table such as S as an <I>externalizable constant</I>. <P>
<DT><A REL=DEFINITION HREF="t_pn.htm#pathname"><B>pathname</B></A> <P><DD>
Two <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathnames</I></A> S and C are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> if all corresponding <A REL=DEFINITION HREF="26_glo_p.htm#pathname"><I>pathname</I></A> <I>components</I> are <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A>. <P>
<DT><A REL=DEFINITION HREF="t_fn.htm#function"><B>function</B></A> <P><DD>
<A REL=DEFINITION HREF="26_glo_f.htm#function"><I>Functions</I></A> are not <A REL=DEFINITION HREF="26_glo_e.htm#externalizable_object"><I>externalizable objects</I></A>. <P>
<DT><A REL=DEFINITION HREF="t_stu_ob.htm#structure-object"><B>structure-object</B></A> and <A REL=DEFINITION HREF="t_std_ob.htm#standard-object"><B>standard-object</B></A> <P><DD>
A general-purpose concept of <A REL=DEFINITION HREF="26_glo_s.htm#similarity"><I>similarity</I></A> does not exist for <A REL=DEFINITION HREF="26_glo_s.htm#structure"><I>structures</I></A> and <A REL=DEFINITION HREF="26_glo_s.htm#standard_object"><I>standard objects</I></A>. However, a <A REL=DEFINITION HREF="26_glo_c.htm#conforming_program"><I>conforming program</I></A> is permitted to define a <A REL=DEFINITION HREF="f_mk_ld_.htm#make-load-form"><B>make-load-form</B></A> <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> for any <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> K defined by that <A REL=DEFINITION HREF="26_glo_p.htm#program"><I>program</I></A> that is a <A REL=DEFINITION HREF="26_glo_s.htm#subclass"><I>subclass</I></A> of either <A REL=DEFINITION HREF="t_stu_ob.htm#structure-object"><B>structure-object</B></A> or <A REL=DEFINITION HREF="t_std_ob.htm#standard-object"><B>standard-object</B></A>. The effect of such a <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>method</I></A> is to define that an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> S of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> K in <A REL=DEFINITION HREF="26_glo_s.htm#source_code"><I>source code</I></A> is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> C of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> K in <A REL=DEFINITION HREF="26_glo_c.htm#compiled_code"><I>compiled code</I></A> if C was constructed from <A REL=DEFINITION HREF="26_glo_c.htm#code"><I>code</I></A> produced by calling <A REL=DEFINITION HREF="f_mk_ld_.htm#make-load-form"><B>make-load-form</B></A> on S. <P>
<P></DL><P>
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss215.htm">LOAD-OBJECTS:MAKE-LOAD-FORM</A><LI> <A REL=CHILD HREF="../Issues/iss082.htm">CONSTANT-FUNCTION-COMPILATION:NO</A><LI> <A REL=CHILD HREF="../Issues/iss063.htm">COMPILE-FILE-SYMBOL-HANDLING:NEW-REQUIRE-CONSISTENCY</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>