If it's for side-effects, then using _ is fine, in my opinion—they're
nicely identifiable.
They're especially useful for inserting println calls for seeing the
value of something when I'm debugging; in fact, this is the primary
way I do debugging. I would say, though, that usually if you're going
to truly do side-effects, it's better to isolate them as much as
possible, rather than interspersing them within essential logic.
I've seen the
(let [x ...
x (... x ...)
x (... x ...)
x (... x ...)]
x)
notation before, and it is fine. For my tastes, however, I think that
it repeats the symbol (in this case, 'x) too much. Sometimes it may be
the best way, but usually I would instead use ->, ->>, and/or letfn.
On Dec 10, 9:05 am, David Brown <[email protected]> wrote:
> On Thu, Dec 10, 2009 at 09:26:07AM -0500, Graham Fawcett wrote:
> >(let [x 1
> > _ (f x)
> > y (+ x 2)
> > _ (g y)]
> > ...)
>
> What do people in general think of this style? I remember using this
> trick a lot with O'Caml, and I've certainly used it a few times in
> Clojure, but something feels icky about it.
>
> Where it's most useful, though is with stuff like this:
>
> (let [x ...
> y ...
> _ (prn "y is" y)
> ...]
> ...)
>
> I have found I sometimes find something like:
>
> (let [x ...
> x (... x ...)
> x (... x ...)
> x (... x ...)]
> x)
>
> easier to write, even if it is just how I write it the first time, and
> then later change it to something looking more like function
> application. Sometimes, I've found the let-chain is easier to modify
> in the future.
>
> I guess, realizing it's still not imperative (necessarily), it
> shouldn't bother me as much.
>
> David
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en