clojure-doc

jdjohnston 2024-10-12T02:28:30.350539Z

The unless first macro in the macro guide seems a little misleading. From the text one would be surprised to learn that Clojure already has if-not. I actually like the name unless better, but I wouldn't write a macro just to scratch that itch. Might be worth a note in the text that, while unless is an easy example, Clojure already has if-not.

seancorfield 2024-10-12T03:15:10.480679Z

True. And if-not is mentioned in the Introduction, but I think normally unless is closer to when-not in most languages?

seancorfield 2024-10-12T03:15:42.367369Z

I'll create an issue and do some research on unless elsewhere and update things accordingly...

jdjohnston 2024-10-12T06:57:44.423669Z

Good catch on unless being more like when-not. I guess it was the way it was presented in the guide that threw me off. The CLHS documents WHEN and UNLESS on the same page. Either way, reimplementing a core macro does seem a questionable way to introduce macros.

jdjohnston 2024-10-12T07:33:10.636349Z

BTW, you wrote "`if-not` is mentioned in the Introduction". Mostly out of curiosity, what Introduction? Where is if-not mentioned?

seancorfield 2024-10-12T16:41:06.310229Z

At the end of this section of the Introduction to Clojure https://clojure-doc.org/articles/tutorials/introduction/#side-effects

jdjohnston 2024-10-12T16:48:22.814359Z

Thanks! Found it. I was refreshing my memory as to whether Clojure macros were considered hygienic, so I went straight to the macro guide. I doubt many read the guides front-to-back, but they are useful.

jdjohnston 2024-10-12T16:49:26.820419Z

*hygenic

jdjohnston 2024-10-12T16:51:42.527159Z

*Oops, had it right in the first place: hygienic

jdjohnston 2024-10-12T16:59:58.572799Z

BTW, I liked the mention of clojure.walk/macroexpand-all. I either missed that one all these years or had forgotten about it. Good debugging tool.

seancorfield 2024-10-12T17:15:15.987909Z

For the most part, for the target audience for clojure-doc, the issue of hygienic vs anaphoric etc isn't really relevant. Clojure encourages using functions over macros wherever possible, hence the joke that "The first rule of Macro Club is, don't write macros!"...

seancorfield 2024-10-12T17:15:40.461239Z

http://clojure.org hardly mentions the topic at all (and, to be honest, says very little about macros anyway).