home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / lisp / 3195 < prev    next >
Encoding:
Text File  |  1993-01-07  |  2.5 KB  |  58 lines

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