On 2012-10-18, at 2:11 PM, Evan Gamble wrote:
> For the situation where the lets are nested because you're checking the
> values in some way after each binding, I wrote a macro called let?. I find it
> very useful and use it in nearly all my code.
> https://github.com/egamble/let-else
Hmmm,
OK, just looked it up and realized that it's just how # works, and not a
special kind of macro.
On Thu, Oct 18, 2012 at 5:25 PM, Mark Engelberg wrote:
> On Thu, Oct 18, 2012 at 4:11 PM, Herwig Hochleitner <
> hhochleit...@gmail.com> wrote:
>
>>
>> FWIW, when just wanting to print out debug values
On Thu, Oct 18, 2012 at 4:11 PM, Herwig Hochleitner
wrote:
>
> FWIW, when just wanting to print out debug values, I use a custom reader
> tag similar to the above macro:
>
> (let [x #log/spy (+ a b)]
> (usage-of x))
>
>
>
That's nice! I haven't done anything with reader macros. Can you post th
2012/10/18 Mark Engelberg
> When I want to add print commands for debugging, I usually either do it
> the way David Nolen described, i.e., binding _ to a printf statement, or I
> use a little utility macro like this (picked up from stackoverflow):
>
> (defmacro dbg[x] `(let [x# ~x] (println "dbg:
It's slightly different, but libraries such as Flow or Prismatic's Graph
can be used to achieve a similar effect.
Flow: https://github.com/stuartsierra/flow
Graph:
http://blog.getprismatic.com/blog/2012/10/1/prismatics-graph-at-strange-loop.html
Example using Flow:
(def the-flow
(flow b ([a]
deja-vu :)
On Thu, Oct 18, 2012 at 11:16 PM, JvJ wrote:
>
> On a side note, I was partially inspired by Haskell's do notation, which
> is imperative-looking syntactic sugar for monadic bind operators.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure"
On Thu, Oct 18, 2012 at 1:45 PM, Grant Rettke wrote:
>
> Anyone voted for internal define lately?
>
On the one hand, internal define would be nice because it would help
alleviate the nested let problem and possibly be more intuitive for
newcomers.
On the other hand, sometimes (rarely) you actua
The doto form is great, but as far as I know, it only lets you thread a
single object. I'm looking at creating several objects consecutively.
On Thursday, 18 October 2012 17:11:08 UTC-4, Grant Rettke wrote:
>
> I figured you would use doto for that.
>
> On Thu, Oct 18, 2012 at 4:09 PM, JvJ >
>
Most of what could be accomplished by an internal define could be done with
a let statement. But if you don't want to add the brackets, you can create
your own function definition macro that converts defs to lets.
On Thursday, 18 October 2012 17:12:04 UTC-4, Grant Rettke wrote:
>
> On Thu, Oct
On a side note, I was partially inspired by Haskell's do notation, which is
imperative-looking syntactic sugar for monadic bind operators.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
On a side note, I was partially inspired by Haskell's do notation, which is
imperative-looking syntactic sugar for monadic binds.
On Thursday, 18 October 2012 12:01:33 UTC-4, JvJ wrote:
>
> I'm not sure if anyone's done this before, but I'm fed up with writing
> code that looks like this:
>
> (l
On Thu, Oct 18, 2012 at 4:05 PM, David Nolen wrote:
> On Thu, Oct 18, 2012 at 4:45 PM, Grant Rettke wrote:
>> Anyone voted for internal define lately?
> At this point I think it's highly unlikely to change - the behavior is
> pretty well documented:
I see. Just a thought that an internal define
I figured you would use doto for that.
On Thu, Oct 18, 2012 at 4:09 PM, JvJ wrote:
> Exactly. Not only debugging, but java interop that involved calling methods
> with side effects.
>
> On Thursday, 18 October 2012 15:02:47 UTC-4, David Nolen wrote:
>>
>> On Thu, Oct 18, 2012 at 2:55 PM, Alan Ma
Exactly. Not only debugging, but java interop that involved calling
methods with side effects.
On Thursday, 18 October 2012 15:02:47 UTC-4, David Nolen wrote:
>
> On Thu, Oct 18, 2012 at 2:55 PM, Alan Malloy
> > wrote:
>
>> It's rare to get tired of this, because nobody does it: it's not
>> com
On Thu, Oct 18, 2012 at 4:45 PM, Grant Rettke wrote:
> On Thu, Oct 18, 2012 at 3:45 PM, Grant Rettke wrote:
> > On Thu, Oct 18, 2012 at 3:42 PM, Mark Engelberg
> > wrote:
> >> A def, even inside defn, creates and binds a global variable.
> >
> > Woa, I see, thanks!
>
> Anyone voted for internal
On Thu, Oct 18, 2012 at 3:45 PM, Grant Rettke wrote:
> On Thu, Oct 18, 2012 at 3:42 PM, Mark Engelberg
> wrote:
>> A def, even inside defn, creates and binds a global variable.
>
> Woa, I see, thanks!
Anyone voted for internal define lately?
--
You received this message because you are subscri
On Thu, Oct 18, 2012 at 3:42 PM, Mark Engelberg
wrote:
> A def, even inside defn, creates and binds a global variable.
Woa, I see, thanks!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
A def, even inside defn, creates and binds a global variable.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
f
On Thu, Oct 18, 2012 at 3:32 PM, David Nolen wrote:
> On Thu, Oct 18, 2012 at 4:22 PM, Grant Rettke wrote:
>>
>>
>> When you use def inside a defn is it equivalent to a let binding like
>> this?
>>
>> (defn foo []
>> (def a 1)
>> (println a))
>>
>> (defn foo []
>> ((fn [a]
>> (println
On Thu, Oct 18, 2012 at 4:22 PM, Grant Rettke wrote:
>
> When you use def inside a defn is it equivalent to a let binding like this?
>
> (defn foo []
> (def a 1)
> (println a))
>
> (defn foo []
> ((fn [a]
> (println a)) 1))
Not equivalent.
--
You received this message because you a
On Thu, Oct 18, 2012 at 3:17 PM, David Nolen wrote:
>
> On Thu, Oct 18, 2012 at 4:15 PM, Grant Rettke wrote:
>>
>> On Thu, Oct 18, 2012 at 2:50 PM, Mark Engelberg
>> wrote:
>> > Either way works well. I think Evan's way results in somewhat more
>> > compact
>> > code for the common case, wherea
On Thu, Oct 18, 2012 at 4:15 PM, Grant Rettke wrote:
> On Thu, Oct 18, 2012 at 2:50 PM, Mark Engelberg
> wrote:
> > Either way works well. I think Evan's way results in somewhat more
> compact
> > code for the common case, whereas Cgrand's way feels a little more
> versatile
> > (and his "flatt
On Thu, Oct 18, 2012 at 2:50 PM, Mark Engelberg
wrote:
> Either way works well. I think Evan's way results in somewhat more compact
> code for the common case, whereas Cgrand's way feels a little more versatile
> (and his "flatter cond" is what I use). I strongly urge you to pick one of
> these
When I want to add print commands for debugging, I usually either do it the
way David Nolen described, i.e., binding _ to a printf statement, or I use
a little utility macro like this (picked up from stackoverflow):
(defmacro dbg[x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))
I agree with Eva
On Oct 18, 12:02 pm, David Nolen wrote:
> On Thu, Oct 18, 2012 at 2:55 PM, Alan Malloy wrote:
> > It's rare to get tired of this, because nobody does it: it's not
> > common because your interleaved statements are side-effecting only,
> > which is not encouraged in Clojure, and rarely needed. Cer
On Thu, Oct 18, 2012 at 2:09 PM, Ben Wolfson wrote:
> On Thu, Oct 18, 2012 at 12:01 PM, Grant Rettke wrote:
>> It isn't side effecting it is sequencing.
>
> Clojure's let is already sequential, like Scheme's let*: "The bindings
> are sequential, so each binding can see the prior bindings." R5RS
>
On Thu, Oct 18, 2012 at 2:07 PM, David Nolen wrote:
> On Thu, Oct 18, 2012 at 3:06 PM, Grant Rettke wrote:
>>
>> (-> ((fn []
>> (let [a 1]
>> (println "this is a: " a)
>> a)))
>>((fn [a]
>> (let [b 2]
>> (println "this is b: " b)
>> (list a b
>>
On Thu, Oct 18, 2012 at 12:01 PM, Grant Rettke wrote:
> On Thu, Oct 18, 2012 at 1:55 PM, Alan Malloy wrote:
>> It's rare to get tired of this, because nobody does it: it's not
>> common because your interleaved statements are side-effecting only,
>> which is not encouraged in Clojure, and rarely
On Thu, Oct 18, 2012 at 3:06 PM, Grant Rettke wrote:
> (-> ((fn []
> (let [a 1]
> (println "this is a: " a)
> a)))
>((fn [a]
> (let [b 2]
> (println "this is b: " b)
> (list a b
>((fn [[a b]]
> (let [c 3]
> (println "this is c:
On Thu, Oct 18, 2012 at 1:32 PM, Grant Rettke wrote:
> On Thu, Oct 18, 2012 at 11:11 AM, David Nolen wrote:
>> On Thu, Oct 18, 2012 at 12:01 PM, JvJ wrote:
>>>
>>> I'm not sure if anyone's done this before, but I'm fed up with writing
>>> code that looks like this:
>>
>>
>> What problem does thi
On Thu, Oct 18, 2012 at 2:55 PM, Alan Malloy wrote:
> It's rare to get tired of this, because nobody does it: it's not
> common because your interleaved statements are side-effecting only,
> which is not encouraged in Clojure, and rarely needed. Certainly
> sometimes it's the best way to do somet
On Thu, Oct 18, 2012 at 1:55 PM, Alan Malloy wrote:
> It's rare to get tired of this, because nobody does it: it's not
> common because your interleaved statements are side-effecting only,
> which is not encouraged in Clojure, and rarely needed. Certainly
> sometimes it's the best way to do someth
It's rare to get tired of this, because nobody does it: it's not
common because your interleaved statements are side-effecting only,
which is not encouraged in Clojure, and rarely needed. Certainly
sometimes it's the best way to do something, but not so often that I'd
become frustrated; if anything
On Thu, Oct 18, 2012 at 11:11 AM, David Nolen wrote:
> On Thu, Oct 18, 2012 at 12:01 PM, JvJ wrote:
>>
>> I'm not sure if anyone's done this before, but I'm fed up with writing
>> code that looks like this:
>
>
> What problem does this solve given you can do the following?
>
> (let [a 1
> _
For the situation where the lets are nested because you're checking the
values in some way after each binding, I wrote a macro called let?. I find
it very useful and use it in nearly all my
code. https://github.com/egamble/let-else
--
You received this message because you are subscribed to the
Thank you for this clarification!
On Thu, Oct 18, 2012 at 6:26 PM, David Nolen wrote:
> On Thu, Oct 18, 2012 at 12:23 PM, JvJ wrote:
>
>> I didn't realize you could bind to empty identifiers like that. Alright,
>> that makes more sense. I figured I was missing something.
>>
>
> Just to be cle
There's nothing special going on, no "empty" identifiers. It's just a
common convention to use _ when uninterested in the return value.
(let [_ 1]
_)
;=> 1
Pretty evil to actually use bindings called _ though :)
Thanks,
Ambrose
On Fri, Oct 19, 2012 at 12:23 AM, JvJ wrote:
> I didn't realize
On Thu, Oct 18, 2012 at 12:23 PM, JvJ wrote:
> I didn't realize you could bind to empty identifiers like that. Alright,
> that makes more sense. I figured I was missing something.
>
Just to be clear _ has not special meaning beyond convention. I could have
used x but that doesn't convey that w
Exactly. A big part of the reason was that I needed to do things between
when other variables were initialized.
On Thursday, 18 October 2012 12:17:17 UTC-4, Ben wrote:
>
> On Thu, Oct 18, 2012 at 9:12 AM, keeds >
> wrote:
> > I'm confused. How does the following not work?
> >
> > (let [a 1 b
I didn't realize you could bind to empty identifiers like that. Alright,
that makes more sense. I figured I was missing something.
On Thursday, 18 October 2012 12:11:49 UTC-4, David Nolen wrote:
>
> On Thu, Oct 18, 2012 at 12:01 PM, JvJ >wrote:
>
>> I'm not sure if anyone's done this before, bu
On Thu, Oct 18, 2012 at 9:12 AM, keeds wrote:
> I'm confused. How does the following not work?
>
> (let [a 1 b 2 c 3]
> (println a)
> (println b)
> (println c)
> (+ a b c))
It works, but all of the expressions on the RHS of the let
expression's binding vector have to be applied before you
I'm confused. How does the following not work?
(let [a 1 b 2 c 3]
(println a)
(println b)
(println c)
(+ a b c))
On Thursday, October 18, 2012 5:01:33 PM UTC+1, JvJ wrote:
>
> I'm not sure if anyone's done this before, but I'm fed up with writing
> code that looks like this:
>
> (let [a
On Thu, Oct 18, 2012 at 12:01 PM, JvJ wrote:
> I'm not sure if anyone's done this before, but I'm fed up with writing
> code that looks like this:
>
What problem does this solve given you can do the following?
(let [a 1
_ (println a)
b 2
_ (println b)
c 3
_ (printl
I'm not sure if anyone's done this before, but I'm fed up with writing code
that looks like this:
(let [a 1]
(println "this is a: " a)
(let [b 2]
(println "this is b: " b)
(let [c 3]
(println "this is c: " c)
(+ a b c
I'd rather do something more l
I'm not sure if anyone's already done this, but I recently got tired of
writing code that looked like this:
(let [a 1]
(ns cljutils.core)
(defn- form-check
"Ensures the form represents an assignment.
Such as (:= a 1)"
[form]
(and
(= 3 (count form))
(= := (first form))
(symbol?
45 matches
Mail list logo