home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!sdd.hp.com!think.com!barmar
- From: barmar@think.com (Barry Margolin)
- Newsgroups: comp.lang.lisp
- Subject: Re: Selective compilation of reader macro forms...
- Date: 8 Sep 1992 03:10:42 GMT
- Organization: Thinking Machines Corporation, Cambridge MA, USA
- Lines: 36
- Message-ID: <18h5jiINNj27@early-bird.think.com>
- References: <60132@mimsy.umd.edu>
- NNTP-Posting-Host: gandalf.think.com
-
- In article <60132@mimsy.umd.edu> waander@cs.umd.edu (Bill Andersen) writes:
- > I have a reader macro which I want to do two different things depending on
- >whether the form following the macro is being compiled, or is being
- >entered interactively.
-
- If the reader macro is being defined in the same file as the uses that
- should get this special treatment, the following should work:
-
- (eval-when (compile)
- (defun read-macro-compile ...)
- (set-macro-character #\<char> #'read-macro-compile ...))
-
- (defun read-macro-runtime ...)
-
- (set-macro-character #\<char> #'read-macro-runtime ...)
-
- If the above restriction doesn't apply, you could use a special variable:
-
- (defvar *read-macro-being-compiled* nil)
-
- (defun read-macro (...)
- (if *read-macro-being-compiled*
- ...))
-
- (defun my-compile-file (&rest args)
- (let ((*read-macro-being-compiled* t))
- (apply #'compile-file args)))
-
- (defun my-compile (*rest args)
- (let ((*read-macro-being-compiled* t))
- (apply #'compile args)))
- --
- Barry Margolin
- System Manager, Thinking Machines Corp.
-
- barmar@think.com {uunet,harvard}!think!barmar
-