Re: confusing macro issue: java.lang.InstantiationException

2012-01-21 Thread Cedric Greevey
On Sat, Jan 21, 2012 at 2:47 AM, drewn  wrote:
> Thank you, that works great!  It's a nice use of destructuring too,
> which I should of thought of.

...

> Thanks for a great lesson on macros!

You're welcome. :)

-- 
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: strange problem

2012-01-21 Thread Rasmus Svensson
On 19 Jan, 12:03, joachim  wrote:
> On Jan 18, 8:23 pm, Andy Fingerhut  wrote:
>
> > I don't have some code lying around to do that, but I might make one.  The
> > name strings would require several megabytes of storage, but as long as you
> > don't mind that...
>
> I wouldn't mind, but the code your provided is already more than I was
> hoping for, so thanks again!
> Jm

Have you checked out ICU4J?

Dependency: [com.ibm.icu/icu4j "4.8.1.1"]
Javadoc: http://icu-project.org/apiref/icu4j/

You can do this with it:

(require '[clojure.string :as str])
(import 'com.ibm.icu.lang.UCharacter)

(defn char-names [s]
  (UCharacter/getName s ", "))

(defn strip-supplementary [s]
  (str/replace s #"[^\u-\u]+" char-name))

(strip-supplementary "The first three letters of the Gothic
alphabet are: \uD800\uDF30\uD800\uDF31\uD800\uDF32")
;=> "The first three letters of the Gothic alphabet are: GOTHIC
LETTER AHSA, GOTHIC LETTER BAIRKAN, GOTHIC LETTER GIBA"

On 17 Jan, 19:14, Andy Fingerhut  wrote:
> Rasmus, thanks for that suggestion.  I have seen this regular expression
> before recently for the same purpose, but not an explanation for why it
> matches only supplementary characters.  Do you know, or have you read
> somewhere, a good explanation for that?

Hrm. To be honest I first tried to match characters in the range U
+D800 - U+DFFF, but that didn't work for some reason. I then googled a
bit and found the above regex. It worked so I just used it and didn't
think about it much. It is a bit weird indeed. It gives you the
impression that Java regexes is aware of supplementary characters
somehow. Maybe it would also work to match characters not outside that
range? Like this: #"[^\u-\uD7FF\uE000-\u]". That regex would
be a bit more clear, I think.

// Rasmus

-- 
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: clojure-clr loadpath points to D: harddrive

2012-01-21 Thread dmiller
On Jan 19, 10:25 pm, jayvandal  wrote:
> Why does the clr point to d: work?
> user=> (use :reload 'ui)
> FileNotFoundException Could not locate db.mysql.clj.dll or db/
> mysql.clj on load
> path.  clojure.lang.RT.load (d:\work\clojure-clr\Clojure\Clojure\Lib
> \RT.cs:3065)

It is not looking in d:\work\... to resolve the load.

The  "d:\work\clojure-clr\Clojure\Clojure\Lib\RT.cs:3065" indicates
the source line where the exception was thrown.

It should be looking for the file to load starting from the root.
>From the text, it appears there is a load or use or require within
your ui.clj looking for db/mysql.  As the error statement indicates,
starting from the current directory, it has looked for ./
db.mysql.clj.dll or   ./db/mysql.clj.  The latter being clj source,
the former being the standard name for the assembly that results from
AOT-compiling of  db/mysql.clj.  Clearly something is not where it
should be.

You can set roots other than the current working directory via the
environment variable CLOJURE_LOAD_PATH.  Actually, I'm planning a post
for http://clojureclr.blogspot.com/ regarding all environment
variables that are referenced, plus some info on AOT-compilation.

-David

-- 
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: Seemingly simple shell commands taking forever

2012-01-21 Thread techwhizbang
Thanks Phil, that was it exactly. Duly noted!

On Jan 20, 2:28 pm, Phil Hagelberg  wrote:
> techwhizbang  writes:
> > I am using lein run -m to execute a simple database preparation task.
> > I issue 2 very simple commands that execute very fast on their on own
> > when executed in the shell. They also appear to execute very fast
> > based on the print output to stdout. However, the problem is that
> > after executing the 2 clojure.java.shell sh commands the process hangs
> > on way after it completes. So much so that it feels wrong.
>
> > Here is the gist.https://gist.github.com/1635837
>
> The agent thread pool is probably keeping the process open. Try calling
> (shutdown-agents) when you're done.
>
> This is a long-standing known bug/shortcoming in Clojure:
>
>  http://dev.clojure.org/jira/browse/CLJ-124
>
> -Phil

-- 
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


[ANN] oauth-clj

2012-01-21 Thread r0man
Hi all,

I just released another OAuth library for Clojure on top of
clj-http, supporting version 1 and 2 of the OAuth protocol.

Roman.

https://github.com/r0man/oauth-clj
http://clojars.org/oauth-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 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

Must a page refresh fire an init event?

2012-01-21 Thread Folcon
I'm trying out Clojurescript one, but whenever I refresh the page the init 
event appears to fire so I lose the current state I'm in.

How can I set it so that the init event only resets my state if I don't 
have any? (I'm intending to have an explicit reset event.)

Kind Regards,
Folcon

-- 
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: Must a page refresh fire an init event?

2012-01-21 Thread Daniel Jomphe
Folcon wrote:
>
> I'm trying out Clojurescript one, but whenever I refresh the page the init 
> event appears to fire so I lose the current state I'm in.
>
> How can I set it so that the init event only resets my state if I don't 
> have any? (I'm intending to have an explicit reset event.)
>

That's the nature of the web. A page refresh in a browser clears all 
client-side, transient state. You can restore state out of persistent state 
stores (cookies on the client side, or session on the server side), or you 
can also pass state elements through the HTTP request-response workflow.

All that said, if your intention was to try your code changes while you 
were developing, I strongly encourage you to watch this very nice 
screencast [1] and read that wiki page [2].

[1] http://vimeo.com/35153207
[2] https://github.com/brentonashworth/one/wiki/Development

Also, the rest of the wiki is very interesting [3].

[3] https://github.com/brentonashworth/one/wiki

-- 
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: Must a page refresh fire an init event?

2012-01-21 Thread Daniel Jomphe
The wiki page I really meant 
is https://github.com/brentonashworth/one/wiki/Workflow

Also, obviously, restoring state out of persistent state stores can only be 
made if you've explicitly saved stuff there before the user refreshed the 
page. The same is true of the HTTP request-response workflow. No state can 
survive through a browser refresh in any case unless the developer 
provisioned one of those ways for the state to flow through.

Daniel Jomphe wrote:
>
> Folcon wrote:
>>
>> I'm trying out Clojurescript one, but whenever I refresh the page the 
>> init event appears to fire so I lose the current state I'm in.
>>
>> How can I set it so that the init event only resets my state if I don't 
>> have any? (I'm intending to have an explicit reset event.)
>>
>
> That's the nature of the web. A page refresh in a browser clears all 
> client-side, transient state. You can restore state out of persistent state 
> stores (cookies on the client side, or session on the server side), or you 
> can also pass state elements through the HTTP request-response workflow.
>
> All that said, if your intention was to try your code changes while you 
> were developing, I strongly encourage you to watch this very nice 
> screencast [1] and read that wiki page [2].
>
> [1] http://vimeo.com/35153207
> [2] https://github.com/brentonashworth/one/wiki/Development
>
> Also, the rest of the wiki is very interesting [3].
>
> [3] https://github.com/brentonashworth/one/wiki
>

-- 
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: Must a page refresh fire an init event?

2012-01-21 Thread Folcon
Hi Daniel,

I am aware of that, reading the wiki it appears that Clojurescript One 
keeps track of state in an atom and I was under the impression that it 
should be possible to recover the current state from this atom? Maybe I'm 
mistaken in this however.

Regards,
Folcon

-- 
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: Must a page refresh fire an init event?

2012-01-21 Thread Folcon
Actually thinking about this what you are saying seems to be correct, I 
just realised that the atom is stored on the client, not the server. Is 
there any cookie functionality I can access from clojurescript?

Regards,
Folcon

-- 
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

Bug in 1.3 with sets as functions?

2012-01-21 Thread Mark Engelberg
I believe it is a bug that:
(#{true false} false) yields false
whereas
(contains? #{true false} false) yields true

Can someone confirm or deny this?

-- 
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: Bug in 1.3 with sets as functions?

2012-01-21 Thread Kevin Downey
Sets when used as functions are not predicates the do not return true or
false based on membership.

They return the looked up value, in this case false. You can say "well I
passed in the value, why would I want it back" but sets don't need to
return an identical object, just an equal object (could have different
metadata etc.

This behavior is not a bug. It seems unlikely that this interface/contract
would be changed, do you have compelling case for change?
On Jan 21, 2012 7:46 PM, "Mark Engelberg"  wrote:

> I believe it is a bug that:
> (#{true false} false) yields false
> whereas
> (contains? #{true false} false) yields true
>
> Can someone confirm or deny this?
>
> --
> 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: Bug in 1.3 with sets as functions?

2012-01-21 Thread Phil Hagelberg
Mark Engelberg  writes:

> I believe it is a bug that:
> (#{true false} false) yields false
> whereas
> (contains? #{true false} false) yields true
>
> Can someone confirm or deny this?

It's intentional that calling a set as a function returns the argument
if it's a member. Part of the reason contains? exists is so that you can
find out whether nil is a member of a set.

-Phil

-- 
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: Must a page refresh fire an init event?

2012-01-21 Thread Daniel Jomphe
ClojureScript One is built on top of Ring, which provides nice middleware 
for handling cookies [1].

You may want to search for "wrap-" on the web page of One's marginalia 
documentation to see where you could add this middleware [2].

[1] https://github.com/mmcgrana/ring/wiki/Cookies
[2] http://clojurescriptone.com/documentation.html

But all of this is server-side, and if you need to persist state of which 
the server can't know about, then you need to set the cookies on the client 
side. There, accessing cookies can be done by calling standard 
cookie-handling javascript functions [3] (using ClojureScript's interop to 
javascript). Or you may prefer to use the Cookies class that comes with the 
Google Closure Library that's part of ClojureScript [4], which I would 
advise to do if you need to manage cookies client-side.

[3] http://www.w3schools.com/js/js_cookies.asp
[4] http://closure-library.googlecode.com/svn/docs/class_goog_net_Cookies.html

As for how to call either of those things from ClojureScript, I suggest 
looking at One's source code for lots of examples. (One doesn't use cookies 
at all but you'll see lots of calls of js stuff, and lots of usages of 
Closure Library stuff.)

On Saturday, January 21, 2012 9:37:26 PM UTC-5, Folcon wrote:
>
> Actually thinking about this what you are saying seems to be correct, I 
> just realised that the atom is stored on the client, not the server. Is 
> there any cookie functionality I can access from clojurescript?
>
> Regards,
> Folcon
>

-- 
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: Must a page refresh fire an init event?

2012-01-21 Thread Folcon
Thanks a lot Daniel, much appreciated!

-- 
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: Bug in 1.3 with sets as functions?

2012-01-21 Thread Mark Engelberg
Ah yes.  I knew that.  I've seen it on this list dozens of times.  And
yet, when it bit me, I was still surprised.  

-- 
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: Bug in 1.3 with sets as functions?

2012-01-21 Thread Mark Engelberg
Thanks for reminding me.

-- 
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: Bug in 1.3 with sets as functions?

2012-01-21 Thread Mark Engelberg
Upon some introspection as to why I failed to remember this subtle
point, I realized that:
1. I expect get on sets to do the behavior where it returns the item.
2. I expect contains? on sets to do the behavior where it returns true or false.
3. I (incorrectly) expected function application of a set to behave
like contains? not get.

-- 
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