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

  1. Path: sparky!uunet!cs.utexas.edu!gateway
  2. From: gadbois@mcc.com (David Gadbois)
  3. Newsgroups: comp.lang.lisp
  4. Subject: Re: A question: Dynamic type check
  5. Date: 28 Aug 1992 17:57:41 -0500
  6. Organization: UTexas Mail-to-News Gateway
  7. Lines: 33
  8. Sender: daemon@cs.utexas.edu
  9. Message-ID: <19920828225713.6.GADBOIS@CLIO.MCC.COM>
  10. References: <1992Aug28.192233.20104@jpl-devvax.jpl.nasa.gov>
  11. NNTP-Posting-Host: cs.utexas.edu
  12.  
  13.     Date: Fri, 28 Aug 1992 14:22 CDT
  14.     From: charest@Aig.Jpl.Nasa.Gov (Len Charest)
  15.  
  16.     In article <10026@uqcspe.cs.uq.oz.au>, gong@cs.uq.oz.au (Ming Gong) writes:
  17.     |> I want to know *at run time* whether or not a expression is a
  18.     |> function.  Can some knowledgeable people tell me how?
  19.  
  20.     [...]
  21.  
  22.     If the functions in question are true Lisp function objects, then
  23.     FUNCTIONP should work as described above. Otherwise, the answer
  24.     depends on your implementation of these 'functions'. For example, if
  25.     you used DEFSTRUCT to define the data structure then a
  26.     type-discriminating predicate would be automatically created. E.g.,
  27.  
  28.     (defstruct function
  29.       name
  30.       lambda-list
  31.       code)
  32.  
  33.     > (setq test (make-function :name 'plus :lambda-list '(x y)
  34.                 :code '(+ x y)))
  35.     TEST
  36.     > (function-p test)
  37.     T
  38.  
  39. Note that since FUNCTION is already a type name, you can lose big
  40. redefining it as such even if your implementation lets you.  It would be
  41. not unlike redefining CAR.  It would be OK to use a name like
  42. MY-FUNCTION, or to define it in a package that has its own symbol named
  43. "FUNCTION".
  44.  
  45. --David Gadbois
  46.