home *** CD-ROM | disk | FTP | other *** search
- 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
- From: straz@cambridge.apple.com (Steve Strassmann)
- Newsgroups: comp.lang.lisp.mcl
- Subject: functionp
- Message-ID: <9211051708.AA21411@cambridge.apple.com>
- Date: 5 Nov 92 17:08:12 GMT
- Sender: info-mcl-request@cambridge.apple.com
- Lines: 33
- Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
- Full-Name: Steve Strassmann
- Original-To: Aladin Akyurek <akyurek@niscale.LeidenUniv.nl>
- Original-Cc: info-mcl
-
- >From: Aladin Akyurek <akyurek@niscale.LeidenUniv.nl>
- >Subject: functionp
- >To: info-mcl@cambridge.apple.com
- >Date: Thu, 5 Nov 92 16:38:57 MET
- >Cc: akyurek@hammer.niscale.LeidenUniv.nl (Aladin Akyurek [NISCALE])
- >Mailer: Elm [revision: 70.30]
- >
- >When you have a function defined, say (defun junk (x) ... ),
- >and you try:
- >
- >(functionp 'junk)
- >
- >you get NIL.
- >
- >Is this not a bug?
- >
- >-Aladin
-
- It is not. What you should use instead is
- (functionp #'junk) or
- (functionp (symbol-function 'junk))
-
- Unlike Scheme (where every symbol has just one value), Common Lisp
- has a value-cell and a function-cell for every symbol. Thus you can do
- (defvar junk 5)
- (defun junk (x) x)
-
- and you'll get
- ? (junk junk)
- 5
-
- The sharp-quote (#') gets you the function cell, and THAT is what
- you want to test.
-