Re: Boolean

2012-04-13 Thread Stefan Kamphausen


> Hope I've made my point clear now.
>

Maybe helping here... 

To anyone with some understanding of programming and a basic understanding 
how `if' looks like in lisps the following lines would be at least 
astonishing

 user=> (if some-thing "then" "else")
 "then"
 user=> (if (= some-thing false) "then" "else")
 "then"

How can some-thing evaluate to true but be equal (in whatever sense = 
defines equality) to false?  

IMHO it looks like some inconsistency in the contract between truthiness 
and equality.

(And yes, I understand the argument that (Boolean. false) is an object and 
thus true; it's just the combination of both that I find very irritating.)

Kind regards,
Stefan

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ClojureScript function params shadow top-level namespace segments

2012-04-13 Thread Stuart Campbell
Given the following ClojureScript:

(ns foo)
(defn bar [] 42)

(ns baz
  (:require [foo :as x]))

(defn quux [foo]
  (x/bar))

baz.quux compiles to:

baz.quux = function quux(foo) {
  return foo.bar.call(null)
};

i.e. the parameter name shadows the top-level "foo" namespace.

Is that a bug?

Regards,
Stuart

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Boolean

2012-04-13 Thread Stefan Kamphausen
According to e.g.

 http://nathanmarz.com/blog/fun-with-equality-in-clojure.html

it's a speed trade-off.  Something one can live with, but a wart 
nevertheless.

Best,
Stefan


-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Boolean

2012-04-13 Thread Tassilo Horn
Stefan Kamphausen  writes:

> According to e.g.
>
>  http://nathanmarz.com/blog/fun-with-equality-in-clojure.html
>
> it's a speed trade-off.

Partly.  See Daniel's post where he fixed my contrieved micro-benchmark
and showed that testing on Boolean-equality in `if` slows that down
about a factor of 20.

> Something one can live with, but a wart nevertheless.

Well, since even the Boolean JavaDocs say "it is rarely appropriate to
use this [the Boolean(boolean)] constructor", I don't think it's worth a
slowdown.

Bye,
Tassilo

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Boolean

2012-04-13 Thread Tassilo Horn
Stefan Kamphausen  writes:

> To anyone with some understanding of programming and a basic
> understanding how `if' looks like in lisps the following lines would
> be at least astonishing

Other lisps (I know of) don't have this problem, because in Common Lisp
or Emacs Lisp, nil is the only false value, and there's no way to create
a new nil value that's not identical to nil.  Scheme is similar in
having only #t and #f as boolean values with no possibility of creating
new instances of #t and #f.

>  user=> (if some-thing "then" "else")
>  "then"
>  user=> (if (= some-thing false) "then" "else")
>  "then"
>
> How can some-thing evaluate to true but be equal (in whatever sense =
> defines equality) to false?

some-thing doesn't evaluate to true, it evaluates to *logical* true,
i.e., it is neither nil or false (where *is* means identity).

Bye,
Tassilo

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Loading a huge graph

2012-04-13 Thread László Török
Thanks,

having a C++ background, there is definitely a lot to learn about the JVM.

I'm wrote a script in Python that ran in about 10-12s and used up to 320MB
of memory.

I'm running a clojure repl from Emacs via jack-in.

What's the best way to adjust the heap size? swank-clojure and clojure-mode
don't say.

If I spin up the repl via lein swank, I can use the LEIN_JVM_OPTS, however
it affects only one of the JVMs started by lein swank, the one with jline.

Any advice? :)


2012/4/13 Alex Robbins 

