One reason for hygiene

You need hygiene because:

Only superstars on their highest alert level [while writing macros] get things right all the time.


That said, hygiene alone isn’t a cure-all for writing predictable macros. If you don’t understand what you are doing, thoroughly; you will screw up eventually. “Thar be dragons here” as someone once warned on the PLT list.

(via PLT)

4 thoughts on “One reason for hygiene”

  1. Hi Pascal,

    Thanks for posting. I am not totally sure why you think this is just about fear, uncertainty, and doubt; so let me elaborate.

    First, I am only talking about Scheme here. I don’t have enough experience with Common Lisp to criticize it. That is why I only tagged this post with ‘Scheme’ ‘Macro’.

    Second, in Scheme; it is pretty easy to screw up macros even when they are hygienic. It takes thoughtfulness and expertise. I have experienced this. Once you start getting into “interesting” macros; you need to be on top of your game.

    Third, let me elaborate on why I agree with the quote (note that I included the relevant part from the source). There are a number of ways to avoid solve the problem that hygienic macros solve in Scheme; (and of course I can’t remember the post on the Bigloo list that talks about all of them. Additionally, my CL friend explained to me how you address avoid name clashes in macros there; so I have a sense of what you mean on your website when you say it is easy to avoid.) and I think that the programmer ought not have to deal with avoiding name clases himself because he has other concerns to deal with. Period, it is pretty simple. Why worry about it if the macro compiler can do it for you?

    Pascal, you shared what you think; now please share why you think it in regards to this post :).

  2. I have argued with Matthias Felleisen about macro hygiene before, and I am pretty sure that he considers his comments about unhygienic macro systems to be much more generally applicable than you do.

    I have looked at the examples in the PLT mailing list (in the thread that you refer to), and it is the case that the particular examples shown there are simply non-issues in Common Lisp. You can write the macros exactly in the straightforward way, and you won’t get the problems Matthias and others think you should get. They argue in the same way that defenders of static type systems argue, and my response is the same as the response of defenders of dynamic type systems: I simply don’t have the problems I am ‘supposed’ to have. (And Matthias’s anecdote is quite lame, IMHO.)

    If all were equal, I wouldn’t object to the macro compiler taking care of macro hygiene for me. However, not all is equal: Syntax-rules and syntax-case require a different style of implementing macros, and as a matter of taste, I simply prefer Lisp-style macros because they better reflect my way of thinking about macros. Furthermore, in Common Lisp, I get a couple of features in the macro system which I don’t get so easily in Scheme macro systems, like lexical environments and macroexpand / macroexpand-1 operators, symbol macros, easy integration with setf, and so on. (Yes, R6RS also adds some of those, but not as elegant as in Common Lisp. IMHO.)

    In short, there is a trade-off here, and the extra features I get in the Common Lisp macro system excite me much more than the automatic hygiene syntax-rules and syntax-case provide. (And I really do understand the subtleties of macro hygiene, I can easily create examples in Common Lisp that would _actually_ be problems in this regard…)

  3. I see. Thanks for elaborating Pascal.

    CL is on my list to learn and I am pretty interested since Scheme is the only Lisp that I have learned well.

Leave a Reply

Your email address will not be published. Required fields are marked *