4 ms·
They're pure convenience, but they're pretty convenient. It's very common to have patterns like: (let ((result (do-some-calculation))) (when result
by girzel 8y ago
They're pure convenience, but they're pretty convenient. It's very common to have patterns like:
(let ((result (do-some-calculation)))
(when result
(operate-on result)))
`when-let' would just skip one "layer" of code, and I believe avoid assigning a local variable if (do-some-calculation) fails. Just a convenience.
(edit: trying to fix formatting)
- girzel 8y agoNever mind, it still binds a local variable (at least in elisp, where I just tried it).
- dreamcompiler 8y agoIt has to, otherwise it would have to execute the initform twice.
- girzel 8y agoYeah, that finally clicked afterwards...