home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / lisp / mcl / 1595 next >
Encoding:
Text File  |  1992-11-15  |  2.3 KB  |  58 lines

  1. Newsgroups: comp.lang.lisp.mcl
  2. Path: sparky!uunet!convex!darwin.sura.net!spool.mu.edu!agate!dog.ee.lbl.gov!hellgate.utah.edu!hellgate!moore
  3. From: moore@cs.utah.edu (Tim Moore)
  4. Subject: Re: A possible bug in funcall
  5. Message-ID: <MOORE.92Nov15114105@defmacro.cs.utah.edu>
  6. Followup-To: comp.lang.lisp.mcl
  7. In-reply-to: wineberg@scs.carleton.ca's message of 13 Nov 92 23:30:05 GMT
  8. Organization: University of Utah CS Dept
  9. References: <721789069.3191@news.Colorado.EDU>
  10. Distribution: co
  11. Date: 15 Nov 92 11:41:05
  12. Lines: 44
  13.  
  14. In article <721789069.3191@news.Colorado.EDU> wineberg@scs.carleton.ca (Mark Wineberg) writes:
  15.    I was experimenting with funcalls on mcl version 2.0 and found a behavior
  16.    that I did not understand.  The lambda expresions were all copied
  17.    so the error is not produced by a typo.  I far as I know, the
  18.    car of the list is a valid function, properly written with the
  19.    #', yet when the car is taken, a funcall on it does not work.
  20.    Is this a bug in the system or am I misusing something.
  21.  
  22. You are being misled by the printer, which is printing a list of the
  23. form (function ...) as #'...
  24.  
  25.    An example taken from the listener's transcript follows:
  26.  
  27.    ? (funcall #'(lambda () (+ 1 2 3 4 5)))
  28.    15
  29.    ? (funcall (eval '#'(lambda () (+ 1 2 3 4 5))))
  30.    15
  31.    ? (car '(#'(lambda () (+ 1 2 3 4 5)) 25))
  32.    #'(LAMBDA NIL (+ 1 2 3 4 5))
  33.  
  34. The list (function (lambda () (+ 1 2 3 4 5))) isn't a function.  EVAL
  35. (implicity through the read-eval-print loop in your first example,
  36. explicitly in your second), or COMPILE can translate it into a
  37. funcallable object.
  38.  
  39.    ? (funcall (car '(#'(lambda () (+ 1 2 3 4 5)) 25)))
  40.    > Error: #'(LAMBDA NIL (+ 1 2 3 4 5)) can't be FUNCALLed or APPLYed.
  41.    > While executing: CCL::TOPLEVEL-EVAL
  42.    > Type Command-. to abort.
  43.    See the RestartsI menu item for further choices.
  44.    1 > 
  45.  
  46. The correct response.  A real, funcallable function would probably
  47. always be printed something like #<Interpreted Function #X123456>, not
  48. #'(LAMBDA NIL ...)
  49.  
  50. All this implies that you can't put a function in a quoted list by
  51. writing '(foo #'(lambda (bar) ...)).  Indeed, you shouldn't put
  52. functions in constants at all.
  53.  
  54. --
  55. Tim Moore                    moore@cs.utah.edu {bellcore,hplabs}!utah-cs!moore
  56. "Wind in my hair - Shifting and drifting - Mechanical music - Adrenaline surge"
  57.     - Rush
  58.