home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!ames!think.com!barmar
- From: barmar@think.com (Barry Margolin)
- Newsgroups: comp.lang.lisp
- Subject: Re: A question: Dynamic type check
- Date: 28 Aug 1992 21:28:51 GMT
- Organization: Thinking Machines Corporation, Cambridge MA, USA
- Lines: 41
- Message-ID: <17m5qjINNgll@early-bird.think.com>
- References: <10026@uqcspe.cs.uq.oz.au> <1992Aug28.192233.20104@jpl-devvax.jpl.nasa.gov>
- NNTP-Posting-Host: telecaster.think.com
-
- In article <1992Aug28.192233.20104@jpl-devvax.jpl.nasa.gov> charest@aig.jpl.nasa.gov writes:
- >In article <10026@uqcspe.cs.uq.oz.au>, gong@cs.uq.oz.au (Ming Gong) writes:
- >|> For example, I have a lisp function PLUS implementing
- >|> lambda x. lambda y. x + y
- >|> then (funcall (PLUS) 3) is a function and will printout something like
- >|> #<Function PLUS ....>.
- >
-
- >Some observations: if PLUS is a Lisp function then the form (PLUS) is a
- >call to that function with no arguments; furthermore (funcall (PLUS) 3) is
- >a call to the *result* of (PLUS) with the argument 3. I'll assume that you
- >mean (PLUS) returns the function object and that object is what prints as
- >#<Function PLUS ....>. This suggests that PLUS is not an ordinary Lisp
- >function object, but rather some custom data structure that you
- >implemented yourself.
-
- It looks to me like he's experimenting with curried functions. Presumably
- his definition of PLUS is something like:
-
- (defun plus ()
- #'(lambda (x)
- #'(lambda (y) (+ x y))))
-
- When I use this in Lucid CL I see:
-
- > (funcall (plus) 3)
- #<Compiled-Function (:INTERNAL (:INTERNAL PLUS 0) 0) C349EE>
- > (plus)
- #<Compiled-Function (:INTERNAL PLUS 0) C347E6>
- > (funcall (plus) 3)
- #<Compiled-Function (:INTERNAL (:INTERNAL PLUS 0) 0) C34C8E>
- > (funcall (funcall (plus) 3) 4)
- 7
-
- I can easily imagine other Lisp implementations printing out the first two
- results as "#<Function PLUS ...>".
- --
- Barry Margolin
- System Manager, Thinking Machines Corp.
-
- barmar@think.com {uunet,harvard}!think!barmar
-