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

  1. Newsgroups: comp.lang.lisp
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!uchinews!uchinews.uchicago.edu!converse
  3. From: converse@cs.uchicago.edu (timoshenko)
  4. Subject: Re: macro question
  5. In-Reply-To: davis@passy.ilog.fr's message of 6 Jan 93 09:27:02 GMT
  6. Message-ID: <CONVERSE.93Jan7001530@sloth.uchicago.edu>
  7. Sender: news@uchinews.uchicago.edu (News System)
  8. Organization: University of Chicago Computer Science
  9. References: <1993Jan7.040552.27087@cc.umontreal.ca>
  10.     <CONVERSE.93Jan5225205@sloth.uchicago.edu>
  11.     <DAVIS.93Jan6102702@passy.ilog.fr>
  12. Date: Thu, 7 Jan 1993 06:15:30 GMT
  13. Lines: 38
  14.  
  15. >In article <CONVERSE.93Jan5225205@sloth.uchicago.edu>
  16. converse@cs.uchicago.edu (timoshenko) writes:
  17.  
  18. >>I suppose you could do something like
  19.  
  20. >>(defmacro a (x y)
  21.      `(progn (defun ,x () (+ 2 2))
  22.          (defun ,y () (* 2 3))))
  23. [..]
  24. >>Why do you want to do this, though?  It's likely to be confusing, 
  25.  
  26. In article <DAVIS.93Jan6102702@passy.ilog.fr> davis@passy.ilog.fr (Harley Davis) writes:
  27. >Your solution is correct, but I don't really understand why you don't
  28. >like it.  If all functions "should" be defined by DEFUN, then you are
  29. >severely limiting Lisp's potential for higher level syntactic
  30. >abstractions based on macros.  For example, you would also have to be
  31. >against DEFCLASS forms which define accessor functions since these
  32. >function definitions aren't visible directly at the top level.
  33.  
  34.     Sure, you're right that DEFCLASS and DEFSTRUCT and the like
  35. have the useful side-effect of defining new functions, but those have
  36. the advantage that they are part of the language already.  And, in
  37. fact, such side-effects _are_ confusing (though in DEFCLASS etc. the
  38. confusion is probably worth it).  I remember a confused posting a long
  39. time ago from someone working through an AI programming book (AIP2?)
  40. who wanted to know where in the code MAKE-NODE and NODE-SLOT were
  41. defined.  And the answer was (in a sense) "Nowhere." since they resulted
  42. from a defstruct.  If you know the forms that have this sort of effect
  43. you won't be similarly confused, but you should probably have a pretty
  44. good reason before you use macros to create new ones.  And I wondered 
  45. whether the original poster's problem really needed to extend the
  46. language that far, or whether he was taking that approach because he
  47. was confused about something else.
  48.  
  49.     --Tim Converse
  50. --
  51. -------------------------------------------------------------------------------
  52. Tim Converse  U. of Chicago CS Dept.  converse@cs.uchicago.edu  (312) 702-8584
  53.