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