Hacker News new | past | comments | ask | show | jobs | submit login

I don't think that matters. Either you write a macro that is correct that won't break because of unwanted intersection with the place of expansion, or your macro is wrong.

Edit: barring code-walking macro of course. Once you start using those, the bets are off.

Edit2: of course, I don't think overwriting core forms count either. That is poor bedside manners :)




Rather than rehash the ancient argument once again, I defer to this post:

https://www.xach.com/naggum/articles/3225161536947499@naggum...

(KMP was on both Common Lisp and Scheme standard committees; Erik Naggum was an eloquent, if controversial, Lisp expert)


They both (in this case):

1. are at least a little bit wrong.

2. Never use FLET or LABELS

I think we can rule out #2. Function capture is a legitimate problem that does (admittedly rarely) happen in real-world code.

The thing that makes writing hygienic macros possible in CL today is the package system. It's disallowed to rebind functions from the CL package, so if your macros only rely on non-exported symbols from your package and symbols in the CL package, then you are free from any hygiene problems that aren't caused by code that is clearly bad locally (that is code that binds internal symbols of other packages; any "::" in use should be immediately flagged by a code review.)


> if your macros only rely on non-exported symbols from your package and symbols in the CL package, then you are free from any hygiene problems that aren't caused by code that is clearly bad locally

Not quite true, recursive macro invocations that create bindings can step on themselves and force you to use GENSYM, even if your criteria are satisfied.


The "interesting" macro hygiene problems can't be solved with GENSYM. I was assuming it was understood that proper macros should use GENSYM for generated bindings.


First of all, KMP argues that the problem does not exist in a lisp 2. This is obviously wrong, even though the risk is smaller. I would argue that a macro that acts correctly 99% of the time is still wrong. Lisp-2 doesn't solve this. Gensym and packages do.

Erik says that gensym and packages solve the same issue that hygiene solves - something I said all along. His main gripe seems to be with the single namespace, which most people dont see as a problem. If you really really need to call your variables `list`, then by all means: use multiple namespaces.


Correct me if I'm wrong, but Lisp-2 vs. Lisp-1 has nothing to do with hygiene, it just splits Scheme's single problem (lexically binding values in macros) into two problems (lexically binding values in macros, and lexically binding functions in macros).

The real problem, which Naggum includes, is the lack of GENSYM (if scheme indeed lacks it), and lack of first class symbols, as he mentioned.


> it just splits Scheme's single problem (lexically binding values in macros) into two problems (lexically binding values in macros, and lexically binding functions in macros).

Bingo. Lisp-2 and GENSYM are attempting to solve the same issue in two different use cases. And, if I may add, GENSYM looks a bit lazy and half-assed next to the scortch-the-earth multiple namespaces of Lisp-2. It's like they blew up Lisp with dynamite and then sat down and said "whatever" when the same problem appears in macros.

> The real problem, which Naggum includes, is the lack of GENSYM

Guile Scheme has both GENSYM and DEFMACRO (unhygienic). I think quite a few Scheme systems err on the side of practical concerns.

But that doesn't erase that fact that GENSYM is an ugly hack to get macros to work.


> Lisp-2 and GENSYM are attempting to solve the same issue in two different use cases.

Now this is… post-hoc, Lisp-2 is the original form of LISP and predates the concepts of macros.

> And, if I may add, GENSYM looks a bit lazy and half-assed next to the scortch-the-earth multiple namespaces of Lisp-2.

I would agree. However in reality we have a system that is half-assed vs a system that nobody likes to use.


> predates the concepts of macros

Though LISP macros are quite old, from around 1962...


It's somewhat orthogonal, yes, but a lisp-1 just has more ways to run into the name collision.


Most schemes have a gensym as a part of their lower level macro facilities. It is a part of r6rs (which at least has generate-temporaries, I don't know if gensym is actually standard. All schemes I have used have it).


I miss Eric Naggum. His rants were absolutely epic. I was terrified of inadvertently offending him on comp.lang.lisp so I always thought extremely carefully before posting anything :)


I think he was a bully. An intelligent bully, but still a bully. For example: He told me I should get a late abortion (as in suicide) when I as a 14 year old disagreed with him about guaranteed tail recursion. Now, it sounded a bit better in norwegian, but still a pretty horrible thing to say.

His spirit lived (lives?) on for a long time, and it made staring common lisp a much shittier experience.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: