I'm a big believer in Clojure / Rich Hickey's principles regarding the
separation of Identity and State (http://www.infoq.com/presentations/
Are-We-There-Yet-Rich-Hickey) and how this is generally a good idea.
However I've recently been running into what seems to be a slight
conceptual challenge w
Luc, what you're saying sounds to me like "this is the way it is so
deal with it". Can you give me some concrete code snippets showing why
it's better to box ints as Longs? Do you really think the following is
at all intuitive?
user=> (class (Integer/parseInt "1"))
java.lang.Long
user=> (class (In
On Fri, Oct 21, 2011 at 12:52 AM, nathanmarz wrote:
> user=> (class (Integer/parseInt "1"))
> java.lang.Long
(Integer/parseInt "1") returns an int - which Clojure promotes to long
(since it only has 64-bit primitives) and class takes an Object so
long is boxed to Long.
> user=> (class (Integer/v
> c) Put actor identities inside the world state - nasty! now the world
> state is mutable
Not necessarily (and I'd be interested in the replies)?
I mean, here's how I view it. If actors are part of the world, then
they are part of its state. Hence, when the state of an actor changes,
the
How about a potentially ugly workaround:
user> (defn sum [ & {:keys [x y]} ] (+ x y))
#'user/sum
user> (sum :x 1 :y 2)
3
user> (def inc-sum (partial sum :x 1))
#'user/inc-sum
user> (inc-sum :y 1)
2
user> (inc-sum :y 2)
3
user>
I know this is a trivial example, but I do quite fancy named arguments
On Oct 21, 4:25 pm, Ulises wrote:
> > c) Put actor identities inside the world state - nasty! now the world
> > state is mutable
>
> Not necessarily (and I'd be interested in the replies)?
>
> I mean, here's how I view it. If actors are part of the world, then
> they are part of its state.
> Are you arguing for my option b) then? In which case actors don't have
> distinct identities, they are just part of the overall world?
Not necessarily as your option b) already gives implementation details
(using ids to find actors, etc.). I was mostly thinking out loud to
see if anything emerge
> Luc, what you're saying sounds to me like "this is the way it is so
> deal with it". Can you give me some concrete code snippets showing why
> it's better to box ints as Longs? Do you really think the following is
> at all intuitive?
>
> user=> (class (Integer/parseInt "1"))
> java.lang.Long
> u
Ok I watched the talk, and I picked up a few things. But I have questions,
which hopefully some kind member in the community can answer.
There are several instances of libraries Rich mentions that provide simple
constructs so what clojure libraries provide, set functions and rules (is it
core.l
Hello, in portuguese there are lots of special characters (such as *á*, *é*,
*ã...*), but when I need a file with slurp I don't get this characters in
the result.
For example, if I have this line in the file: "Ferida perdida na imensidão."
When I execute (slurp file-name), I get:
"Ferida perdi
when I read* a file
--
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,
You need to tell slurp how the file is encoded.
(slurp path-to-my-file :encoding "UTF-8")
That means that you'll need to know what encoding your file is using.
If you've never dealt with encoding before, I recommend reading this:
http://www.joelonsoftware.com/articles/Unicode.html
// Ben
On Fri
Thank's a lot, bsmith.occs, it worked
I haven't consider the encoding =P
--
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
Like Stu says, this conversation is going in circle.
"Concrete code examples" cannot be a replacement for consistent rules when
designing software and especially a prog. language.
Since the beginning of this thread, you have been exposed to two of these:
a) make collections consistent
b) make co
Is the clojurescript REPL set up to allow access from remote machines?
My development box is all set up, and I'm able to connect to the REPL
from OSX Safari and Simulated Mobile Safari. Everything is localhost,
so it all works great.
I'm currently able to use my iPad and iPhone to access my devbox
Me too! It's gonna be great!
On Wed, Oct 19, 2011 at 10:30 PM, Abbas wrote:
> Look forward to your talk.
>
> Cheers,
> Abbas
>
> On Oct 18, 5:19 pm, Aaron Bedra wrote:
> > I will be there and am giving a talk in the functional web track
> >
> > http://qconsf.com/sf2011/presentation/One+%28%29+t
Hi,
may I question the transitivity of state information?
Maybe the world's state is that player "Trantor" is at position [15 34]. Now
Trantor eats an appel. The appel is removed from his inventory and his
health is raised by 5 hit points. Did the state of the world change? No.
Trantor is stil
I thought tail recursion was actually not possible on the JVM but saw
a talk on the Erlang VM yesterday and Robert Virding mentioned that
Erjang managed to do it.
I'm sure the core guys have seen it but just in case others thought
the same as me here are a few links:
http://www.javalimit.com/2009/
> And how would one structure something as stateful as a web app using these
> techniques? Hopefully someone can point to a pre-existing example that
> follows all or many of these ideas.
I currently work on a thick-client system. But our back-end is quite
stateless. One thing that irks me the mos
> Maybe the world's state is that player "Trantor" is at position [15 34]. Now
> Trantor eats an appel. The appel is removed from his inventory and his
> health is raised by 5 hit points. Did the state of the world change? No.
> Trantor is still at position [15 34]. Does the world have to know abou
Perhaps I can clarify why the 1.3 behavior is confusing. For those who have
focused on issues like "primitives need to be boxed, therefore you get a
long" - I think you are missing Nathan's point. Here is what changed about
boxing in 1.3:
Clojure 1.2:
(class (Long/parseLong "1")) => java.la
Wow. Easily the best conference talk I have seen... well, ever.
Executive summary: "Mutability is bad for your complection." :)
- Chris
--
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
No
Clojure does tail-call elimination for simple cases with loop/recur. This is
by far the most common case. Most other tail-recursive situations can be
represented as lazy sequences, which are another way to handle recursive
functions without consuming stack space. For the final rare cases (e.g.
Great talk!
I got lost a bit in the Abstraction for Simplicity. Could anybody provide me
some concrete examples for Who When Where Why slides?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups
Tom Hall writes:
> I'm sure the core guys have seen it but just in case others thought
> the same as me here are a few links:
> http://www.javalimit.com/2009/12/tail-recursion-in-erjang.html
> https://github.com/trifork/erjang/wiki/How-Erjang-compiles-tail-recursion
>
> If someone could comment b
Hmm I get no errors. But it doesn't work. I agree that would be a *real*
killer app for ClojureScript. Debugging JS on mobile browsers is a big pain.
I will try looking into it if no one else gets to it first, ticket created
http://dev.clojure.org/jira/browse/CLJS-92
David
On Thu, Oct 20, 2011 a
Hi,
I'm trying to set the classes output path different from the default
src/main/classes by overriding :javac-options {:destdir
"../../target/classes/"} and that does not seem to work. is there a property
I can use to accomplish this?
Thanks,
Siyu
--
You received this message because you
Hey Timothy,
Thanks for the response, I currently perform some of these steps. My data is
taken out of mongodb and converted into straight clojure maps. I pass these
around in my application, calling validation functions on them etc. Having
said that, this talk will push me to take a good look
Thank you both..
This information was really helpful.
Tim
On Oct 20, 6:05 pm, Andy Fingerhut wrote:
> I would suspect that you would not get a _significant_ performance advantage
> from specifying processor affinity, but if you really want to measure it and
> find out by experimentation, read on.
I've always felt that Clojure's treatment of nil was somehow inconsistent
with the elegance of many other features of Clojure. Now I can finally
articulate why: nil complects non-existence, false, and empty.
The choice to make nil represent so many concepts was an "easy" choice,
because it saves
I tried :compile-path and it worked, but it's not listed in
https://github.com/technomancy/leiningen/blob/stable/sample.project.clj
--
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 tha
If I understand your post correctly you feel that nil should
ONLY represent the concept of a missing value. It should not
represent false and empty.
Having used lisp in many different forms over the last 40 years
I think that the "complecting" of nil to represent all three
concepts is one of the m
On Fri, Oct 21, 2011 at 10:33 AM, siyu798 wrote:
> I tried :compile-path and it worked, but it's not listed
> in https://github.com/technomancy/leiningen/blob/stable/sample.project.clj
Good catch; I will add this.
-Phil
--
You received this message because you are subscribed to the Google
Grou
On Fri, Oct 21, 2011 at 10:38 AM, daly wrote:
> If I understand your post correctly you feel that nil should
> ONLY represent the concept of a missing value. It should not
> represent false and empty.
Yes, you correctly interpreted my post. That is my opinion.
> The context of the nil value
> c
On Fri, Oct 21, 2011 at 10:14 AM, Stuart Sierra
wrote:
> Clojure does tail-call elimination for simple cases with loop/recur. This is
> by far the most common case. Most other tail-recursive situations can be
> represented as lazy sequences, which are another way to handle recursive
> functions wi
On 10/21/2011 06:50 PM, Mark Engelberg wrote:
Now I can finally articulate why: nil complects non-existence, false,
and empty.
How does nil represent empty? '() does not equal nil.
It is also easy in the sense that it is more similar to what Lisp users (as
opposed to Scheme) are used to fro
Collections often include false as a value. You will have to handle it by
using some other value like ::not-found.
David
On Fri, Oct 21, 2011 at 12:50 PM, Mark Engelberg
wrote:
> I've always felt that Clojure's treatment of nil was somehow inconsistent
> with the elegance of many other features
> nil complects non-existence, false, and empty.
Let's explore that a little further:
* Non-existence
- Accessing a local or var that has never been declared
* False
- (if nil :never-here :but-here)
* Empty
- (seq [])
And maybe there is another?
* Not set
- (def x)
- (:x {:a 1})
But
On Fri, Oct 21, 2011 at 11:08 AM, Thorsten Wilms wrote:
> On 10/21/2011 06:50 PM, Mark Engelberg wrote:
>>
>> Now I can finally articulate why: nil complects non-existence, false,
>> and empty.
>
> How does nil represent empty? '() does not equal nil.
(cons 1 nil) is one obvious example.
The pa
On Fri, Oct 21, 2011 at 11:22 AM, David Nolen wrote:
> Collections often include false as a value. You will have to handle it by
> using some other value like ::not-found.
>
> David
True, but the multiple meanings of nil creates additional complexity.
Contrast, for example, (filter identity s) an
On Fri, Oct 21, 2011 at 11:43 AM, Mark Engelberg
wrote:
>> How does nil represent empty? '() does not equal nil.
>
> (cons 1 nil) is one obvious example.
>
> The pattern of using first/next/nil? as a more efficient/compact
> alternative to first/rest/empty? is arguably another.
>
One more anecdot
Thanks for looking into it!
Regarding the issue: "Cannot interact with Browser REPL running in iOS/
Webkit Mobile devices", I did try it locally on my development machine
with the iOS simulator and it works fine. For both iPhone and iPad,
and iOS version 4 and 5. Only on the actual devices, connec
Just because we have dynamic types does not give us the freedom to not
consider them.
(when s
...)
Does not communicate anything about collections - only nil, false or
something else.
(when (seq s)
...)
(when (empty? s)
...)
Clearly express a consideration about the types at play.
Davi
On Fri, Oct 21, 2011 at 12:41 PM, David Nolen wrote:
> Just because we have dynamic types does not give us the freedom to not
> consider them.
Oh, I definitely considered the types when I wrote the function. It's
just that at the time I wrote it, I was confident the input would
already be seq-if
On Fri, 2011-10-21 at 12:36 -0700, Mark Engelberg wrote:
> On Fri, Oct 21, 2011 at 11:43 AM, Mark Engelberg
> wrote:
> >> How does nil represent empty? '() does not equal nil.
> >
> > (cons 1 nil) is one obvious example.
> >
> > The pattern of using first/next/nil? as a more efficient/compact
> >
> (because test cases are written by the coder who has a
> specific intention in mind)
>
Good observation. When I see figures of tests coverage I wonder how
many flow paths aren't being covered simply because they don't exists
but they should.
--
You received this message because you are subscr
On Fri, Oct 21, 2011 at 4:02 PM, Mark Engelberg wrote:
> On Fri, Oct 21, 2011 at 12:41 PM, David Nolen
> wrote:
> > Just because we have dynamic types does not give us the freedom to not
> > consider them.
>
> Oh, I definitely considered the types when I wrote the function. It's
> just that at t
On Fri, 2011-10-21 at 15:41 -0400, David Nolen wrote:
> Just because we have dynamic types does not give us the freedom to not
> consider them.
If all of these dynamics types and all of the tests "respected nil"
in its many meanings then
(when s ...,
(when (seq s)...,
(when (empty? s)...,
Hi:
I found what I think might be considered a bug, but I'm not certain.
The doc-string for `pmap' just says that the passed-in function is
applied "in parallel," but the code as-written is pretty clearly
intended to keep only (+ 2 #CPUS) future-wrapped function applications
realized at a time. I
Another annotation bug:
Annotations on gen-class in an ns form, like (ns foo (:gen-class
^{Singleton {}} foo.ClassName)) don't seem to work.
--
__
Herwig Hochleitner
--
You received this message because you are subscribed to the G
This message is not specifically in reply to Tim, but to the thread in general.
It can be very difficult to enumerate (or even remember :) all of the
contending tradeoffs around something like Clojure's nil handling.
The is no doubt nil punning is a form of complecting. But you don't completely
Bravo, bravo! Great speech, I'm already looking for such esseys. I'm
already learning haskell and erlang for great good, because all things
told about lisp has been already read.
I'm also designing system. Because it has some well defined
functionality, my first tought was, hey man I will use obec
I'm a bit unsure as to the best way to solve this. Assuming I have the
following tree:
{:parent1
{:relationship1
{:child1 1}
{:child2 2}}
{:relationship2
{child3 3}}
{:_meta}}
I want to get:
[:parent1 :relationship1 :child1]
[:parent1 :relationship1 :child2]
[:pare
Rich,
My apologies that what I have said about nil punning came across
as criticism directed at you. That was not intentional. I have
the highest respect for your design work. You're doing an amazing
job and I continue to learn from you.
I understand the lazy vs empty issue and I think you made a
Turns out this works just fine. You need to make sure that you change:
(repl/connect "http://localhost:9000/repl";)
In your source to be the correct IP.
David
On Fri, Oct 21, 2011 at 3:39 PM, stratospark wrote:
> Thanks for looking into it!
>
> Regarding the issue: "Cannot interact with Brows
The example tree was not accepted as a valid data structure, so I used this
instead. Hopefully it represents what you had in mind:
(def tree {:parent1
{:relationship1
{:child1 1
:child2 2}
:relationship2
{:child3 3}
:_meta 4
Hello Herwig,
I checked the patch you linked to in your original post, and it doesn't seem
that type hinting for native arrays of Objects is supported, that is the [L
type. Native arrays of native types work quite well.
(definterface Name (^"[S" method [])) ;;returns array of shorts
(def p (proxy
On Fri, 2011-10-21 at 09:19 +0530, Baishampayan Ghose wrote:
> If you are going to upload your library to any Maven (or similar) repo
> that's accessible through Leiningen, then you may choose to not
> include a project.clj file; in any case, if you yourself are using
> Leiningen, you should includ
Yea let's chat on IRC. I'll ping you when I see you online.
-Nathan
On Oct 21, 4:24 am, Stuart Halloway wrote:
> > Luc, what you're saying sounds to me like "this is the way it is so
> > deal with it". Can you give me some concrete code snippets showing why
> > it's better to box ints as Longs?
Why do you think, there is a bug?
You are referring to the /code/, i.e. the implementation, of things, which
is not a defined interface. At the same time, the /documentation/ describes
the actual behavior quite well.
Chunked seqs are supposed to realize more elements than you consume. That's
f
Thanks, it works with a hardcoded IP address. I had tried using our
Bonjour network hostnames, but that doesn't seem to work. The
important thing is now I have a REPL to my iPad!
-pat
On Oct 21, 2:53 pm, David Nolen wrote:
> Turns out this works just fine. You need to make sure that you change:
Hi
I wrote the following function to create a SQL IN clause from a list
of values. Essentially the function creates a single string which is a
comma separated quoted list of the values surrounded by parenthesis.
user=> (def xs [1 2 3 4 5])
user=>(str "('" (first xs) (reduce #(str %1 "', '" %2) "
On Oct 21, 2011, at 5:37 PM, daly wrote:
> Rich,
>
> My apologies that what I have said about nil punning came across
> as criticism directed at you.
It certainly didn't come across that way - no worries :-)
Rich
--
You received this message because you are subscribed to the Google
Groups "
user=> (str "('" (apply str (interpose "', '" [1 2 3 4 5])) "')")
"('1', '2', '3', '4', '5')"
Would be a way to do it. Interpose returns a lazy sequence so you need to apply
str to realize the sequence.
Luc P.
On Fri, 21 Oct 2011 17:54:41 -0700 (PDT)
Shoeb Bhinderwala wrote:
> Hi
>
> I wrote
Augh don't do this, you are begging for SQL injection attacks. I'll
set one of the elements in your list to:
'); DROP TABLE users; --
On Oct 21, 5:54 pm, Shoeb Bhinderwala
wrote:
> Hi
>
> I wrote the following function to create a SQL IN clause from a list
> of values. Essentially the function cr
Stefan Kamphausen writes:
> Chunked seqs are supposed to realize more elements than you
> consume. That's for performance reasons. But since you will only ever
> apply side-effect-free functions to seqs, that will make no
> difference, no?
Sorry, yes, I'm talking about within the code of `pmap'
Just found another one:
You can't annotate constructors of gen-class.
2011/10/22 Ivan Koblik :
> Hello Herwig,
> I checked the patch you linked to in your original post, and it doesn't seem
> that type hinting for native arrays of Objects is supported, that is the [L
> type.
Yes. It should be.
It all depends if you sanitize the arguments yourself before building the SQL
string...
Luc
On Fri, 21 Oct 2011 19:23:22 -0700 (PDT)
Alan Malloy wrote:
> Augh don't do this, you are begging for SQL injection attacks. I'll
> set one of the elements in your list to:
> '); DROP TABLE users; --
>
Thanks. It is so much cleaner with interpose.
On Oct 21, 9:24 pm, Luc Prefontaine
wrote:
> user=> (str "('" (apply str (interpose "', '" [1 2 3 4 5])) "')")
> "('1', '2', '3', '4', '5')"
>
> Would be a way to do it. Interpose returns a lazy sequence so you need to
> apply str to realize the sequ
clojure.string/join
On Oct 21, 8:54 pm, Shoeb Bhinderwala
wrote:
> Thanks. It is so much cleaner with interpose.
>
> On Oct 21, 9:24 pm, Luc Prefontaine
> wrote:
>
>
>
>
>
>
>
> > user=> (str "('" (apply str (interpose "', '" [1 2 3 4 5])) "')")
> > "('1', '2', '3', '4', '5')"
>
> > Would be a w
On Fri, Oct 21, 2011 at 5:54 PM, Shoeb Bhinderwala
wrote:
> I wrote the following function to create a SQL IN clause from a list
> of values. Essentially the function creates a single string which is a
> comma separated quoted list of the values surrounded by parenthesis.
If you're using clojure.
Always forgetting this one :)
It performs better than the other solutions...
On Fri, 21 Oct 2011 21:15:51 -0700 (PDT)
Alan Malloy wrote:
> clojure.string/join
>
> On Oct 21, 8:54 pm, Shoeb Bhinderwala
> wrote:
> > Thanks. It is so much cleaner with interpose.
> >
> > On Oct 21, 9:24 pm, Luc P
Can't repeat this strongly enough. Do not, ever, decide you can escape/
sanitize the strings yourself so you don't need a parameterized query.
Maybe it works, but one of these days you'll slip up and get something
wrong. Just prepare a statement with the right number of ?s in it, and
then ask the S
Hm? My starter package is there:
http://aichallenge.org/starter_packages.php
They changed the game at the end and I didn't have time to update it
for hills, but it actually works just fine as is. Also, it should be
fairly trivial for someone to add that bit...
Cheers,
Chris.
On Oct 20, 11:58 am
I reread your original post, sorry I saw that you managed to declare type
constrained methods. Then, what was your question about?
Type hinting for arguments works as well:
(definterface Name
(^"[S" method [^"[S" short-arg]))
(def p (proxy [Name] []
(method [^"[S" short-arg] short-arg)))
75 matches
Mail list logo