> Yeah, sounds like it could definitely be a memory issue. This is one
> part where the JVM works a lot differently than I expected coming from
> a python background.
>
> Everybody may already know this, but the JVM only takes 64mb for the
> heap by default. You'll get an out of memory error if your program
> uses more than that. In contrast, python just takes all the memory it
> needs. As your program gets closer to the JVM memory limit it'll spend
> more and more time doing garbage collection, with less and less real
> work getting done. You can pass an -Xmx flag to give java access to
> more memory, which many (most?) programs do.
>
>
> On Thu, Apr 12, 2012 at 5:22 PM, David Nolen 
> wrote:
> > How much memory do Python & Go consume when you do this? Are you giving
> the
> > JVM enough memory?
> >
> >
> > On Thu, Apr 12, 2012 at 6:17 PM, László Török 
> wrote:
> >>
> >> Hi,
> >>
> >> I'm trying figure out how to load a huge file that contains some 800k
> pair
> >> of integers (two integers per line) which represent edges of a directed
> >> graph.
> >>
> >> So if the ith line has x and y, it means that there is an edge between x
> >> and y vertex in the graph.
> >>
> >> The goal is to load it in an array of arrays representation, where the
> kth
> >> array contains all the nodes, where there is a directed edge from the
> kth
> >> node to those nodes.
> >>
> >> I've attempted multiple variants of with-open reader and line-seq etc.
> but
> >> almost always ended up with OutMemoryException or sg VERY slow.
> >>
> >> My latest attempt that also does not work on the large input:
> >>
> >> (defn load-graph [input-f]
> >>   (with-open [rdr (io/reader input-f)]
> >> (->> (line-seq rdr)
> >> (map (fn [row]
> >>(let [[v1str v2str] (str/split row #"\s")]
> >>[ (Integer/parseInt v1str) (Integer/parseInt v2str)
> ]))
> >>   )
> >> (reduce (fn [G [v1 v2]]
> >>   (if-let [vs (get G v1)]
> >> (update-in G [v1] #(conj % v2))
> >> (assoc G v1 [v2])))  { }  
> >>
> >> I'm getting a bit frustrated as there are Python, Go implementations
> that
> >> load the graph in less the 5 seconds.
> >>
> >> What am I doing wrong?
> >>
> >> Thanks
> >>
> >> --
> >> László Török
> >>
> >> --
> >> 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 first post.
> >> To unsubscribe from this group, send email to
> >> clojure+unsubscr...@googlegroups.com
> >> For more options, visit this group at
> >> http://groups.google.com/group/clojure?hl=en
> >
> >
> > --
> > 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
> > first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
>
> --
> 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 first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
László Török

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: [ANN] Leiningen 2.0.0-preview3

2012-04-13 Thread nick rothwell
Trivial bug report: saying

lein new

throws an ArityException rather than reporting an error and suggesting 
usage.

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Loading a huge graph

2012-04-13 Thread bOR_
I have this option in my project.clj file, which does the trick if you are 
developing from emacs+swank+clojure-jack-in, and using large networks

  :jvm-opts ["-Xmx4000m"]

And yes, one of the things to do when working with the jvm is learning how 
to use jconsole or visualvm to see why your program is slow :-), and know 
how to adapt the jvm options. If I remember correctly, java 1.7 has an 
option for a more flexible heap size, which might be a nice default.


On Friday, 13 April 2012 10:32:24 UTC+2, Las wrote:
>
> Thanks,
>
> having a C++ background, there is definitely a lot to learn about the JVM.
>
> I'm wrote a script in Python that ran in about 10-12s and used up to 320MB 
> of memory.
>
> I'm running a clojure repl from Emacs via jack-in.
>
> What's the best way to adjust the heap size? swank-clojure and 
> clojure-mode don't say.
>
> If I spin up the repl via lein swank, I can use the LEIN_JVM_OPTS, however 
> it affects only one of the JVMs started by lein swank, the one with jline.
>
> Any advice? :)
>
>
> 2012/4/13 Alex Robbins 
>
>> Yeah, sounds like it could definitely be a memory issue. This is one
>> part where the JVM works a lot differently than I expected coming from
>> a python background.
>>
>> Everybody may already know this, but the JVM only takes 64mb for the
>> heap by default. You'll get an out of memory error if your program
>> uses more than that. In contrast, python just takes all the memory it
>> needs. As your program gets closer to the JVM memory limit it'll spend
>> more and more time doing garbage collection, with less and less real
>> work getting done. You can pass an -Xmx flag to give java access to
>> more memory, which many (most?) programs do.
>>
>>
>> On Thu, Apr 12, 2012 at 5:22 PM, David Nolen  
>> wrote:
>> > How much memory do Python & Go consume when you do this? Are you giving 
>> the
>> > JVM enough memory?
>> >
>> >
>> > On Thu, Apr 12, 2012 at 6:17 PM, László Török  
>> wrote:
>> >>
>> >> Hi,
>> >>
>> >> I'm trying figure out how to load a huge file that contains some 800k 
>> pair
>> >> of integers (two integers per line) which represent edges of a directed
>> >> graph.
>> >>
>> >> So if the ith line has x and y, it means that there is an edge between 
>> x
>> >> and y vertex in the graph.
>> >>
>> >> The goal is to load it in an array of arrays representation, where the 
>> kth
>> >> array contains all the nodes, where there is a directed edge from the 
>> kth
>> >> node to those nodes.
>> >>
>> >> I've attempted multiple variants of with-open reader and line-seq etc. 
>> but
>> >> almost always ended up with OutMemoryException or sg VERY slow.
>> >>
>> >> My latest attempt that also does not work on the large input:
>> >>
>> >> (defn load-graph [input-f]
>> >>   (with-open [rdr (io/reader input-f)]
>> >> (->> (line-seq rdr)
>> >> (map (fn [row]
>> >>(let [[v1str v2str] (str/split row #"\s")]
>> >>[ (Integer/parseInt v1str) (Integer/parseInt v2str) 
>> ]))
>> >>   )
>> >> (reduce (fn [G [v1 v2]]
>> >>   (if-let [vs (get G v1)]
>> >> (update-in G [v1] #(conj % v2))
>> >> (assoc G v1 [v2])))  { }  
>> >>
>> >> I'm getting a bit frustrated as there are Python, Go implementations 
>> that
>> >> load the graph in less the 5 seconds.
>> >>
>> >> What am I doing wrong?
>> >>
>> >> Thanks
>> >>
>> >> --
>> >> László Török
>> >>
>> >> --
>> >> 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 first post.
>> >> To unsubscribe from this group, send email to
>> >> clojure+unsubscr...@googlegroups.com
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/clojure?hl=en
>> >
>> >
>> > --
>> > 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
>> > first post.
>> > To unsubscribe from this group, send email to
>> > clojure+unsubscr...@googlegroups.com
>> > For more options, visit this group at
>> > http://groups.google.com/group/clojure?hl=en
>>
>> --
>> 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 first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>
>
> -- 
> László Török
>
> 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send

Practical Clojure

2012-04-13 Thread faenvie
hi community,

i simply want to state that i love this book http://www.apress.com/9781430272311

it's minimalism is amazing and it helped me a lot. its good to
repeatedly read single chapters to get conscious of ... minimal is
good.

i would love to read a second edition with maybe a chapter about
clojurescript.

have a successful time

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Boolean

2012-04-13 Thread Softaddicts
Again, (Boolean. false) is an object. Objects returned from Java are values
from Clojure's perspective like numbers, 

Clojure is a Lisp but allows you to access Java's object world.
It's not because the object wraps a property containing a boolean primitive 
value that it
 should behave the same as Clojure's boolean type.

Other classes may wrap a primitive boolean value in a property and you would not
like these to be converted to a Clojure boolean value, you would like to retain 
a handle
on the object. Why should Boolean objects be different ? They are a Java 
creation,
they have nothing to do with the type value system of Clojure.

Luc


> 
> 
> > Hope I've made my point clear now.
> >
> 
> Maybe helping here... 
> 
> To anyone with some understanding of programming and a basic understanding 
> how `if' looks like in lisps the following lines would be at least 
> astonishing
> 
>  user=> (if some-thing "then" "else")
>  "then"
>  user=> (if (= some-thing false) "then" "else")
>  "then"
> 
> How can some-thing evaluate to true but be equal (in whatever sense = 
> defines equality) to false?  
> 
> IMHO it looks like some inconsistency in the contract between truthiness 
> and equality.
> 
> (And yes, I understand the argument that (Boolean. false) is an object and 
> thus true; it's just the combination of both that I find very irritating.)
> 
> Kind regards,
> Stefan
> 
> -- 
> 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 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
--
Softaddicts sent by ibisMail!

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Boolean

2012-04-13 Thread Vinzent

>
> http://clojuredocs.org/clojure_core/clojure.core/if

 
It's great, Andy, thank you! I haven't even thought about clojuredocs at 
all. Since it still doesn't eliminates the problem completely, I believe 
many clojure newcomers will find it incredibly useful.


Stefan Kamphausen  writes:

> According to e.g.
>  http://nathanmarz.com/blog/fun-with-equality-in-clojure.html
> it's a speed trade-off. 

 
Yes, but adding a couple of words to the ='s docstring (and possibly 
printing a warning) as I suggested earlier doesn't have any trade-offs, 
right? It's actually a trivial fix that would save a lot of time and 
OMGWTFs for the new clojure users. Just like Boolean's javadoc puts a 
strong emphasis on the fact that public *Boolean*(boolean value) 
constructor usually shouldn't be used, clojure's docstring should say that 
(= x false) may give you a result which will confuse you, so you'd better 
use 'false?' instead.

Note: I'm writing all this not because I like to argue, but because I want 
to make sure that the community has came to a consensus on this issue 
before opening a ticket. 

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Loading a huge graph

2012-04-13 Thread László Török
Excellent! Thank you, that did the trick!

2012/4/13 bOR_ 

> I have this option in my project.clj file, which does the trick if you are
> developing from emacs+swank+clojure-jack-in, and using large networks
>
>   :jvm-opts ["-Xmx4000m"]
>
> And yes, one of the things to do when working with the jvm is learning how
> to use jconsole or visualvm to see why your program is slow :-), and know
> how to adapt the jvm options. If I remember correctly, java 1.7 has an
> option for a more flexible heap size, which might be a nice default.
>
>
> On Friday, 13 April 2012 10:32:24 UTC+2, Las wrote:
>>
>> Thanks,
>>
>> having a C++ background, there is definitely a lot to learn about the JVM.
>>
>> I'm wrote a script in Python that ran in about 10-12s and used up to
>> 320MB of memory.
>>
>> I'm running a clojure repl from Emacs via jack-in.
>>
>> What's the best way to adjust the heap size? swank-clojure and
>> clojure-mode don't say.
>>
>> If I spin up the repl via lein swank, I can use the LEIN_JVM_OPTS,
>> however it affects only one of the JVMs started by lein swank, the one with
>> jline.
>>
>> Any advice? :)
>>
>>
>> 2012/4/13 Alex Robbins 
>>
>>> Yeah, sounds like it could definitely be a memory issue. This is one
>>> part where the JVM works a lot differently than I expected coming from
>>> a python background.
>>>
>>> Everybody may already know this, but the JVM only takes 64mb for the
>>> heap by default. You'll get an out of memory error if your program
>>> uses more than that. In contrast, python just takes all the memory it
>>> needs. As your program gets closer to the JVM memory limit it'll spend
>>> more and more time doing garbage collection, with less and less real
>>> work getting done. You can pass an -Xmx flag to give java access to
>>> more memory, which many (most?) programs do.
>>>
>>>
>>> On Thu, Apr 12, 2012 at 5:22 PM, David Nolen 
>>> wrote:
>>> > How much memory do Python & Go consume when you do this? Are you
>>> giving the
>>> > JVM enough memory?
>>> >
>>> >
>>> > On Thu, Apr 12, 2012 at 6:17 PM, László Török 
>>> wrote:
>>> >>
>>> >> Hi,
>>> >>
>>> >> I'm trying figure out how to load a huge file that contains some 800k
>>> pair
>>> >> of integers (two integers per line) which represent edges of a
>>> directed
>>> >> graph.
>>> >>
>>> >> So if the ith line has x and y, it means that there is an edge
>>> between x
>>> >> and y vertex in the graph.
>>> >>
>>> >> The goal is to load it in an array of arrays representation, where
>>> the kth
>>> >> array contains all the nodes, where there is a directed edge from the
>>> kth
>>> >> node to those nodes.
>>> >>
>>> >> I've attempted multiple variants of with-open reader and line-seq
>>> etc. but
>>> >> almost always ended up with OutMemoryException or sg VERY slow.
>>> >>
>>> >> My latest attempt that also does not work on the large input:
>>> >>
>>> >> (defn load-graph [input-f]
>>> >>   (with-open [rdr (io/reader input-f)]
>>> >> (->> (line-seq rdr)
>>> >> (map (fn [row]
>>> >>(let [[v1str v2str] (str/split row #"\s")]
>>> >>[ (Integer/parseInt v1str) (Integer/parseInt
>>> v2str) ]))
>>> >>   )
>>> >> (reduce (fn [G [v1 v2]]
>>> >>   (if-let [vs (get G v1)]
>>> >> (update-in G [v1] #(conj % v2))
>>> >> (assoc G v1 [v2])))  { }  
>>> >>
>>> >> I'm getting a bit frustrated as there are Python, Go implementations
>>> that
>>> >> load the graph in less the 5 seconds.
>>> >>
>>> >> What am I doing wrong?
>>> >>
>>> >> Thanks
>>> >>
>>> >> --
>>> >> László Török
>>> >>
>>> >> --
>>> >> 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 first post.
>>> >> To unsubscribe from this group, send email to
>>> >> clojure+unsubscribe@**googlegroups.com
>>> >> For more options, visit this group at
>>> >> http://groups.google.com/**group/clojure?hl=en
>>> >
>>> >
>>> > --
>>> > 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
>>> > first post.
>>> > To unsubscribe from this group, send email to
>>> > clojure+unsubscribe@**googlegroups.com
>>> > For more options, visit this group at
>>> > http://groups.google.com/**group/clojure?hl=en
>>>
>>> --
>>> 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 first post.
>>> To unsubscribe from this group, send em

Re: Supporting platform specific code

2012-04-13 Thread Vinzent

>
> ^{:platform :jvm} (load "jvm/lib") 

^{:platform :python} (load "python/lib")


or platform metadata attached to the 'ns' form should be trated as "this 
whole file is for this platform". This way, in src/py/blah.clj you'd have

^{:platform :python}
(ns blah)
...
(your code)
...

without relying on file extensions, directory structure or similar things.


Tassilo Horn writes:

> But why would that be better than a reader macro
>   #+:jvm(load "jvm/lib")
>   #+:python (load "python/lib")


I don't think it's "better", this two options are rather equivalent. The 
only difference is that #+ would require new reader entities, while variant 
with metadata leverages already existing clojure facilities.

Although, another thing is that it looks like metadata would be more 
flexible; for example, one could write

^{:platform :jvm, :version "1.7"}

or maybe even something like 

^{:platform :jvm, :version "[1.7,)", :implementation "sun"}

Of course, it's possible to make #+{:version ...} work, but then I don't 
see how is it really differs from meta.

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Boolean

2012-04-13 Thread Cedric Greevey
What of the original issue, that deserializing a large nested
datastructure with boxed booleans in it results in misbehaving Boolean
"false" instances?

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Practical Clojure

2012-04-13 Thread wschnell
Hi,
you are not alone.
This book is for reading again and again.

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Supporting platform specific code

2012-04-13 Thread Tassilo Horn
Vinzent  writes:

>> But why would that be better than a reader macro
>>   #+:jvm(load "jvm/lib")
>>   #+:python (load "python/lib")
>
>
> I don't think it's "better", this two options are rather equivalent.
> The only difference is that #+ would require new reader entities,
> while variant with metadata leverages already existing clojure
> facilities.

That there's metadata already doesn't mean the reader would not need to
be adapted.  And # is already a reader dispatch character, so there is
probably not much difference implementation wise.

> Although, another thing is that it looks like metadata would be more
> flexible; for example, one could write
>
> ^{:platform :jvm, :version "1.7"}
>
> or maybe even something like 
>
> ^{:platform :jvm, :version "[1.7,)", :implementation "sun"}

But my own programs already use :platform and :version metadata with
completely different semantics.  (Well, no, they don't, but it could
be.)

> Of course, it's possible to make #+{:version ...} work, but then I don't 
> see how is it really differs from meta.

I'd still prefer a more general plain-macro version for conditional
compilation with arbitrary tests instead of hardcoded platform and
version keys.  For example, I might want to be able to test if a certain
program is installed on the machine, or if a certain lib is in the
CLASSPATH.

Bye,
Tassilo

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Supporting platform specific code

2012-04-13 Thread Timothy Baldridge
I'm starting to like the hybrid approach as well. We could create a
new version of "require" that's a conditional load:

(cond-require {:platform :jvm :version 7} 'core.platform.jvm.mymodule)
(cond-require {:platform :clr :version 4.5} 'core.platform.clr.mymodule)

With a single modification to core.clj we could then add this to the ns macro:



(ns clojure.core.match
 (:refer-clojure :exclude [compile])
 (:require [clojure.set :as set])
 (:cond-require {:platform :jvm :version 7}
[core.platform.jvm.mymodule :as mymodule])
 (:cond-require {:platform :clr :version 4.5 :arch :x64}
[core.platform.clr.mymodule :as mymodule]))

In this way we kind-of get the best of all worlds. Code is broken out
into seperate files, we can use metadata to give extra platform
specific info to the loading routines, and we don't end up with any
magic strings. Users can organize code however they wish, if someone
wants /src/platform/jvm/foo.clj and someone else wants
/src/jvm/foo/platform/foo.clj they are free to do so.

I guess the only thing I don't like about this is that when porting to
a new platform you can't simply find for .cljclr and copy/modify all
the found files. Instead you have to grep the contents of all .clj
files, and figure out what needs to be done, but if the library
maintainers do their job, that should be eaiser. They can simply put
all platform files in a separate directory

Timothy

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript function params shadow top-level namespace segments

2012-04-13 Thread David Nolen
Yes. Please open a ticket in JIRA.

Thanks!

On Fri, Apr 13, 2012 at 3:40 AM, Stuart Campbell  wrote:

> Given the following ClojureScript:
>
> (ns foo)
> (defn bar [] 42)
>
> (ns baz
>   (:require [foo :as x]))
>
> (defn quux [foo]
>   (x/bar))
>
> baz.quux compiles to:
>
> baz.quux = function quux(foo) {
>   return foo.bar.call(null)
> };
>
> i.e. the parameter name shadows the top-level "foo" namespace.
>
> Is that a bug?
>
> Regards,
> Stuart
>
> --
> 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 first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Boolean

2012-04-13 Thread Rich Hickey
You are reporting this to the wrong language group.

The fact that Java:

A) has a public constructor for Boolean (a type with only 2 possible instances)
B) whose doc string says "Note: It is rarely appropriate to use this 
constructor."
and then
C) goes on to use it in some library functions (reflection, serialization)

are all bugs in *Java*. When they fix them, your problem will go away.

Please submit your bug reports to Oracle, and patches to Open JDK. 

Good luck :)

Rich

On Apr 7, 2012, at 11:41 AM, Steven Obua wrote:


> Well, I am an emotional programmer. And it just hurts when something 
> potentially great like Clojure fucks up big time in the little details.
> 
> I found the problem. It was caused by serializing a record value and later 
> deserializing it:
> 
> ---
> (defrecord M-Node [leaf content])
> 
> (def n (M-Node. false ""))
> 
> (if (:leaf n) "boom" "ok")  ;; returns "ok"
> 
> (def n (load-node (store-node n)))  ;; load-node and store-node are just java 
> serialization/deserialization
> 
> (if (:leaf n) "boom" "ok")  ;; returns "boom"
> 
> 
> 
> On Saturday, April 7, 2012 4:17:40 PM UTC+1, Aaron Cohen wrote:
> I'm afraid you've managed to convey your emotion, but not what the actual 
> problem you're having is.
> 
> Care to try that again?
> 
> --Aaron
> 
> -- 
> 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 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Supporting platform specific code

2012-04-13 Thread Tassilo Horn
Timothy Baldridge  writes:

> I'm starting to like the hybrid approach as well. We could create a
> new version of "require" that's a conditional load:
>
> (cond-require {:platform :jvm :version 7} 'core.platform.jvm.mymodule)
> (cond-require {:platform :clr :version 4.5} 'core.platform.clr.mymodule)
>
> With a single modification to core.clj we could then add this to the
> ns macro:

Basically, I think to split out platform specific code into their own
namespaces is appropriate and should be encouraged for all the good
reasons you mentioned.  But there might be places where it also had its
drawbacks.

For example, you have a single, rather complex function that uses
platform specific code at various places.  With the cond-require
approach, you have to essentially clone it for each platform.  If the
original version is buggy, all of them are buggy.  If you start
refactoring your design, you'll need to do the same modifications to all
of them.

Alternatively and probably better, you just create wrapper functions for
every occurence of platform specific code, may it only be a constructor
call.  Well, that's a bit against the clojure principle of "don't wrap
your host platform", but probably that principle is becoming out of
fashion at least for libs and programs intended to be run on many
platforms.

Bye,
Tassilo

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Supporting platform specific code

2012-04-13 Thread Vinzent

>
> But my own programs already use :platform and :version metadata 
> with completely different semantics.  (Well, no, they don't, but it could
>
> be.)
>
That's not a problem, since the same is true for :doc, :macro, :arglists, 
etc, etc. Also, meta on expressions is probably not used so often. Anyway, 
it might be reasonable to use a single :platform key, and put map with the 
onther keys under it.
 

> I'd still prefer a more general plain-macro version for conditional
>
> compilation with arbitrary tests instead of hardcoded platform and
> version keys.
>
I agree, although nothing prevents us from something like :condition 
(some-expr) being evaluating for such complex cases. By the way, do you 
have any clue why in Common Lisp they use #+ #- instead of macro approach, 
which seems a way more powerful?

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ClojureScript function params shadow top-level namespace segments

2012-04-13 Thread Stuart Campbell
Done: http://dev.clojure.org/jira/browse/CLJS-180

On 13 April 2012 22:14, David Nolen  wrote:

> Yes. Please open a ticket in JIRA.
>
> Thanks!
>
> On Fri, Apr 13, 2012 at 3:40 AM, Stuart Campbell  wrote:
>
>> Given the following ClojureScript:
>>
>> (ns foo)
>> (defn bar [] 42)
>>
>> (ns baz
>>   (:require [foo :as x]))
>>
>> (defn quux [foo]
>>   (x/bar))
>>
>> baz.quux compiles to:
>>
>> baz.quux = function quux(foo) {
>>   return foo.bar.call(null)
>> };
>>
>> i.e. the parameter name shadows the top-level "foo" namespace.
>>
>> Is that a bug?
>>
>> Regards,
>> Stuart
>>
>>  --
>> 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 first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
>
>  --
> 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 first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Practical Clojure

2012-04-13 Thread David Cabana
I have not read it all (yet), but what I have read is outstanding.
O'Reilly has made the table of contents and first chapter available
online. If you are at all curious, check it out.  The first chapter
contains an exceptionally lucid and thorough section on destructuring.

http://cdn.oreilly.com/oreilly/booksamplers/9781449394707_sampler.pdf

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Supporting platform specific code

2012-04-13 Thread Tassilo Horn
Vinzent  writes:

>> I'd still prefer a more general plain-macro version for conditional
>> compilation with arbitrary tests instead of hardcoded platform and
>> version keys.
>
> I agree, although nothing prevents us from something like :condition
> (some-expr) being evaluating for such complex cases. By the way, do
> you have any clue why in Common Lisp they use #+ #- instead of macro
> approach, which seems a way more powerful?

Reader macros are quite common in CL, and they are short and handy when
you use them on individual forms inside functions, i.e., when you don't
split specifics into separate files.  And of course, CL implementations
are usually not hosted on some other VMs, so interop with host platforms
doesn't occur.  You rather deal with little things like clisp
interpreting the common lisp spec about file system access slightly
different than SBCL, or with non-standardized extension libs.

With respect to plain macros: that's almost trivial to do in both CL and
Clojure, and I'm sure that's frequently done here and there.  For
example, that's a quick and dirty macro I'm using somewhere in my code:

--8<---cut here---start->8---
(defmacro compile-if
  "Evaluate `exp` and if it returns logical true and doesn't error, expand to
  `then`.  Else expand to `else`.  Example:

  (compile-if (Class/forName \"java.util.concurrent.ForkJoinTask\")
(do-cool-stuff-with-fork-join)
(fall-back-to-executor-services))"
  [exp then else]
  (if (try (eval exp)
   (catch Throwable _ false))
`(do ~then)
`(do ~else)))
--8<---cut here---end--->8---

It would just be nice if there was a standard facility for doing stuff
like that, for example in the form of a platform namespace with a
conditional compilation macro plus various commonly needed predicates
that can be used as test expressions.  (I would not object to a reader
macro in addition.)

Bye,
Tassilo

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Supporting platform specific code

2012-04-13 Thread Aaron
I posed this question briefly in this post here:  
https://groups.google.com/d/msg/clojure/K65Va0rCCls/Ow5bAJ_YTGIJ.  In this 
real world example of porting Korma over to ClojureCLR, I encountered the 
following things:

   - One namespace which handled JDBC interaction needed to be rewritten 
   completely to target ADO.NET
   - Another namespace required a few minor changes, only one of these 
   (changing .indexOf to IndexOf) was platform specific

Korma is a library that is probably exceptional in its avoidance of 
platform specific features in most namespaces.  Porting something like 
swank would not have been so easy.  In general, I would say that for this 
library, I would prefer to use the platform specific folder approach - i.e 
having two namespaces korma.platform.db and korma.platform.util in src-jvm/ 
and src-clr/ folders.  Then there could be a CLR specific project.clj 
(maybe project.clr.clj) sitting next to the JVM project.clj (and eventually 
maybe a project.py.clj).  Each project.clj would reference the correct 
platform specific folder in addition to the shared src/ folder.  Just off 
the top of my head, the reasons for supporting this approach are:

   - It forces the developer to isolate platform specific code into 
   manageable units that can be 1) more easily ported to another platform, 2) 
   easily maintained, and 3) tested in isolation for compatibility
   - There is no need for one clojure dialect to know about the whereabouts 
   or contents of code for another dialect.  This would seem to be unnecessary 
   overhead.

While I can see why it might be nice to be able to quickly add some 
metadata to distinguish this platform specific code while keeping 
everything in one file, as other have mentioned, I would encourage people 
to think about the downsides of this.  Say, I had just taking korma.db and 
put some conditionally compiled CLR code alongside the JVM code.  The file 
doubles in size.  Would I then want the py team to do the same?  Also, for 
the one .indexOf -> IndexOf change, say there are little changes like that 
all over the place.  Would a team adding a new port want to go through the 
whole source tree and find every instance of this?  Without modifying the 
clojure compilers we have now, the platform specific directory approach 
will work and is probably cleaner.  It just requires team consensus on 
adopting this approach.

One thing, I would propose is adding some build tool awareness of this so 
that maybe an NLein or PyLein could use the same project.clj and just see 
:platform-clr, :platform-py, :platform-jvm attributes.  Or this could be 
done by having a shared project.shared.clj included by each platform 
specific project file.  These types of approaches might be simpler and more 
maintainable in the long run.

Aaron
On Thursday, April 12, 2012 12:56:59 PM UTC-4, tbc++ wrote:
>
> I've been thinking lately how to seamlessly merge clojure-py and
> clojure-jvm code in the same packages. This is something I know has
> been discussed in the past, but I'm just looking for
> ideas/brainstorming on how we can solve this problem.
>
> Let's begin by explaining the problem. Let's assume that my project
> needs a platform specific way to convert a int to a string:
>
> On clojure-jvm:
>
> (defn to-string [i] (.toString Integer i))
>
> On clojure-py:
>
> (defn to-string [i] (py/str i))
>
> On Clojurescript:
>
> (defn to-string [i] (.toString i))
>
>
> We could do this inline (inside a common .clj file):
>
> (for-platform "jvm"
>   (defn to-string [i] (.toString Integer i))
>   "python"
>   (defn to-string [i] (py/str i))
>   "js"
>   (defn to-string [i] (.toString i)))
>
> But this gets ugly real fast.
>
> My idea, would be to provide some sort of hook to the compiler, that
> would be cross-platform. The compiler, when looking for a namespace,
> would find all files in a given folder that match the required
> namespace:
>
> /test/to_string.clj
> /test/to_string.cljpy
> /test/to_string.cljs
> /test/to_string.cljclr
>
> These function hooks would then pick the best entry based on the
> extension, defaulting to .clj if no better option exists. Since these
> functions could be composable it would be possible to also dispatch on
> platform versions:
>
> /test/to_string.cljpy26   ; Python 2.6 code
> /test/to_string.clj7; JVM 7 code
>
> It seems to me that this would be a very clean way to allow clojure
> programs to be cross-platform. The side-effect is that it would force
> non-standard code out into separate namespaces where they can be
> easily maintained. If someone wanted to port the project to a new
> platform, he would need only to find existing platform overrides, and
> create new entries.
>
>
> Thoughts?
>
> Timothy Baldridge
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googl

Friend: an extensible authentication and authorization library for Clojure Ring webapps and services

2012-04-13 Thread Chas Emerick
For your consideration, a new library:

I’m hoping this can eventually be a warden/spring-security/everyauth /omniauth 
for Clojure; that is, a common abstraction for authentication and authorization 
mechanisms.  Clojure has been around long enough that adding pedestrian things 
like form and HTTP Basic and $AUTH_METHOD_HERE to a Ring application should be 
easy.  Right now, it’s not: either you’re pasting together a bunch of different 
libraries that don’t necessarily compose well together, or you get drawn into 
shaving the authentication and authorization yaks for the fifth time in your 
life so you can sleep well at night.

Hopefully Friend will make this a solved problem, or at least push things in 
that direction.

Read more here: http://wp.me/p10OJi-d6

Cheers,

- Chas

--
http://cemerick.com
[Clojure Programming from O'Reilly](http://www.clojurebook.com)

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Clojurescript standards to integrate other libraries

2012-04-13 Thread Prasanna Gautam
I'm quite new to clojurescript and I'm working on using clojurescript with 
some other javascript libraries - most notably I would like to get jQuery 
and Highcharts to work right now. Are there any established patterns or 
projects that make it easier to write wrappers for libraries that aren't 
compatible with Google Closure Advanced mode?

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

compile dynamic ns ?

2012-04-13 Thread ollem
Hi,

I want to create and compile java classes on the fly using clojure.
I also want to pack the compiled result in a jar file to be used by
another system.
I have used JavaAssist  before but thought that it could be kind of
neat to use clojure instead.

I have ran into a problem though:

(defn dyn-class [ns cname]
  (gen-class
   :name cname
   :state state
   :main false
   :prefix "-"
   :impl-ns ns
   :methods [[helloGen [] void]])
  (intern ns '-helloGen (fn [] (println "hello awkward world!"

(create-ns 'hejsan)
(dyn-class 'hejsan "com.dr.Allan")
(compile 'hejsan)

Could not locate hejsan__init.class or hejsan.clj on classpath:
  [Thrown class java.io.FileNotFoundException]

Can I do this without having to write hejsan.clj down to disk ?

Thanks! // Olle

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: noir response

2012-04-13 Thread Rups
My download code is like this which reads file from mongodb. but it not
downloaded original file.

(defpage [:get "/download"] {:as values}
 (let [f (fetch-one-file :test3)
   stream (stream-from :test3 f)
   data (slurp stream)]
   (resp/content-type (:contentType f) data)
  ))



On Fri, Apr 13, 2012 at 6:56 PM, Rups  wrote:

> Hi...
>
>I am using a noir,
>I like to download a file on click event.
>I have a file object in binary formate.
>How i write code for response for download file in its original
> formate.
>

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Practical Clojure

2012-04-13 Thread Curtis Gagliardi
I hadn't heard of practical clojure, but while we're praising books,
I'd like to say that Clojure Programming is excellent.  I've been
reading the early access version, and while I haven't finished it, I'm
almost done with the first half, which covers the core of the
language.  It's been incredibly helpful so far and I'm really looking
forward to the practical stuff that makes up second half of the
book.

On Apr 13, 8:51 am, David Cabana  wrote:
> I have not read it all (yet), but what I have read is outstanding.
> O'Reilly has made the table of contents and first chapter available
> online. If you are at all curious, check it out.  The first chapter
> contains an exceptionally lucid and thorough section on destructuring.
>
> http://cdn.oreilly.com/oreilly/booksamplers/9781449394707_sampler.pdf

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Idea for algorithm for renaming in an Clojure IDE

2012-04-13 Thread André Ferreira
I was thinking about how things like function or variable renaming are
complicated by lisps macros. That it's almost impossible to track the
scope of anything, since 2 symbols near each other might mean
completely different things after macro expansion.
So I came up with an algorithm that *might* work in the most common
case. Is there a flaw in the idea, or did I overlook any major aspect
of the language? Any idea of which IDE would be the best to try and
prototype it?

Here it is in pseudocode:

select symbol in source that you want to rename
parse the code
add tracking meta-data (file, line, position in line) into all symbols
of the tree
expand all macros
find selected symbol: it's either a definition in a def form or let*
or letfn form, or a variable being
used
if the symbol is a definition, find all places where it is used,
taking scope into account
   use metadata to find where the symbol was in the source code
   if it wasn't, it means a macro expanded it into place, so fail
   else rename it
if the symbol is a variable, find where it was defined, taking scope
into account
use metadata to rename it, if there is none, fail
find all symbols that refer to the definition, rename if there is
metadata, fail otherwise

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


noir response

2012-04-13 Thread Rups
Hi...

   I am using a noir,
   I like to download a file on click event.
   I have a file object in binary formate.
   How i write code for response for download file in its original
formate.

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Question on clojurescript symbols <-> strings

2012-04-13 Thread Marius Seritan
I am not sure if this is the right forum. I am playing with domina and 
domina-events and I cannot register and event because of some problem with 
symbols. By the time my symbols make it into goog.events the event is 
"ï· 'keyup" instead of "keyup". 

I am trying to figure this out. In my browser I have a breakpoint and I am 
running these functions to translate from symbols to strings:

cljs.core.symbol.call(0,"ha")
-> "ï·‘'ha"

But then when I try the reverse translation I get:
cljs.core.name.call(0,"ï·‘'ha")
-> "ï·‘'ha"

Does this ring a bell? Thanks!

Marius

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Loading a huge graph

2012-04-13 Thread Robert Marianski
If the jvm does have enough memory, you may want to try building up the
map using a transient.

And not sure if this is faster, (maybe it's slower), but you can spell the
function you pass to reduce more succinctly:

(fn [G [v1 v2]] (update-in G [v1] (fnil conj []) v2))

Robert

On Thu, Apr 12, 2012 at 06:22:34PM -0400, David Nolen wrote:
> How much memory do Python & Go consume when you do this? Are you giving the
> JVM enough memory?
> 
> On Thu, Apr 12, 2012 at 6:17 PM, László Török  wrote:
> 
> > Hi,
> >
> > I'm trying figure out how to load a huge file that contains some 800k pair
> > of integers (two integers per line) which represent edges of a directed
> > graph.
> >
> > So if the ith line has x and y, it means that there is an edge between x
> > and y vertex in the graph.
> >
> > The goal is to load it in an array of arrays representation, where the kth
> > array contains all the nodes, where there is a directed edge from the kth
> > node to those nodes.
> >
> > I've attempted multiple variants of with-open reader and line-seq etc. but
> > almost always ended up with OutMemoryException or sg VERY slow.
> >
> > My latest attempt that also does not work on the large input:
> >
> > (defn load-graph [input-f]
> >   (with-open [rdr (io/reader input-f)]
> > (->> (line-seq rdr)
> > (map (fn [row]
> >(let [[v1str v2str] (str/split row #"\s")]
> >[ (Integer/parseInt v1str) (Integer/parseInt v2str) ]))
> >   )
> > (reduce (fn [G [v1 v2]]
> >   (if-let [vs (get G v1)]
> > (update-in G [v1] #(conj % v2))
> > (assoc G v1 [v2])))  { }  
> >
> > I'm getting a bit frustrated as there are Python, Go implementations that
> > load the graph in less the 5 seconds.
> >
> > What am I doing wrong?
> >
> > Thanks
> >
> > --
> > László Török
> >
> >  --
> > 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 first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
> 
> -- 
> 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 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Dealing with dynamic header in log file processing

2012-04-13 Thread Cliff Mosley
Prefacing this with being a complete Clojure novice, my question is more 
about approach than the actual code required. Like many, I have a few tried 
and true examples that I like to work through in each language. In my case, 
I have a set of IIS log files that I want to generate usage statistics on. 
The hitch in my particular problem is that the log files may or may not 
have columns redefined within the file.

As an example 
#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2011-05-02 17:42:15
#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2011-05-02 17:42:15
#Fields: date time c-ip cs-username s-ip s-port cs-method cs-uri-stem 
cs-uri-query sc-status cs(User-Agent)
2011-05-02 17:42:15 172.22.255.255 - 172.30.255.255 80 GET 
/images/picture2.jpg - 200 
Mozilla/4.0+(compatible;MSIE+5.5;+Windows+2000+Server)
2011-05-02 17:43:15 172.22.255.255 - 172.30.255.255 80 GET 
/images/picture1.jpg - 200 
Mozilla/4.0+(compatible;MSIE+5.5;+Windows+2000+Server)
.
.

.
.
#Same file, s-ip is now removed so ordinal positions are changed
#Fields: date time c-ip cs-username s-port cs-method cs-uri-stem 
cs-uri-query sc-status cs(User-Agent)
2011-05-02 17:48:15 172.22.255.255 - 80 GET /images/picture1.jpg - 200 
Mozilla/4.0+(compatible;MSIE+5.5;+Windows+2000+Server)
2011-05-02 17:49:15 172.22.255.255 - 80 GET /images/picture3.jpg - 200 
Mozilla/4.0+(compatible;MSIE+5.5;+Windows+2000+Server)

So with the above data, I am trying to get the count of log file hits from 
a given cs(User-Agent). In other languages, I would just read in the 
#Fields row and continue processing merrily given the most recent order I 
encountered moving through the file sequentially. With Clojure, the 
immutability of the fields is throwing a wrench for me.

If anyone could give me a nudge in the right direction, I would appreciate 
it.
Cliff

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Practical Clojure

2012-04-13 Thread Tom Maynard


On Friday, April 13, 2012 5:19:43 AM UTC-5, faenvie wrote:
>
>
> i simply want to state that i love this book 
> http://www.apress.com/9781430272311 
>
>
Which version(s) of Closure does the book cover?  I have both "Joy of" and 
"In Action" and I find them somewhat disjointed and confusing in their 
exposition, not at all like "ML for Working Programmers" or "Elements of 
ML" which are both more cogent and helpful in mapping out the "alien 
terrain" of functional languages for imperative programmers.

So I am still looking for what I would consider a definitive text 
introducing Clojure in a meaningful, orderly way.

Tom.

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Help using parsatron to parse a list

2012-04-13 Thread rahulpilani
Hi,
I am trying to use the parsatron library 
(https://github.com/youngnh/parsatron) to parse a simple list of digits. I 
am not able to get it to parse correctly, I was wondering what I was 
missing. 

What I have so far:
(defparser array-item []
  (let->> [_ (many (char \space))
   item (many (digit))
   _ (many (char \space)
   _ (either
  (char \,)
  (lookahead (char \]
  (always item)))
 
(defparser arr []
  (between (char \() (char \))
   (many (array-item

But the array-item parser is not working for a simple input like "1)". 

The question I have is, how do I terminate the array-item parser correctly 
so that the between parser can take over in the arr parser?



-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: == is not always transitive

2012-04-13 Thread Sung Pae
Leif  writes:

> I'd also like to make sure people are aware of this oddity. I
> discovered this after reading an article about the bad design of PHP.
> I read that in PHP, "== is not transitive." I thought "Ha ha ha, that
> ridiculous PHP!"
>
> Then I checked c.c/== ; Imagine my reaction when I learned that
> Clojure had something in common with PHP. o_O, :'[ Other emoticons
> also washed over me.

Clojure's == is numerical equivalence, not equality.

-
clojure.core/==
([x] [x y] [x y & more])
  Returns non-nil if nums all have the equivalent
  value (type-independent), otherwise false

The problem with PHP (and JavaScript's) == operator is that the type
coercion is not limited to numerical types:

PHP

"1" == 1=> true
"1" + 1 => 2

JavaScript

"1" == 1=> true
"1" + 1 => "11"

Clojure

(== "1" 1)  => java.lang.ClassCastException
(+ "1" 1)   => java.lang.ClassCastException

Clojure's equality function [1], however, does what you expect when
comparing floats and integers:

(= 1.0 1)   => false

But it also does what you want when comparing _categories_ of numbers
[2] [3]:

(let [a (int 1) b (bigint 1)]
  {:equal_values? (= a b)
   :equal_types?  (= (type a) (type b))})

=> {:equal_values? true, :equal_types? false}

I think Clojure does a fantastic job of being both convenient and
strongly typed.

--
guns

[1]: 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Util.java#L23
[2]: 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Numbers.java#L213
[3]: 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Numbers.java#L978

 If you were really concerned about whether a number is a BigInteger
 vs Integer, or Float vs Double, you would have to handle that on
 your own.

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Friend: an extensible authentication and authorization library for Clojure Ring webapps and services

2012-04-13 Thread Chas Emerick
For your consideration, a new library:

I’m hoping this can eventually be a warden/spring-security/everyauth /omniauth 
for Clojure; that is, a common abstraction for authentication and authorization 
mechanisms.  Clojure has been around long enough that adding pedestrian things 
like form and HTTP Basic and $AUTH_METHOD_HERE to a Ring application should be 
easy.  Right now, it’s not: either you’re pasting together a bunch of different 
libraries that don’t necessarily compose well together, or you get drawn into 
shaving the authentication and authorization yaks for the fifth time in your 
life so you can sleep well at night.

Hopefully Friend will make this a solved problem, or at least push things in 
that direction.

Read more here: http://wp.me/p10OJi-d6

Cheers,

- Chas

--
http://cemerick.com
[Clojure Programming from O'Reilly](http://www.clojurebook.com)

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

moderation anomaly

2012-04-13 Thread Stuart Halloway
For some reason Google Groups is re-asking me to moderate people who have been 
on the list forever (e.g. it just wanted to know if Chas Emerick should be 
allowed to post). Moderation got a little backed up as a result, but I think 
everything that was pending is pushed through now.

Sorry for the inconvenience.

Stu


Stuart Halloway
Clojure/core
http://clojure.com

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Loading a huge graph

2012-04-13 Thread László Török
Thanks, I know about transients, but I'm already using mutable arrays for
speed :-)
On Apr 13, 2012 8:01 PM, "Robert Marianski"  wrote:
>
> If the jvm does have enough memory, you may want to try building up the
> map using a transient.
>
> And not sure if this is faster, (maybe it's slower), but you can spell the
> function you pass to reduce more succinctly:
>
> (fn [G [v1 v2]] (update-in G [v1] (fnil conj []) v2))
>
> Robert
>
> On Thu, Apr 12, 2012 at 06:22:34PM -0400, David Nolen wrote:
> > How much memory do Python & Go consume when you do this? Are you giving
the
> > JVM enough memory?
> >
> > On Thu, Apr 12, 2012 at 6:17 PM, László Török 
wrote:
> >
> > > Hi,
> > >
> > > I'm trying figure out how to load a huge file that contains some 800k
pair
> > > of integers (two integers per line) which represent edges of a
directed
> > > graph.
> > >
> > > So if the ith line has x and y, it means that there is an edge
between x
> > > and y vertex in the graph.
> > >
> > > The goal is to load it in an array of arrays representation, where
the kth
> > > array contains all the nodes, where there is a directed edge from the
kth
> > > node to those nodes.
> > >
> > > I've attempted multiple variants of with-open reader and line-seq
etc. but
> > > almost always ended up with OutMemoryException or sg VERY slow.
> > >
> > > My latest attempt that also does not work on the large input:
> > >
> > > (defn load-graph [input-f]
> > >   (with-open [rdr (io/reader input-f)]
> > > (->> (line-seq rdr)
> > > (map (fn [row]
> > >(let [[v1str v2str] (str/split row #"\s")]
> > >[ (Integer/parseInt v1str) (Integer/parseInt
v2str) ]))
> > >   )
> > > (reduce (fn [G [v1 v2]]
> > >   (if-let [vs (get G v1)]
> > > (update-in G [v1] #(conj % v2))
> > > (assoc G v1 [v2])))  { }  
> > >
> > > I'm getting a bit frustrated as there are Python, Go implementations
that
> > > load the graph in less the 5 seconds.
> > >
> > > What am I doing wrong?
> > >
> > > Thanks
> > >
> > > --
> > > László Török
> > >
> > >  --
> > > 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 first post.
> > > To unsubscribe from this group, send email to
> > > clojure+unsubscr...@googlegroups.com
> > > For more options, visit this group at
> > > http://groups.google.com/group/clojure?hl=en
> >
> > --
> > 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 first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
>
> --
> 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 first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Question on clojurescript symbols <-> strings

2012-04-13 Thread David Nolen
What's your actual code look like?

On Thu, Apr 12, 2012 at 11:17 PM, Marius Seritan  wrote:

> I am not sure if this is the right forum. I am playing with domina and
> domina-events and I cannot register and event because of some problem with
> symbols. By the time my symbols make it into goog.events the event is "ï·
> 'keyup" instead of "keyup".
>
> I am trying to figure this out. In my browser I have a breakpoint and I am
> running these functions to translate from symbols to strings:
>
> cljs.core.symbol.call(0,"ha")
> -> "ï·‘'ha"
>
> But then when I try the reverse translation I get:
> cljs.core.name.call(0,"ï·‘'ha")
> -> "ï·‘'ha"
>
> Does this ring a bell? Thanks!
>
> Marius
>
>  --
> 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 first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Light Table - a new IDE concept

2012-04-13 Thread looselytyped
This is an awesome implementation of Brett Victors "Inventing On
Principle" [http://vimeo.com/36579366] using Clojure and Noir by Chris
Granger (who also wrote Noir).

Figured I would share it with the group.

http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/

Raju

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Boolean

2012-04-13 Thread Sean Corfield
On Fri, Apr 13, 2012 at 3:33 AM, Vinzent  wrote:
> Just like Boolean's javadoc puts a strong
> emphasis on the fact that public Boolean(boolean value) constructor usually
> shouldn't be used, clojure's docstring should say that (= x false) may give
> you a result which will confuse you, so you'd better use 'false?' instead.

(def f (Boolean. false))
(false? f)
;; => false
(true? f)
;; => false
(= f false)
;; => true
(if f :t :f)
;; => :t

So 'false?' doesn't help you here.

No one should be using (Boolean. false) in Clojure code - we have true
/ false. Why create a Java object whose documentation says not to do
it?

So if anyone runs into this problem _in real world code_ it's because
they are calling a Java API that somehow returns a Java Boolean object
embedded in the result. If you are working with a Java data structure
full of _Objects_ then you need to take care of converting those
Object instances into appropriate Clojure values. Calling (boolean v)
is sufficient to convert the Java Object to a Clojure true/false
value.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Light Table - a new IDE concept

2012-04-13 Thread D.Bushenko
This is really interesting. Is there a sourcecode for the light table ? I 
couldn't find it...

пятница, 13 апреля 2012 г., 21:34:54 UTC+3 пользователь looselytyped 
написал:
>
> This is an awesome implementation of Brett Victors "Inventing On 
> Principle" [http://vimeo.com/36579366] using Clojure and Noir by Chris 
> Granger (who also wrote Noir). 
>
> Figured I would share it with the group. 
>
> http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/ 
>
> Raju


пятница, 13 апреля 2012 г., 21:34:54 UTC+3 пользователь looselytyped 
написал:
>
> This is an awesome implementation of Brett Victors "Inventing On 
> Principle" [http://vimeo.com/36579366] using Clojure and Noir by Chris 
> Granger (who also wrote Noir). 
>
> Figured I would share it with the group. 
>
> http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/ 
>
> Raju

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Light Table - a new IDE concept

2012-04-13 Thread Tamreen Khan
Nope, the source hasn't been released yet. I think Chris is still trying to
figure out what to do with it.

2012/4/13 D.Bushenko 

> This is really interesting. Is there a sourcecode for the light table ? I
> couldn't find it...
>
> пятница, 13 апреля 2012 г., 21:34:54 UTC+3 пользователь looselytyped
> написал:
>
>> This is an awesome implementation of Brett Victors "Inventing On
>> Principle" [http://vimeo.com/36579366] using Clojure and Noir by Chris
>> Granger (who also wrote Noir).
>>
>> Figured I would share it with the group.
>>
>> http://www.chris-granger.com/**2012/04/12/light-table---a-**
>> new-ide-concept/
>>
>> Raju
>
>
> пятница, 13 апреля 2012 г., 21:34:54 UTC+3 пользователь looselytyped
> написал:
>
>> This is an awesome implementation of Brett Victors "Inventing On
>> Principle" [http://vimeo.com/36579366] using Clojure and Noir by Chris
>> Granger (who also wrote Noir).
>>
>> Figured I would share it with the group.
>>
>> http://www.chris-granger.com/**2012/04/12/light-table---a-**
>> new-ide-concept/
>>
>> Raju
>
>  --
> 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 first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Light Table - a new IDE concept

2012-04-13 Thread sean neilan
I wish there was a link to download it.

On Fri, Apr 13, 2012 at 1:34 PM, looselytyped  wrote:

> This is an awesome implementation of Brett Victors "Inventing On
> Principle" [http://vimeo.com/36579366] using Clojure and Noir by Chris
> Granger (who also wrote Noir).
>
> Figured I would share it with the group.
>
> http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/
>
> Raju
>
> --
> 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 first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Light Table - a new IDE concept

2012-04-13 Thread Jim - FooBar();

I am left speecheless...!

Jim

On 13/04/12 19:49, sean neilan wrote:

I wish there was a link to download it.

On Fri, Apr 13, 2012 at 1:34 PM, looselytyped > wrote:


This is an awesome implementation of Brett Victors "Inventing On
Principle" [http://vimeo.com/36579366] using Clojure and Noir by Chris
Granger (who also wrote Noir).

Figured I would share it with the group.

http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/

Raju

--
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 first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


--
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 first post.

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en 


--
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Practical Clojure

2012-04-13 Thread faenvie
as i think about it, it seems to me that 'practical clojure' should be
updated but stay minimal. This means strictly keep the focus on the
core of clojure, correct errors, add a few missing things (add more
info on destructuring for instance), add and update things that come
new or changed with clojure-1.3, clojure-1.4.

in addition there could be a separate book 'professional clojure' that
focuses on extensions and advanced topics of the clojure cosmos:
clojurescript, monads, continuations, building dsl, core.logic, ring,
korma, noir  ... this could be a great selling book IMO. it is the
book david nolan, jim duey, chris granger ... would probably love to
review.

oreillys upcoming book 'programming clojure' tries to sum up the 2
books in one.  buy it and draw your own clonclusions ;-)

i like strictly focused, minimal books and i have a desire for that
imaginary second book 'professional clojure'.

have a nice time

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Light Table - a new IDE concept

2012-04-13 Thread Lee Spector

On Apr 13, 2012, at 2:34 PM, looselytyped wrote:
> 
> http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/

Very nice!

Small note: In Interlisp, if I remember it correctly, code was structured into 
functions -- not files -- and one got an editor window for each function 
definition. One saved one's work to disk by writing out the whole workspace of 
function definitions, without there being a concept of files of code. Or at 
least that's how I remember it, although it has been a long time!

Interlisp did the live propagation of values thing that's in this demo... but 
still, it's interesting to see the idea of function editors coming back.

 -Lee

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Light Table - a new IDE concept

2012-04-13 Thread Lee Spector

On Apr 13, 2012, at 3:18 PM, Lee Spector wrote:
> 
> Interlisp did the live propagation of values thing that's in this demo... but 
> still, it's interesting to see the idea of function editors coming back.

OOPS -- I meant "Interlisp DIDN'T DO the live propagation of values thing...".

Interlisp had lots of cool stuff (like DWIM auto-correction of code, great GUI 
for syntax-aware editing, ...) but not that.

 -Lee

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Light Table - a new IDE concept

2012-04-13 Thread kovas boguta
Holy  I've been wanting this for literally the last decade.

Seeing the data flow through the program.

Being able to instantly see the code for all the functions related to
your function call.

I 100% agree that we need smaller units of source code than the text file.

Interested in how it would deal with
1. long running evaluations
2. some way to save & store the results of the evaluation, which
themselves are useful (right now they seem very ephemeral)



On Fri, Apr 13, 2012 at 3:07 PM, Jim - FooBar();  wrote:
> I am left speecheless...!
>
> Jim
>
>
> On 13/04/12 19:49, sean neilan wrote:
>
> I wish there was a link to download it.
>
> On Fri, Apr 13, 2012 at 1:34 PM, looselytyped  wrote:
>>
>> This is an awesome implementation of Brett Victors "Inventing On
>> Principle" [http://vimeo.com/36579366] using Clojure and Noir by Chris
>> Granger (who also wrote Noir).
>>
>> Figured I would share it with the group.
>>
>> http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/
>>
>> Raju
>>
>> --
>> 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 first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
>
> --
> 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
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
>
> --
> 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
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Boolean

2012-04-13 Thread Andy Fingerhut
One little nit that confuses me.

Boolean/FALSE is documented as being of type Boolean in Java documentation,
yet it is treated by Clojure the same as primitive boolean false:

user=> (clojure-version)
"1.3.0"
user=> (if Boolean/FALSE "logical true" "logical false")
"logical false"
user=> (identical? Boolean/FALSE false)
true

Does anyone know why?

Thanks,
Andy


On Fri, Apr 13, 2012 at 11:41 AM, Sean Corfield wrote:

> On Fri, Apr 13, 2012 at 3:33 AM, Vinzent  wrote:
> > Just like Boolean's javadoc puts a strong
> > emphasis on the fact that public Boolean(boolean value) constructor
> usually
> > shouldn't be used, clojure's docstring should say that (= x false) may
> give
> > you a result which will confuse you, so you'd better use 'false?'
> instead.
>
> (def f (Boolean. false))
> (false? f)
> ;; => false
> (true? f)
> ;; => false
> (= f false)
> ;; => true
> (if f :t :f)
> ;; => :t
>
> So 'false?' doesn't help you here.
>
> No one should be using (Boolean. false) in Clojure code - we have true
> / false. Why create a Java object whose documentation says not to do
> it?
>
> So if anyone runs into this problem _in real world code_ it's because
> they are calling a Java API that somehow returns a Java Boolean object
> embedded in the result. If you are working with a Java data structure
> full of _Objects_ then you need to take care of converting those
> Object instances into appropriate Clojure values. Calling (boolean v)
> is sufficient to convert the Java Object to a Clojure true/false
> value.
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
> --
> 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 first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojurescript standards to integrate other libraries

2012-04-13 Thread Mark Rathwell
Hi,

Below are some good resources for the questions you have.  Just a
note, you can advanced compile your own code that calls out to jQuery,
and others, you just can't compile those libraries in.  So, there are
existing extern files for jQuery, and for other libraries you might be
using, you can create your own extern files.

jayq (ClojureScript jQuery wrapper):
https://github.com/ibdknox/jayq

closure compiler extern files:
http://code.google.com/p/closure-compiler/source/browse/#svn%2Ftrunk%2Fcontrib%2Fexterns

Using Javascript Libraries in ClojureScript:
http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html

using jQuery plugins:
https://groups.google.com/forum/#!msg/clj-noir/HPeQl5jn4V8/WdP10stY8GYJ

On Wed, Apr 11, 2012 at 8:55 PM, Prasanna Gautam
 wrote:
> I'm quite new to clojurescript and I'm working on using clojurescript with
> some other javascript libraries - most notably I would like to get jQuery
> and Highcharts to work right now. Are there any established patterns or
> projects that make it easier to write wrappers for libraries that aren't
> compatible with Google Closure Advanced mode?
>
> --
> 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
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Practical Clojure

2012-04-13 Thread Sean Corfield
On Fri, Apr 13, 2012 at 6:51 AM, David Cabana  wrote:
> I have not read it all (yet), but what I have read is outstanding.

I haven't bothered buying it because it's so out of date now. I'll buy
a second edition when it gets underway, however.

I bought Programming Clojure once the 2nd Ed got underway. That's a
good book, as is Clojure Programming (which I prefer - hard to put my
finger on why). I _love_ Joy of Clojure. I quite liked Clojure in
Action as the early access versions evolved but I think Manning made a
serious error in not having a final pass over the book to update it to
1.3 - by the time they finally published it, it was out of date and
the examples rely on the monolithic 1.2 contrib library which doesn't
help anyone learning Clojure _today_...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: noir response

2012-04-13 Thread Mark Rathwell
See [1] for this morning's response to a very similar question ;)
There is also a group for Noir-specific questions at [2].

[1] https://groups.google.com/forum/#!msg/clj-noir/mT8L2hnMnNg/jRJ2UdOqKuQJ
[2] https://groups.google.com/forum/#!forum/clj-noir


On Fri, Apr 13, 2012 at 11:10 AM, Rups  wrote:
> My download code is like this which reads file from mongodb. but it not
> downloaded original file.
>
> (defpage [:get "/download"] {:as values}
>  (let [f (fetch-one-file :test3)
>    stream (stream-from :test3 f)
>    data (slurp stream)]
>    (resp/content-type (:contentType f) data)
>   ))
>
>
>
>
> On Fri, Apr 13, 2012 at 6:56 PM, Rups  wrote:
>>
>> Hi...
>>
>>    I am using a noir,
>>    I like to download a file on click event.
>>    I have a file object in binary formate.
>>    How i write code for response for download file in its original
>> formate.
>
>
> --
> 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
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Boolean

2012-04-13 Thread Meikel Brandmeyer
Hi,

Am 13.04.2012 um 21:45 schrieb Andy Fingerhut:

> One little nit that confuses me.
> 
> Boolean/FALSE is documented as being of type Boolean in Java documentation, 
> yet it is treated by Clojure the same as primitive boolean false:
> 
> user=> (clojure-version)
> "1.3.0"
> user=> (if Boolean/FALSE "logical true" "logical false")
> "logical false"
> user=> (identical? Boolean/FALSE false)
> true
> 
> Does anyone know why?

https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L294

together with

https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L34

would be a close call, I guess.

Kind regards
Meikel

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Boolean

2012-04-13 Thread Tassilo Horn
Andy Fingerhut  writes:

> Boolean/FALSE is documented as being of type Boolean in Java
> documentation, yet it is treated by Clojure the same as primitive
> boolean false:
>
> user=> (clojure-version)
> "1.3.0"
> user=> (if Boolean/FALSE "logical true" "logical false")
> "logical false"
> user=> (identical? Boolean/FALSE false)
> true
>
> Does anyone know why?

That's the canonical false Boolean object you get when auto-boxing the
primitive boolean false, or when calling (Boolean/valueOf).

,[ JLS: 5.1.7. Boxing Conversion ]
| At run time, boxing conversion proceeds as follows:
| 
|   - If p is a value of type boolean, then boxing conversion converts p
| into a reference r of class and type Boolean, such that
| r.booleanValue() == p
| 
|   [...]
| 
| If the value p being boxed is true, false, a byte, or a char in the
| range \u to \u007f, or an int or short number between -128 and 127
| (inclusive), then let r1 and r2 be the results of any two boxing
| conversions of p. It is always the case that r1 == r2.
`

Thus, checking "t != Boolean.FALSE" as clojure's `if` implementation
does is perfectly fine, because unless you've created a new Boolean
object yourself, the spec guarantees that you may check on identity.
(I totally agree with Rich that having a way to create new Boolean
instances is completely flawed.)

Bye,
Tassilo

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Light Table - a new IDE concept

2012-04-13 Thread Tassilo Horn
kovas boguta  writes:

> Holy  I've been wanting this for literally the last decade.
>
> Seeing the data flow through the program.

I'd like to try it out and see what it shows for recursive functions. >:)

> Being able to instantly see the code for all the functions related to
> your function call.

Yes, that really cool.

> 2. some way to save & store the results of the evaluation, which
> themselves are useful (right now they seem very ephemeral)

Yeah.  You write a function, then some snippet using it, you instantly
see the value it evaluated to, you think it's correct, so you hit M-x
butterfly RET [1], and bang, the snippet and the result are added to
your test suite.

Bye,
Tassilo

Footnotes:
[1] http://xkcd.com/378/

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Boolean

2012-04-13 Thread Armando Blancas
It's the other way around: false is boxed into Boolean/FALSE. Here's the if 
stmt:

public Object eval() {
Object t = testExpr.eval();
if(t != null && t != Boolean.FALSE)
return thenExpr.eval();
return elseExpr.eval();
}

On Friday, April 13, 2012 12:45:02 PM UTC-7, Andy Fingerhut wrote:
>
> One little nit that confuses me.
>
> Boolean/FALSE is documented as being of type Boolean in Java 
> documentation, yet it is treated by Clojure the same as primitive boolean 
> false:
>
> user=> (clojure-version)
> "1.3.0"
> user=> (if Boolean/FALSE "logical true" "logical false")
> "logical false"
> user=> (identical? Boolean/FALSE false)
> true
>
> Does anyone know why?
>
> Thanks,
> Andy
>
>
> On Fri, Apr 13, 2012 at 11:41 AM, Sean Corfield wrote:
>
>> On Fri, Apr 13, 2012 at 3:33 AM, Vinzent  wrote:
>> > Just like Boolean's javadoc puts a strong
>> > emphasis on the fact that public Boolean(boolean value) constructor 
>> usually
>> > shouldn't be used, clojure's docstring should say that (= x false) may 
>> give
>> > you a result which will confuse you, so you'd better use 'false?' 
>> instead.
>>
>> (def f (Boolean. false))
>> (false? f)
>> ;; => false
>> (true? f)
>> ;; => false
>> (= f false)
>> ;; => true
>> (if f :t :f)
>> ;; => :t
>>
>> So 'false?' doesn't help you here.
>>
>> No one should be using (Boolean. false) in Clojure code - we have true
>> / false. Why create a Java object whose documentation says not to do
>> it?
>>
>> So if anyone runs into this problem _in real world code_ it's because
>> they are calling a Java API that somehow returns a Java Boolean object
>> embedded in the result. If you are working with a Java data structure
>> full of _Objects_ then you need to take care of converting those
>> Object instances into appropriate Clojure values. Calling (boolean v)
>> is sufficient to convert the Java Object to a Clojure true/false
>> value.
>> --
>> Sean A Corfield -- (904) 302-SEAN
>> An Architect's View -- http://corfield.org/
>> World Singles, LLC. -- http://worldsingles.com/
>>
>> "Perfection is the enemy of the good."
>> -- Gustave Flaubert, French realist novelist (1821-1880)
>>
>> --
>> 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 first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Boolean

2012-04-13 Thread Jim - FooBar();

wow!!! i wasn't expecting that one...

Jim

On 13/04/12 21:17, Armando Blancas wrote:
It's the other way around: false is boxed into Boolean/FALSE. Here's 
the if stmt:


public Object eval() {
Object t = testExpr.eval();
if(t != null && t != Boolean.FALSE)
return thenExpr.eval();
return elseExpr.eval();
}

On Friday, April 13, 2012 12:45:02 PM UTC-7, Andy Fingerhut wrote:

One little nit that confuses me.

Boolean/FALSE is documented as being of type Boolean in Java
documentation, yet it is treated by Clojure the same as primitive
boolean false:

user=> (clojure-version)
"1.3.0"
user=> (if Boolean/FALSE "logical true" "logical false")
"logical false"
user=> (identical? Boolean/FALSE false)
true

Does anyone know why?

Thanks,
Andy


On Fri, Apr 13, 2012 at 11:41 AM, Sean Corfield
mailto:seancorfi...@gmail.com>> wrote:

On Fri, Apr 13, 2012 at 3:33 AM, Vinzent mailto:ru.vinz...@gmail.com>> wrote:
> Just like Boolean's javadoc puts a strong
> emphasis on the fact that public Boolean(boolean value)
constructor usually
> shouldn't be used, clojure's docstring should say that (= x
false) may give
> you a result which will confuse you, so you'd better use
'false?' instead.

(def f (Boolean. false))
(false? f)
;; => false
(true? f)
;; => false
(= f false)
;; => true
(if f :t :f)
;; => :t

So 'false?' doesn't help you here.

No one should be using (Boolean. false) in Clojure code - we
have true
/ false. Why create a Java object whose documentation says not
to do
it?

So if anyone runs into this problem _in real world code_ it's
because
they are calling a Java API that somehow returns a Java
Boolean object
embedded in the result. If you are working with a Java data
structure
full of _Objects_ then you need to take care of converting those
Object instances into appropriate Clojure values. Calling
(boolean v)
is sufficient to convert the Java Object to a Clojure true/false
value.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

--
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 first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/clojure?hl=en



--
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 first post.

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en 


--
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Boolean

2012-04-13 Thread Tassilo Horn
Armando Blancas  writes:

> It's the other way around: false is boxed into Boolean/FALSE.

That's exactly what I've said, no?

  TH> That [Boolean.FALSE] is the canonical false Boolean object you get
  TH> when auto-boxing the primitive boolean false, or when calling
  TH> (Boolean/valueOf).

Bye,
Tassilo

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Practical Clojure

2012-04-13 Thread David Cabana
I need to clarify something, since I unintentionally introduced
confusion into this discussion.  The initial comment by faenvie
referred to the book "Practical Clojure", a very good book (I own a
copy).  I spaced out and thought that faenvie's comment concerned the
newly released "Clojure Programming". I threw in my two bits, and a
link to a promotional release of some material from CP.  I apologize
for my carelessness. My enthusiasm for CP got the best of me.

Disclaimer: I have no financial or other stake in any of these books.
I speak only as an appreciative reader. We are fortunate that the
Clojure community is well served by several excellent books.

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Light Table - a new IDE concept

2012-04-13 Thread Daniel
My first thought is that I would contribute money for this to be actively 
developed and maintained.

My second thoughts are that it's kind of a bummer it only works in the 
browser currently, and kind of a bummer that he had to fork clojure to 
provide metadata changes, and kind of a bummer that we're encoding 
indentation into the metadata (since there's so many different styles 
around this).

But none of that changes my first thought.  :)


On Friday, April 13, 2012 1:34:54 PM UTC-5, looselytyped wrote:
>
> This is an awesome implementation of Brett Victors "Inventing On 
> Principle" [http://vimeo.com/36579366] using Clojure and Noir by Chris 
> Granger (who also wrote Noir). 
>
> Figured I would share it with the group. 
>
> http://www.chris-granger.com/2012/04/12/light-table---a-new-ide-concept/ 
>
> Raju

-- 
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 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en