[Openmcl-devel] Eq definition

Milan Jovanovic milanj at gmail.com
Tue Mar 2 15:33:30 PST 2010


I think this example should explain (if i understand issue right, i'm  
far from lisp expert)
In #'bar there is no full call to #'eq
(someone will correct me if i'm completely wrong)


CL-USER> (defun foo (a b)
	   (declare (optimize safety))
	   (eq a b))
FOO
CL-USER> (defun bar (a b)
	   (declare (optimize speed))
	   (eq a b))
BAR
CL-USER> (disassemble 'foo)
L0
   [0]     (leaq (@ (:^ L0) (% rip)) (% fn))
   [7]     (cmpl ($ 16) (% nargs))
   [10]    (jne L49)
   [12]    (pushq (% rbp))
   [13]    (movq (% rsp) (% rbp))
   [16]    (pushq (% arg_y))
   [17]    (pushq (% arg_z))
   [18]    (movq (@ -8 (% rbp)) (% arg_y))
   [22]    (movq (@ -16 (% rbp)) (% arg_z))
   [26]    (movl ($ 16) (% nargs))
   [31]    (movq (@ 'EQ (% fn)) (% temp0))
   [38]    (leaveq)
   [39]    (jmpq (@ 10 (% temp0)))
L49
   [49]    (uuo-error-wrong-number-of-args)
NIL
CL-USER> (disassemble 'bar)
L0
   [0]     (leaq (@ (:^ L0) (% rip)) (% fn))
   [7]     (cmpl ($ 16) (% nargs))
   [10]    (jne L45)
   [12]    (pushq (% rbp))
   [13]    (movq (% rsp) (% rbp))
   [16]    (pushq (% arg_y))
   [17]    (pushq (% arg_z))
   [18]    (movq (@ -8 (% rbp)) (% arg_y))
   [22]    (movq (@ -16 (% rbp)) (% arg_z))
   [26]    (cmpq (% arg_z) (% arg_y))
   [29]    (movl ($ 77835) (% arg_z.l))
   [34]    (cmovel (@ 37 (% arg_z)) (% arg_z.l))
   [38]    (leaveq)
   [39]    (retq)
L45
   [45]    (uuo-error-wrong-number-of-args)
NIL
CL-USER>

On Mar 3, 2010, at 12:16 AM, Mathieu Suen wrote:

> Do you mean that the (defun eq ..) define an other method that is  
> not the same as the on use inside the body of the method
> (defun eq ..).
> I guess  this is for debugging purpose.
>
>
> On Mar 2, 2010, at 11:22 PM, Milan Jovanovic wrote:
>
>> Try with different safety/speed settings and you will see the
>> difference.
>>
>> On Mar 2, 2010, at 11:12 PM, Mathieu Suen wrote:
>>
>>> On Mar 2, 2010, at 10:40 PM, Gary Byers wrote:
>>>>
>>>> On Tue, 2 Mar 2010, Mathieu Suen wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I read the source code of the eq function and find it quite odd:
>>>>>
>>>>> (defun eq (x y)
>>>>> "Return T if OBJ1 and OBJ2 are the same object, otherwise NIL."
>>>>> (eq x y))
>>>>> ;; /level-0/l0-pred.lisp
>>>>>
>>>>> Is it because it's a primitive?
>>>>
>>>> Yes.
>>>>
>>>> For extra credit: try to define EQ in lisp without depending on
>>>> the compiler to open-code EQ, e.g. :
>>>>
>>>> (declaim (notinline eq))
>>>>
>>>> (defun eq (x y)
>>>> ;;; ????
>>>> )
>>>>
>>>> (This is a koan; if you think about it long enough, you'll either
>>>> achieve enlightenment or get a bad headache.)
>>>>
>>>
>>> :)
>>> I guess that code never get interpreted so what is the purpose of  
>>> it?
>>>
>>>>
>>>>>
>>>>> Thanks
>>>>> 	Mth
>>>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>
>
> 	
>
> 	
> 		
> ___________________________________________________________________________
> Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et  
> son interface révolutionnaire.
> http://fr.mail.yahoo.com
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list