home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / lisp / 2334 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.9 KB  |  53 lines

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!ames!think.com!barmar
  2. From: barmar@think.com (Barry Margolin)
  3. Newsgroups: comp.lang.lisp
  4. Subject: Re: A question: Dynamic type check
  5. Date: 28 Aug 1992 21:28:51 GMT
  6. Organization: Thinking Machines Corporation, Cambridge MA, USA
  7. Lines: 41
  8. Message-ID: <17m5qjINNgll@early-bird.think.com>
  9. References: <10026@uqcspe.cs.uq.oz.au> <1992Aug28.192233.20104@jpl-devvax.jpl.nasa.gov>
  10. NNTP-Posting-Host: telecaster.think.com
  11.  
  12. In article <1992Aug28.192233.20104@jpl-devvax.jpl.nasa.gov> charest@aig.jpl.nasa.gov writes:
  13. >In article <10026@uqcspe.cs.uq.oz.au>, gong@cs.uq.oz.au (Ming Gong) writes:
  14. >|> For example, I have a lisp function PLUS implementing 
  15. >|>      lambda x. lambda y. x + y
  16. >|> then (funcall (PLUS) 3) is a function and will printout something like
  17. >|>      #<Function PLUS ....>.
  18. >
  19.  
  20. >Some observations: if PLUS is a Lisp function then the form (PLUS) is a
  21. >call to that function with no arguments; furthermore (funcall (PLUS) 3) is
  22. >a call to the *result* of (PLUS) with the argument 3. I'll assume that you
  23. >mean (PLUS) returns the function object and that object is what prints as
  24. >#<Function PLUS ....>. This suggests that PLUS is not an ordinary Lisp
  25. >function object, but rather some custom data structure that you
  26. >implemented yourself.
  27.  
  28. It looks to me like he's experimenting with curried functions.  Presumably
  29. his definition of PLUS is something like:
  30.  
  31. (defun plus ()
  32.   #'(lambda (x)
  33.       #'(lambda (y) (+ x y))))
  34.  
  35. When I use this in Lucid CL I see:
  36.  
  37. > (funcall (plus) 3)
  38. #<Compiled-Function (:INTERNAL (:INTERNAL PLUS 0) 0) C349EE>
  39. > (plus)
  40. #<Compiled-Function (:INTERNAL PLUS 0) C347E6>
  41. > (funcall (plus) 3)
  42. #<Compiled-Function (:INTERNAL (:INTERNAL PLUS 0) 0) C34C8E>
  43. > (funcall (funcall (plus) 3) 4)
  44. 7
  45.  
  46. I can easily imagine other Lisp implementations printing out the first two
  47. results as "#<Function PLUS ...>".
  48. -- 
  49. Barry Margolin
  50. System Manager, Thinking Machines Corp.
  51.  
  52. barmar@think.com          {uunet,harvard}!think!barmar
  53.