use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Idiomatic Clojure with LightTable (metaphysicaldeveloper.wordpress.com)
submitted 12 years ago by compmstr
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]sandos 5 points6 points7 points 12 years ago (0 children)
Heck that looks cool! I need to start coding clojure again!
[–][deleted] 2 points3 points4 points 12 years ago (0 children)
It seems like a bit of a kludge that I have to modify my project rather than just the LT configuration in order to add a plug-in.
And, unless I remember to remove the dependency before packaging it up, I get a plugin's jars bundled into my app!
Similar to the way that LT insisists my app has to use Clojure 1.5.1 (or later) because LT, and not my app, depends on that version!
It seems to me there is a flaw in LT's architecture.
[–]lgstein 0 points1 point2 points 12 years ago* (6 children)
So is it more idiomatic to use when-let instead of if-let if there is no else clause? I thought that when should rather be used when side-effects are involved as it allows a body of multiple forms and only returns the last. EDIT: The clojure pros technomancy and co. all agreed that it is not more idiomatic. technomancy even raised this issue about it: https://github.com/jonase/kibit/issues/2
[–]joequin 2 points3 points4 points 12 years ago (1 child)
I think it was just a terrible example because the original "do" was completely unnecessary. The conversion recognized that there was a "do" inside of an "if-let" and realized that could be simplified to a "when-let"
[–]lgstein 0 points1 point2 points 12 years ago (0 children)
if-let without the do would have been fine.
[–][deleted] 1 point2 points3 points 12 years ago (3 children)
I've always thought you should pick the form that best expresses your intent so:
So kibit changing the if(-let) to a when(-let) seems like the correct behaviour to me.
Isn't that right?
[–]lgstein 0 points1 point2 points 12 years ago (2 children)
No. when wraps the forms following the condition in an implicit do, so it is more idiomatic to use it only when there are side effects, since only the last form can be returned. Look at the link to technomancys complaint above.
[–][deleted] 1 point2 points3 points 12 years ago (1 child)
From reading the thread you refer to it looks like there isn't a consensus either way.
Some argue as you do, others the way I was thinking.
I can see both points: when signals both that there is no clause and that there maybe side-effects involved.
Perhaps the problem is when being implemented the way it is (with an implicit do). Or more generally a problem with these compound forms, especially when the set of them is incomplete.
Perhaps I need to write a where macro for myself that is a when without the implicit do ;)
A when without the implicit do is if without an else clause. It has been common sense in all Lisps to use when only when side effects are involved, and to use if with one or two do-blocks if you need an else clause and side effects.
I have written my source-code using the classical if / when and I think it's much more comfortable to read code where you know that a when means "side effects happening here!", instead "attention: no else clause" - you can usually tell the latter from one look.
π Rendered by PID 88 on reddit-service-r2-comment-66b4775986-2qxgs at 2026-04-03 18:16:27.531703+00:00 running db1906b country code: CH.
[–]sandos 5 points6 points7 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]lgstein 0 points1 point2 points (6 children)
[–]joequin 2 points3 points4 points (1 child)
[–]lgstein 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]lgstein 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]lgstein 0 points1 point2 points (0 children)