Consider the following code:
(defmacro somemacro []
(list 'let ['somevar "Value"] 'somevar))
(macroexpand '(somemacro))
Result:
(let* [somevar "Value"] somevar)
What does let* mean? Unluckily, it does not seem to be documented anywhere... As a helpful member of StackOverflow explained to me, let* is used to implement let. The addition of let vs. let*, is that let is capable of destructuring the parameters, which let* does not do. Consider the following example:
(let [[a b c & d :as e] [1 2 3 4 5 6 7]] [a b c d e])Result:
[1 2 3 (4 5 6 7) [1 2 3 4 5 6 7]]
(let* [[a b c & d :as e] [1 2 3 4 5 6 7]] [a b c d e])Result:
CompilerException java.lang.IllegalArgumentException: Bad binding form, expected symbol, got: [a b c & d :as e], compiling:(NO_SOURCE_PATH:1:1)
No comments:
Post a Comment