Consider the following macro:
(defmacro somemacro []
(list 'let ['somevar "Value"] 'somevar))
Expanding it yields the following result:
(macroexpand '(somemacro))
Result:
(let* [somevar "Value"] somevar)
I have two questions about let* (with the asterisk):
- What does it mean? (In particular: is it documented somewhere?)
- Why is the macro not expanded with the 'normal' let? (I.e., let without the asterisk.) Both yield the same result (in my experimentation). Is there a counter example?
Unluckily I could not find any 'official' documentation about let*, that's why I'm asking here.
Sources I've already considered:
(doc let*) ; --> nil
(source let*) ; --> source not found
- https://clojuredocs.org/clojure.core --> I see not let* here (although there is e.g. list*)
- https://clojuredocs.org/clojure.core/let --> only mentioned once in
a comment, that is not totally clear to me:
Nota Bene: let in Clojure is like let* in Scheme -- each init-expr has access to the preceding binding forms. (There is also a let*, but it is more or less let without destructuring, and in fact is the underlying implementation.)
- LET versus LET* in Common Lisp --> this question is about common lisp, but maybe it's the same in Clojure?
- This answer: https://stackoverflow.com/a/5084339/3398271
In Clojure it basically means "foo* is like foo, but somehow different, and you probably want foo". In other words, it means that the author of that code couldn't come up with a better name for the second function, so they just slapped a star on it.
--> Is this the case for let and let*? But if so, still the question remains, what is exactly the difference?
- What is the difference between let and let* in Scheme? --> Is this the same in Clojure?