home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!olivea!charnel!sifon!CC.UMontreal.CA!kardank
- From: kardank@ERE.UMontreal.CA (Kardan Kaveh)
- Newsgroups: comp.lang.lisp
- Subject: Re: macro question
- Message-ID: <1993Jan7.163546.27947@cc.umontreal.ca>
- Date: 7 Jan 93 16:35:46 GMT
- References: <CONVERSE.93Jan5225205@sloth.uchicago.edu> <DAVIS.93Jan6102702@passy.ilog.fr> <CONVERSE.93Jan7001530@sloth.uchicago.edu>
- Sender: news@cc.umontreal.ca (Administration de Cnews)
- Organization: Universite de Montreal
- Lines: 46
-
- In article <CONVERSE.93Jan7001530@sloth.uchicago.edu> converse@cs.uchicago.edu (timoshenko) writes:
- >>In article <CONVERSE.93Jan5225205@sloth.uchicago.edu>
- >converse@cs.uchicago.edu (timoshenko) writes:
- >
- >>>I suppose you could do something like
- >
- >>>(defmacro a (x y)
- > `(progn (defun ,x () (+ 2 2))
- > (defun ,y () (* 2 3))))
- >[..]
- >>>Why do you want to do this, though? It's likely to be confusing,
- >
- >In article <DAVIS.93Jan6102702@passy.ilog.fr> davis@passy.ilog.fr (Harley Davis) writes:
- >>Your solution is correct, but I don't really understand why you don't
- >>like it. If all functions "should" be defined by DEFUN, then you are
- >>severely limiting Lisp's potential for higher level syntactic
- >>abstractions based on macros. For example, you would also have to be
- >>against DEFCLASS forms which define accessor functions since these
- >>function definitions aren't visible directly at the top level.
- >
- > Sure, you're right that DEFCLASS and DEFSTRUCT and the like
- >have the useful side-effect of defining new functions, but those have
- >the advantage that they are part of the language already.
- [...]
- >you won't be similarly confused, but you should probably have a pretty
- >good reason before you use macros to create new ones. And I wondered
- >whether the original poster's problem really needed to extend the
- >language that far, or whether he was taking that approach because he
- >was confused about something else.
- >
-
- I wish to define a macro for defining classes, which also defines slot
- accessors that evaluate the slots. In this manner, I can place '(+ 2 2)
- in a slot, and get back 4 when I access the slot.
-
- It seems to me like a reasonable motivation for the type of macro described
- above, but if it isn't, I would be interested in a more elegant solution.
-
- Kaveh
-
-
- --
- ------------
- Kaveh Kardan kaveh@taarna.UUCP
- Systeme Taarna kardank@eole.umontreal.qc.ca
- Montreal Quebec Canada (514)844-8448
-