[Openmcl-devel] (equal '#:G34159 '#:G34159) -> NIL

Taoufik Dachraoui dachraoui.taoufik at gmail.com
Wed Aug 1 13:40:08 PDT 2012


Hi

this is what happened:

(defun f (lst) (equal (first lst) (second lst)))
(defun g () (let ((x (gensym))) `(,x ,x)))

? (g)
(#:G34410 #:G34410)
? (f '(#:G34410 #:G34410))
NIL
? (f (g))
T


I had the tendancy to think that everything that have the same printed form
are equal; But can
someone explain why this is not so ?  (as shown above and in the example by
Jason below)

I may understand the following but I am not sure (need an expert
explanation)

? (equal #(1 2 3) #(1 2 3))
NIL

Kind regards
Taoufik


On Wed, Aug 1, 2012 at 9:32 PM, Jason Aeschliman <j.aeschliman at gmail.com>wrote:

> this may help:
>
> (defun compare (x y)
>   (list x y (eq x y) (equal x y) (equalp x y)))
>
> (let* ((x (gensym))
>        (y (read-from-string (prin1-to-string x))))
>   (list   (compare x x)
>   (compare x y)))
>
>
> On Wed, Aug 1, 2012 at 3:28 PM, Ron Garret <ron at flownet.com> wrote:
>
>>
>> On Aug 1, 2012, at 12:22 PM, Taoufik Dachraoui wrote:
>>
>> > Ok thanks
>> >
>> > I solved the problem by doing using (intern (symbol-name (gensym)))
>> instead of (gensym)
>> >
>> > I did not know that the generated symbols do not belong to any package:
>> >
>> > (symbol-package '#:G34159)
>> > > NIL
>>
>> RTFM.
>>
>> http://clhs.lisp.se/Body/f_gensym.htm
>>
>> You might also want to take a look at GENTEMP.
>>
>> >
>> > Is there any reason for this? because usually a symbol is interned in
>> the current package
>>
>> Not when you make it with GENSYM (which uses MAKE-SYMBOL)  The Lisp
>> reader interns symbols in the current package, but MAKE-SYMBOL doesn't.
>>
>> You really should read the paper I pointed you to.  All of it.
>>
>> rg
>>
>> _______________________________________________
>> Openmcl-devel mailing list
>> Openmcl-devel at clozure.com
>> http://clozure.com/mailman/listinfo/openmcl-devel
>>
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20120801/6c561e36/attachment.htm>


More information about the Openmcl-devel mailing list