home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.lisp.mcl
- Path: sparky!uunet!convex!darwin.sura.net!spool.mu.edu!agate!dog.ee.lbl.gov!hellgate.utah.edu!hellgate!moore
- From: moore@cs.utah.edu (Tim Moore)
- Subject: Re: A possible bug in funcall
- Message-ID: <MOORE.92Nov15114105@defmacro.cs.utah.edu>
- Followup-To: comp.lang.lisp.mcl
- In-reply-to: wineberg@scs.carleton.ca's message of 13 Nov 92 23:30:05 GMT
- Organization: University of Utah CS Dept
- References: <721789069.3191@news.Colorado.EDU>
- Distribution: co
- Date: 15 Nov 92 11:41:05
- Lines: 44
-
- In article <721789069.3191@news.Colorado.EDU> wineberg@scs.carleton.ca (Mark Wineberg) 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.
-
- You are being misled by the printer, which is printing a list of the
- form (function ...) as #'...
-
- 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))
-
- The list (function (lambda () (+ 1 2 3 4 5))) isn't a function. EVAL
- (implicity through the read-eval-print loop in your first example,
- explicitly in your second), or COMPILE can translate it into a
- funcallable object.
-
- ? (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 correct response. A real, funcallable function would probably
- always be printed something like #<Interpreted Function #X123456>, not
- #'(LAMBDA NIL ...)
-
- All this implies that you can't put a function in a quoted list by
- writing '(foo #'(lambda (bar) ...)). Indeed, you shouldn't put
- functions in constants at all.
-
- --
- Tim Moore moore@cs.utah.edu {bellcore,hplabs}!utah-cs!moore
- "Wind in my hair - Shifting and drifting - Mechanical music - Adrenaline surge"
- - Rush
-