home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / lisp / mcl / 1550 next >
Encoding:
Text File  |  1992-11-06  |  1.3 KB  |  47 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!concert!gatech!usenet.ins.cwru.edu!agate!apple!apple!cambridge.apple.com!straz@cambridge.apple.com
  2. From: straz@cambridge.apple.com (Steve Strassmann)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: functionp
  5. Message-ID: <9211051708.AA21411@cambridge.apple.com>
  6. Date: 5 Nov 92 17:08:12 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 33
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10. Full-Name: Steve Strassmann
  11. Original-To: Aladin Akyurek <akyurek@niscale.LeidenUniv.nl>
  12. Original-Cc: info-mcl
  13.  
  14. >From: Aladin Akyurek <akyurek@niscale.LeidenUniv.nl>
  15. >Subject: functionp
  16. >To: info-mcl@cambridge.apple.com
  17. >Date: Thu, 5 Nov 92 16:38:57 MET
  18. >Cc: akyurek@hammer.niscale.LeidenUniv.nl (Aladin Akyurek [NISCALE])
  19. >Mailer: Elm [revision: 70.30]
  20. >
  21. >When you have a function defined, say (defun junk (x) ... ),
  22. >and you try:
  23. >
  24. >(functionp 'junk)
  25. >
  26. >you get NIL.
  27. >
  28. >Is this not a bug? 
  29. >
  30. >-Aladin
  31.  
  32. It is not. What you should use instead is 
  33.  (functionp #'junk)  or 
  34.  (functionp (symbol-function 'junk)) 
  35.  
  36. Unlike Scheme (where every symbol has just one value), Common Lisp
  37. has a value-cell and a function-cell for every symbol. Thus you can do
  38.  (defvar junk 5)
  39.  (defun junk (x) x)
  40.  
  41. and you'll get
  42. ? (junk junk)
  43. 5
  44.  
  45. The sharp-quote (#') gets you the function cell, and THAT is what
  46. you want to test.
  47.