Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

(eql "foo" "foo") clisp vs hyperspec

2 views
Skip to first unread message

Mirko

unread,
Dec 15, 2008, 2:55:45 PM12/15/08
to
Hello,

For (eql "foo" "foo") hyperspec says true but clisp (2.46 on windows
+cygwin) says nil. (I tried clisp with maximum ansi compliance as
well)

My reading of Seibel's Practical Common Lisp (Ch. 4, p. 47) suggests
nil.

I did not find anything in the hyperspec errata.

Who is right?

Thanks,

Mirko

anonymous...@gmail.com

unread,
Dec 15, 2008, 3:31:54 PM12/15/08
to
"The eql predicate is true if its arguments are eq, or if they are
numbers of the same type with the same value, or if they are character
objects that represent the same character."

you are looking for equal, which identifies isomorphic objects

Rainer Joswig

unread,
Dec 15, 2008, 3:40:31 PM12/15/08
to
In article
<383d6fdb-67b4-4f74...@s24g2000vbp.googlegroups.com>,
Mirko <Mirko....@gmail.com> wrote:

> Hello,
>
> For (eql "foo" "foo") hyperspec says true but clisp (2.46 on windows
> +cygwin) says nil. (I tried clisp with maximum ansi compliance as
> well)
>

If you look at the Hyperspec it says in the examples:

(eql "Foo" "Foo") => true OR => false


See the 'OR'?


If it is the same one string, EQL returns t.
If they are different string objects, but with the same
characters, it is nil.


> My reading of Seibel's Practical Common Lisp (Ch. 4, p. 47) suggests
> nil.
>
> I did not find anything in the hyperspec errata.
>
> Who is right?
>
> Thanks,
>
> Mirko

--
http://lispm.dyndns.org/

Mirko

unread,
Dec 15, 2008, 5:57:59 PM12/15/08
to

Yep, I knew about e`qual'. I got there by way of `eql'.

I was not clear, (nor careful) enough about hyperspec. Here is the
example from hyperspec under eql:

(eql "Foo" "Foo")
=> true
OR=> false

Which one?

stassats

unread,
Dec 15, 2008, 6:01:32 PM12/15/08
to
On Dec 15, 10:55 pm, Mirko <Mirko.Vuko...@gmail.com> wrote:
> Hello,
>
> For (eql "foo" "foo") hyperspec says true but clisp (2.46 on windows
> +cygwin) says nil.  (I tried clisp with maximum ansi compliance as
> well)

Where does it say so?

My hyperspec says:
(eql "Foo" "Foo")
=> true
OR=> false

Note that "OR".

Mirko

unread,
Dec 15, 2008, 6:32:11 PM12/15/08
to
On Dec 15, 3:40 pm, Rainer Joswig <jos...@lisp.de> wrote:
> In article
> <383d6fdb-67b4-4f74-a06c-fbdf2676b...@s24g2000vbp.googlegroups.com>,

>
>  Mirko <Mirko.Vuko...@gmail.com> wrote:
> > Hello,
>
> > For (eql "foo" "foo") hyperspec says true but clisp (2.46 on windows
> > +cygwin) says nil.  (I tried clisp with maximum ansi compliance as
> > well)
>
> If you look at the Hyperspec it says in the examples:
>
>  (eql "Foo" "Foo") =>  true OR =>  false
>
> See the 'OR'?
>
> If it is the same one string, EQL returns t.
> If they are different string objects, but with the same
> characters, it is nil.
>
> > My reading of Seibel's Practical Common Lisp (Ch. 4, p. 47) suggests
> > nil.
>
> > I did not find anything in the hyperspec errata.
>
> > Who is right?
>
> > Thanks,
>
> > Mirko
>
> --http://lispm.dyndns.org/

Thanks for the clarification.

Mirko

Barry Margolin

unread,
Dec 15, 2008, 8:15:43 PM12/15/08
to
In article
<a3ee6218-8677-4d6b...@g38g2000yqd.googlegroups.com>,
Mirko <Mirko....@gmail.com> wrote:

It's implementation-dependent, and likely even context-dependent. The
compiler is allowed to coalesce constants, making all the "Foo" literals
within a compilation unit be EQL to each other. But it's not required
to do this, so it could keep them distinct like the reader does.

If the implementation's REPL compiles the expression before executing
it, it might coalesce the constants, resulting in true.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

Pascal J. Bourguignon

unread,
Dec 16, 2008, 5:32:50 AM12/16/08
to
Mirko <Mirko....@gmail.com> writes:

For this specific form, Barry answered.


Notice that:

(eql #1="Foo" #1#) --> true
(let ((f "Foo")) (eql f f)) --> true
(let ((f "Foo") (g (copy-string "Foo"))) (eql f g)) --> NIL

What CLHS says here, is that reading "Foo" twice may or may not give the same object.

With the reader macros #= and ##, we can ensure that the same object
is used in several places in the s-exp read. But in general you will
have your string objects bound to variables, and you will pass the
values bound to variables to EQL, so you get determinately true or NIL
depending on whether you give twice the same string object or not.

--
__Pascal Bourguignon__

Alex Mizrahi

unread,
Dec 16, 2008, 9:45:02 AM12/16/08
to
M> I did not find anything in the hyperspec errata.

JFYI, hyperspecs examples are not normative, they are just illustrations.
in some cases hyperspec examples are incorrect. not in this case, though.


0 new messages