Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!edcastle!aiai!aiai.ed.ac.uk!jeff From: jeff@aiai.ed.ac.uk (Jeff Dalton) Newsgroups: comp.lang.scheme Subject: Re: macros, understanding of macros Keywords: macros, elimination of macros Message-ID: <4297@skye.ed.ac.uk> Date: 11 Mar 91 14:50:48 GMT References: <1991Mar9.202550.10979@rice.edu> Sender: news@aiai.ed.ac.uk Reply-To: jeff@aiai.uucp (Jeff Dalton) Organization: AIAI, University of Edinburgh, Scotland Lines: 56 In article <1991Mar9.202550.10979@rice.edu> matthias@leto.rice.edu (Matthias Felleisen) writes: >CLAIM: Disciplined uses of macros can be reduced to the uses of >procedures. They are therefore as understandable (or even more so) as >uses of procedures as far as their semantics is concerned. >JUSTIFICATION OF CLAIM: It is easy to show that each use of a macro >can be translated into the use of a procedure, with appropriate >changes to instances of macros. This is an interesting claim and justification, especially since it identifies a useful class of "disciplined" macros. What the justification actually justifies, however, is that disciplined uses of macros can be reduced to uses of procedures, not that macros are therefore as understandable. After all, it might be that the transformed code (ie, the code that uses procedures instead of macros) was sometimes, or even always, easier to understand. Indeed, the reduction of macros to procedures requires an additional step -- the transformation of the code -- which could be seen as showing that macros are _harder_ to understand. Moreover, I think the plausibility of your approach to this issue is due in part to an accident of wording. Someone said "macros are harder to understand than procedures", but for their purposes they could just as well have said "code that uses macros is harder to understand than equivalent code that does not use macros". And the one could try the following: CLAIM: Code that uses macros can be transformed into equivalent code that does not use macros. It is therefore as understandable ... JUSTIFICATION: Expand the macro calls. This approach will not be convincing to anyone who really does think that the equivalent macro-less code is easier to understand. It has one defect that is avoided in your approach, namely that some macros might be defined in such a way that calls to them cannot be completely expanded. But I don't think _that_ is why people find macros hard to understand. (If it is why, or at least a significant factor, then the case for your approach would certainly be strengthened.) In short. I think that in the end it still comes down to the difficult to formalize psychological reasons you introduce later: >QUESTION: Why do we use disciplined macros then, if (in Scheme) their >use can be reduced to the use of procedures? > >ANSWER: For syntactic reasons: disciplined macros abstract syntactic >patterns just like procedures abstract action patterns. > >WHY DO WE WANT TO HIDE PATTERNS: basically for psychological reasons, >but they are difficult to formalize. -- jd