by frankpf · 6y ago · 0 comments
(defn greet [firstname lastname]
(def fullname (string firstname " " lastname))
(string "Hello, " fullname))
In other lisps, you'd have the last expression nested inside a `let` block: (defn greet [firstname lastname]
(let [fullname (string firstname " " lastname)]
(string "Hello, " fullname)))
which makes the code hard to read and edit IMO. Languages like Haskell and OCaml suffer from a similar problem too.That's interesting, I've always really loved the "return last expression in a block" syntax. (Ruby and Rust can be added to your list as well.) That syntax just reads really naturally to me.
(defun greet (firstname lastname &aux fullname)
(setf fullname (format nil "~a ~a" firstname lastname))
(format nil "Hello, ~a" fullname))CL has an implicit body, but does not allow defining new bindings outside of some dedicated forms (let, etc.). I really prefer having to write "let" forms instead of having new variables added inside the body.