[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A possible bug in funcall



Mark Wineberg (wineberg@scs.carleton.ca) writes:
   I was experimenting with funcalls on mcl version 2.0 and found a behavior
   that I did not understand.  The lambda expresions were all copied
   so the error is not produced by a typo.  I far as I know, the
   car of the list is a valid function, properly written with the
   #', yet when the car is taken, a funcall on it does not work.
   Is this a bug in the system or am I misusing something.
    
    An example taken from the listener's transcript follows:
     
     ? (funcall #'(lambda () (+ 1 2 3 4 5)))
     15
     ? (funcall (eval '#'(lambda () (+ 1 2 3 4 5))))
     15
     ? (car '(#'(lambda () (+ 1 2 3 4 5)) 25))
     #'(LAMBDA NIL (+ 1 2 3 4 5))
     ? (funcall (car '(#'(lambda () (+ 1 2 3 4 5)) 25)))
     > Error: #'(LAMBDA NIL (+ 1 2 3 4 5)) can't be FUNCALLed or APPLYed.
     > While executing: CCL::TOPLEVEL-EVAL
     > Type Command-. to abort.
     See the RestartsI menu item for further choices.
     1 >
The problem occurs because the quote (') does not evaluate its arguments:
?   '((#'(lambda () (+ 1 2 3 4 5)) 25))
((#'(LAMBDA NIL (+ 1 2 3 4 5)) 25))
is not the same as
?    (list #'(lambda () (+ 1 2 3 4 5)) 25)
(#<Anonymous Function #x4380AE> 25)

? (equal '((#'(lambda () (+ 1 2 3 4 5)) 25))
	 (list #'(lambda () (+ 1 2 3 4 5)) 25))
NIL
The type of the car of the first expression is CONS while the type of the
second expression is function:
? (type-of (car '((#'(lambda () (+ 1 2 3 4 5)) 25))))
CONS
? (type-of (car (list #'(lambda () (+ 1 2 3 4 5)) 25)))
FUNCTION


mark