For those who use clojure.tools.logging, there's also the handy spy
function.
On Tuesday, October 15, 2013 6:41:38 PM UTC-7, dgrnbrg wrote:
If this is something you do often, spyscope is a library I wrote to
simplify this sort of investigation. You can print an expression by writing
#spy/d
In CL, `let*` works like Clojure's `let`, in that both allow you to bind
later variables to valued calculated from earlier ones. (CL's `let` only
allows references to things defined before entering the `let`.) A couple
of years ago I was hacking on some CL code originally written by someone
Lifting subexpressions up into lets is actually something I do a lot- for
one very important reason: it lets me insert print statements (or logging
statements) showing the value of the subexpression. So I'll do;
(let [ x (subexpression) ]
(main-expression))
because it lets me do:
if a programming language doesn't have something like 'where', then i
am sad. http://stackoverflow.com/questions/4362328/haskell-where-vs-let
--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
I and some of my coworkers do tend to avoid `let` unless in this particular
case you especially want to emphasize the name of something unobvious.
OFten I'd prefer to pull out a new function over using let, or inline the
binding for readability *improvement*.
On Tue, Oct 15, 2013 at 8:18 AM,
Yeah, I found when I first got started with Clojure I tended to use
let for intermediate named results but over time I've moved to using
small, private top-level functions instead because I want to focus on
the names of the _functionality_ rather than the names of intermediate
_data_. I still use
How looks this?
(defn conditional [x condition consequent alternative]
(if (condition x)
(consequent x)
(alternative x
(conditional (some-expression) p f g)
Am 15.10.2013 19:02, schrieb Sean Corfield:
Yeah, I found when I first got started with Clojure I tended to use
let for
Sean,
The case you listed is where let binding becomes important so as to not
perform duplicate evaluation. That is one place the utility of let stands
out along with its scope.
For example
Without let bindings:
(if (p (some-expression))
(f (some-expression))
(g (some-expression))
I know how to write it but I just don't like that name (or any other
I've come up with yet). And I'd probably put the `x` as the last
argument and provide a curried version.
On Tue, Oct 15, 2013 at 10:13 AM, Marcus Lindner
marcus.goldritter.lind...@gmail.com wrote:
How looks this?
(defn
On Tue, Oct 15, 2013 at 10:15 AM, Guru Devanla grd...@gmail.com wrote:
The case you listed is where let binding becomes important so as to not
perform duplicate evaluation. That is one place the utility of let stands
out along with its scope.
Yup, exactly. I just see it often enough that I
On 15/10/13 18:02, Sean Corfield wrote:
One construct using let that I see in my code quite a bit that I
haven't figured out a cleaner way to express:
(let [x (some-expression)]
(if (p x)
(f x)
(g x)))
wasn't cond- designed exactly for that?
(let [x (some-expression)]
(cond- x
On Tue, Oct 15, 2013 at 10:19 AM, Jim - FooBar(); jimpil1...@gmail.com wrote:
wasn't cond- designed exactly for that?
(let [x (some-expression)]
(cond- x
(p x) f
((comlpement p) x) g)))
That's uglier than the if :)
Sometimes I wish there was a variant of cond- that took functions
What about let-some-expression-if-then-else?
From: clojure@googlegroups.com [clojure@googlegroups.com] on behalf of Sean
Corfield [seancorfi...@gmail.com]
Sent: 15 October 2013 18:02
To: clojure@googlegroups.com
Subject: Re: is PG's imperative outside
On Tue, Oct 15, 2013 at 10:48 AM, Sean Corfield seancorfi...@gmail.comwrote:
On Tue, Oct 15, 2013 at 10:19 AM, Jim - FooBar(); jimpil1...@gmail.com
wrote:
wasn't cond- designed exactly for that?
(let [x (some-expression)]
(cond- x
(p x) f
((comlpement p) x) g)))
That's
On 2013-10-15, at 8:29 AM, Daniel Higginbotham nonrecurs...@gmail.com wrote:
I've been going through On Lisp by Paul Graham and on page 33 he recommends
against performing intermediate bindings. Does this advice hold for
Clojure? Here are a couple examples:
;; Common Lisp (from the book)
Thanks for all the responses!
This discussion will definitely help me write better code. This was
especially helpful:
over time I've moved to using
small, private top-level functions instead because I want to focus on
the names of the _functionality_ rather than the names of intermediate
16 matches
Mail list logo