Error when compiling the node.js example on the quick page.

2012-10-19 Thread Jiajian Huang
I am trying clojurescript right now and when I compiling the node example 
on the quick page, an error happens.

 * temp : cat nodehello.cljs
(ns nodehello)

(defn -main [& args]
  (println (apply str (map [\ "world" "hello"] [2 0 1]

(set! *main-cli-fn* -main)

 * temp : cljsc nodehello.cljs '{:target :nodejs}' > nodehello.js
Oct 20, 2012 2:02:05 PM com.google.javascript.jscomp.LoggerErrorManager 
println
SEVERE: cljs.nodejscli:3: ERROR - required "cljs.nodejs" namespace never 
provided
goog.require('cljs.nodejs');
^

Oct 20, 2012 2:02:05 PM com.google.javascript.jscomp.LoggerErrorManager 
printSummary
WARNING: 1 error(s), 0 warning(s)

Can somebody tell me what's that mean?

-- 
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: data.json 0.2.0

2012-10-19 Thread Michael Klishin
2012/10/20 Sean Corfield 

> Just bringing this up as a general issue for discussion around breaking
> API changes in low-level libraries that many things may depend on.


I'd like to point out that there was 0 upfront communication about the
changes and it was not made clear in the
announcement that this release completely breaks public API (saying that
you have a new API is not enough).

I moved all clojurewerkz.org projects off of c.d.json after I saw breaking
changes that (back then) not only were not announced but
also were not mentioned in the README or anywhere else.

Note that if there were some clojure-dev posts about this, it does not
count because the majority of the ecosystem cannot
join that list and has no easy way (or motivation, honestly) to follow it.

I believe that communicating breaking changes to popular libraries loud and
clear, on this mailing list, is very important.
Twice as important for Contrib projects.

Keeping a file like [1] for every project is a must. c.d.json does have
a change log
at the bottom of README file but most Contrib projects, for example, do not.

1. https://github.com/michaelklishin/welle/blob/master/ChangeLog.md
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
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: CLJS: println stopped working (r1514) ?

2012-10-19 Thread Frank Siebenlist
When I eval in the cljs-repl:

(set! *print-fn* clojure.browser.repl/repl-print)

all works again.

Seems that the "(defmethod handle-post :ready [_ conn _] …)" in 
cljs.repl.browser doesn't assign the *print-fn* in the cljs-repl (?).

Not sure if anything changed there (?).

-FS.


On Oct 19, 2012, at 7:56 PM, Frank Siebenlist  
wrote:

> Not sure if its my cljs-config somehow (working off head r1514), but println 
> doesn't seem to be working anymore:
> 
> ClojureScript:cljs.user> (println "JAJA")
> "Error evaluating:" (println "JAJA") :as 
> "cljs.core.println.call(null,\"JAJA\");\n"
> #
> _STAR_print_fn_STAR_@http://10.0.1.18:9000/js/main-debug.js:1821
> string_print@http://10.0.1.18:9000/js/main-debug.js:18711
> pr_with_opts@http://10.0.1.18:9000/js/main-debug.js:18984
> println__delegate@http://10.0.1.18:9000/js/main-debug.js:19098
> println@http://10.0.1.18:9000/js/main-debug.js:19102
> 
> 
> eval code
> eval@[native code]
> @http://10.0.1.18:9000/js/main-debug.js:29720
> evaluate_javascript@http://10.0.1.18:9000/js/main-debug.js:29719
> @http://10.0.1.18:9000/js/main-debug.js:29799
> deliver@http://10.0.1.18:9000/js/main-debug.js:25554
> deliver_@http://10.0.1.18:9000/js/main-debug.js:26665
> messageReceived_@http://10.0.1.18:9000/js/main-debug.js:26258
> handleEvent@http://10.0.1.18:9000/js/main-debug.js:21161
> fireListener@http://10.0.1.18:9000/js/main-debug.js:21661
> handleBrowserEvent_@http://10.0.1.18:9000/js/main-debug.js:21726
> f@http://10.0.1.18:9000/js/main-debug.js:21265
> [native code]
> nil
> ClojureScript:cljs.user> 
> 
> 
> Is it just me or…
> 
> -FrankS.

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


CLJS: println stopped working (r1514) ?

2012-10-19 Thread Frank Siebenlist
Not sure if its my cljs-config somehow (working off head r1514), but println 
doesn't seem to be working anymore:

ClojureScript:cljs.user> (println "JAJA")
"Error evaluating:" (println "JAJA") :as 
"cljs.core.println.call(null,\"JAJA\");\n"
#
_STAR_print_fn_STAR_@http://10.0.1.18:9000/js/main-debug.js:1821
string_print@http://10.0.1.18:9000/js/main-debug.js:18711
pr_with_opts@http://10.0.1.18:9000/js/main-debug.js:18984
println__delegate@http://10.0.1.18:9000/js/main-debug.js:19098
println@http://10.0.1.18:9000/js/main-debug.js:19102


eval code
eval@[native code]
@http://10.0.1.18:9000/js/main-debug.js:29720
evaluate_javascript@http://10.0.1.18:9000/js/main-debug.js:29719
@http://10.0.1.18:9000/js/main-debug.js:29799
deliver@http://10.0.1.18:9000/js/main-debug.js:25554
deliver_@http://10.0.1.18:9000/js/main-debug.js:26665
messageReceived_@http://10.0.1.18:9000/js/main-debug.js:26258
handleEvent@http://10.0.1.18:9000/js/main-debug.js:21161
fireListener@http://10.0.1.18:9000/js/main-debug.js:21661
handleBrowserEvent_@http://10.0.1.18:9000/js/main-debug.js:21726
f@http://10.0.1.18:9000/js/main-debug.js:21265
[native code]
nil
ClojureScript:cljs.user> 


Is it just me or…

-FrankS.

-- 
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: UTF-8 behavior ClojureScript (vs. Clojure)

2012-10-19 Thread Chas Emerick
I've filed a CLJS issue for this, and attached a patch:

http://dev.clojure.org/jira/browse/CLJS-400

Thanks for keeping on this, Dave. :-)

- Chas

On Oct 19, 6:18 pm, Dave Sann  wrote:
> Chas, If your patch works without issue - this is probably better because
> it will then work with existing versions of Clojure - clojurescript is
> changing faster and people a probably upgrading faster.
>
> I don't think it does any harm for Clojure to be able to read these chars
> but fixing the interchange the the real issue (for me).
>
> Stu closed 1025 already.
>
> Dave

-- 
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: data.json 0.2.0

2012-10-19 Thread Sean Corfield
Removing the old API causes problems for projects that have transitive
dependencies on multiple versions of c.d.json.

For example, congomongo depends on c.d.json 0.1.3, specifically on
json-str. At World Singles we depend on c.d.json directly and we depend on
congomongo. We can't move to c.d.json 0.2.0 because that breaks congomongo
(json-str no longer available).

I can update congomongo to c.d.json 0.2.0 of course but then anything that
depends on congomongo and c.d.json will be forced to update to c.d.json
0.2.0 as well, if they want an updated congomongo.

Just bringing this up as a general issue for discussion around breaking API
changes in low-level libraries that many things may depend on.

(FWIW, I'm probably going to update congomongo to use c.d.json 0.2.0 and
bump it's version number to indicate a breaking change, then update World
Singles dependency on both congomongo and c.d.json).

On Fri, Oct 19, 2012 at 12:03 PM, Stuart Sierra  wrote:

> https://github.com/clojure/data.json
>
> Highlights:
> - New API
> - Customizable type conversion functions
> - big int and big decimal support
> - Performance improvements
>
>

-- 
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: UTF-8 behavior ClojureScript (vs. Clojure)

2012-10-19 Thread Dave Sann
Chas, If your patch works without issue - this is probably better because 
it will then work with existing versions of Clojure - clojurescript is 
changing faster and people a probably upgrading faster. 

I don't think it does any harm for Clojure to be able to read these chars 
but fixing the interchange the the real issue (for me).

Stu closed 1025 already.

Dave

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread Sean Corfield
On Fri, Oct 19, 2012 at 12:53 AM, Kevin Downey  wrote:

> conj can surely produce maps, and does so happily in the following cases:
>

Doh! Of course. Thank you for the correction. I assumed that was his
problem without actually trying it - my bad :(
-- 
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: Write stream to two outputs

2012-10-19 Thread Herwig Hochleitner
The typehint of output should be ^java.io.OutputStream, sorry.

Also to your use case:

If you don't actually want to stream simultanously, you need to write the
data into a buffer and later stream from that.

Sorry again for the whopping triple post.

-- 
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: Write stream to two outputs

2012-10-19 Thread Herwig Hochleitner
Sorry, I mistakenly pressed the send shortcut in gmail. The
modified-version of io/copy is:

(defn copy-multi
  ([input outputs] (copy-multi input outputs (make-array Byte/TYPE 1024)))
  ([^java.io.InputStream input outputs buffer]
 (let [size (.read input buffer)]
   (when (pos? size)
 (doseq [^java.io.OutputStrean output outputs]
   (.write output buffer 0 size))
 (recur input outputs buffer)

>

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

Write stream to two outputs

2012-10-19 Thread Petar Radosevic
Hi,

I'm building an app (MIT license) which let's you share files easily
without depending on a third party service like CloudApp or Droplr. I'm
having the following problem; while uploading the file to your server I
want to stream the file directly to S3 and disk. Why both? Because when
the request returns, the user should be able to share the returned link
immediately. This link returns a S3 download URI. I also need to have
the file on disk to do some extra work like calculating the sha1sum and
store this to db.

I came up with the following uproach. By `loop`ing through the stream,
1024 bytes at a time I though I could write those bytes to two
outputs. I couldn't use `io/copy` because this would only allow me to
use a single output.


(defn save-to-disk [file]
  "Saves a temporary file to disk to further analyse it"
  (let [inputstream (:body file)
pipe-in (java.io.PipedInputStream.)
pipe-out (java.io.PipedOutputStream. pipe-in)]
;; when below works, wrap it in 'future
(with-open [in (io/input-stream inputstream)
file-out (io/output-stream "/tmp/test.txt")]
  (loop [buf (make-array Byte/TYPE 1024)]
(let [len (.read in buf)]
  (when (pos? len)
(doseq [out [file-out pipe-out]]
  (.write out buf 0 len))
(recur buf)
(assoc file :body pipe-in)))

The above does not work, it _does_ work when I only write to
`file-out`. Writing to only `pipe-out` does not work and writing to both
stops after 1024 bytes. My understanding of IO is lacking to solve the
above, would love if somebody could educate me.

Thanks in advance!
-- 
Petar Radosevic | @wunki

-- 
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: ClojureScript release 0.0-1513

2012-10-19 Thread Stuart Sierra
ClojureScript release 0.0-1513 is on its way to the Maven Central 
Repository.

Changes: http://build.clojure.org/job/clojurescript-release/18/

-S

-- 
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 there any reason to make different file extension (clj and cljs) for Clojure and ClojureScript?

2012-10-19 Thread David Nolen
On Fri, Oct 19, 2012 at 3:02 PM, Tamreen Khan  wrote:

> While Clojurescript aims to be close to Clojure, they're still
> different languages, with entirely different compilers. Much of the
> Clojure toolchain uses the extension to figure out how to compile a
> given file. Otherwise, as far as I know there's no reasonable way to
> tell apart Clojure code from Clojurescript code.


These issues could probably be surmounted with Feature Expressions:
http://dev.clojure.org/display/design/Feature+Expressions

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: Is there any reason to make different file extension (clj and cljs) for Clojure and ClojureScript?

2012-10-19 Thread Tamreen Khan
While Clojurescript aims to be close to Clojure, they're still
different languages, with entirely different compilers. Much of the
Clojure toolchain uses the extension to figure out how to compile a
given file. Otherwise, as far as I know there's no reasonable way to
tell apart Clojure code from Clojurescript code.

On Fri, Oct 19, 2012 at 9:24 AM, Mamun  wrote:
> Hi All,
>
> I've just started to learn Clojure and interested to see more ClojureScript.
> It is really nice stuff- data structure, function and code sharing. But Is
> there any reason to make different file extension (*.clj and *.cljs) for
> Clojure and ClojureScript?
>
> Regards,
> Mamun
>
> --
> 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


ANN: data.json 0.2.0

2012-10-19 Thread Stuart Sierra
https://github.com/clojure/data.json

Highlights:
- New API
- Customizable type conversion functions
- big int and big decimal support
- Performance improvements

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread AtKaaZ
Does the println show you what you expect?

On Fri, Oct 19, 2012 at 5:35 PM, larry google groups <
lawrencecloj...@gmail.com> wrote:

>
> > I suggesting adding printlns or logging or a debugger
> > and checking the
> > value of this-users-params, it is almost certainly not
> > what you expect
> > it to be.
>
> I already showed the output of the println statements I'd done, but I'll
> go through this again.
>
> I eventually try to output my info as JSON, like this:
>
> (defn current-users [request]
>   "The default action of this app. Add new users to the registry, and
> delete the ones that are more than 15 seconds old"
>   (let [this-users-params (:params request)]
> (add-to-logged-in-registry this-users-params)
> (remove-old-registrants)
> (response (apply str (json/write-str @registry)
>
> When I ran this at the REPL, everything worked great, but I was feeding it
> ideal information (no nil values). When I uploaded it to the server and the
> site users started hitting this thing (the Javascript in their browsers
> sent all kinds of calls). Then I started getting strange values, including
> a lot of empty calls. I can fix the Javascript, and I will, but I decided I
> also needed to protect the Clojure code.
>
> I originally had this:
>
> (def registry (atom {}))
>
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (println apply str new-user-entry)
>
>   (swap! registry assoc (:username new-user-entry) new-user-entry)))
>
> But on the server I would get errors like:
>
> 2012-10-19
> 02:01:26.214:WARN:oejs.AbstractHttpConnection:/?username=karlorihoo&first_name=Karlo&last_name=Rihoo&user_image=java.lang.Exception:
> JSON object properties may not be nil
> at clojure.data.json$default_write_key_fn.invoke(json.clj:28)
> at clojure.data.json$write_object.invoke(json.clj:313)
> at clojure.data.json$fn__109$G__104__116.invoke(json.clj:279)
>
> So I wanted to add this if statement:
>
> (defn add-to-logged-in-registry [this-users-params]
>   "We assume some user is looking at a site such as wpquestions.com and
> the Javascript on that site is sending an Ajax request to this app, every
> 10 seconds, with a map of information about the user, which we need to
> store in the registry."
>
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (println apply str new-user-entry)
>
> (if-not (nil? (:username new-user-entry))
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> But then the line with swap! never seemed to get called and the registry
> remained empty no matter what I threw at this, including hardcoded "nil"s.
>
>
>
>
>
>
>
>
>
> On Friday, October 19, 2012 3:53:26 AM UTC-4, red...@gmail.com wrote:
>
>> conj can surely produce maps, and does so happily in the following cases:
>>
>> (conj {} [:foo :bar])
>> (conj {} {:foo :bar})
>>
>> I suggesting adding printlns or logging or a debugger and checking the
>> value of this-users-params, it is almost certainly not what you expect
>> it to be.
>>
>> as a side note creating a date object just to call getTime is kind of
>> gross, try (System/currentTimeMillis)
>>
>> On Fri, Oct 19, 2012 at 12:42 AM, Sean Corfield 
>> wrote:
>> > On Fri, Oct 19, 2012 at 12:10 AM, larry google groups
>> >  wrote:
>> >>
>> >> (defn add-to-logged-in-registry [this-users-params]
>> >>   (let [right-now (. (Date.) getTime)
>> >> new-user-entry (conj this-users-params { "updated" right-now
>> })]
>> >> (if (:username new-user-entry)
>> >>   (swap! registry assoc (:username new-user-entry)
>> new-user-entry
>> >>
>> >> The if statement seems to never be true.
>> >
>> >
>> > conj produces a sequence, not a map, so the lookup of :username fails.
>> Try
>> > new-user-entry (assoc this-users-params "updated" right-now)
>> > --
>> > 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 clo...@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+u...@**googlegroups.com
>> > For more options, visit this group at
>> > http://groups.google.com/**group/clojure?hl=en
>>
>>
>>
>> --
>> And what is good, Phaedrus,
>> And what is not good—
>> Need we ask anyone to tell us these things?
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send

Re: I can get this if() clause to ever be true

2012-10-19 Thread AtKaaZ
maybe make the string "username" be a symbol ie. 'username

On Fri, Oct 19, 2012 at 6:39 PM, larry google groups <
lawrencecloj...@gmail.com> wrote:

> >you have `username` a symbol as the key in your map, but you are
> >looking for `:username` they keyword as a key
>
> Ah, interesting, perhaps I tested this somewhere else. To be sure, I tried
> this again:
>
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (println apply str new-user-entry)
> (if-not (nil? (get new-user-entry "username"))
>
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> And now I am back to the error I had before I had any if() statement, so
> now I think data is getting into registry. My problem with JSON must be
> elsewhere, but I don't understand what, exactly, the problem is.
>
> # # clojure.core$str@34902478> {updated 1350664352323, username Raer,
> first_name Raier, last_name Lis, user_image Raier_phptZ2nEJ.jpg, site
> www.javascriptquestions.com}
> 2012-10-19
> 12:32:32.324:WARN:oejs.AbstractHttpConnection:/?username=Raier&first_name=Raier&last_name=Lis&user_image=Raier_phptZ2nEJ.jpg&site=
> www.javascriptquestions.com
>
> java.lang.Exception: JSON object properties may not be nil
> at clojure.data.json$default_write_key_fn.invoke(json.clj:28)
> at clojure.data.json$write_object.invoke(json.clj:313)
> at clojure.data.json$fn__109$G__104__116.invoke(json.clj:279)
> at clojure.data.json$write.doInvoke(json.clj:423)
> at clojure.lang.RestFn.invoke(RestFn.java:425)
> at clojure.lang.AFn.applyToHelper(AFn.java:163)
> at clojure.lang.RestFn.applyTo(RestFn.java:132)
> at clojure.core$apply.invoke(core.clj:604)
> at clojure.data.json$write_str.doInvoke(json.clj:430)
> at clojure.lang.RestFn.invoke(RestFn.java:410)
> at who_is_logged_in.core$current_users.invoke(core.clj:43)
> at clojure.lang.AFn.applyToHelper(AFn.java:161)
> at clojure.lang.AFn.applyTo(AFn.java:151)
> at clojure.core$apply.invoke(core.clj:602)
> at net.cgrand.moustache$delegate$fn__397.invoke(moustache.clj:186)
> at who_is_logged_in.core$fn__536.invoke(core.clj:50)
> at ring.middleware.params$wrap_params$fn__271.invoke(params.clj:55)
> at clojure.lang.Var.invoke(Var.java:401)
> at ring.adapter.jetty$proxy_handler$fn__496.invoke(jetty.clj:18)
> at
> ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle(Unknown
> Source)
> at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
> at org.eclipse.jetty.server.Server.handle(Server.java:349)
> at
> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
> at
> org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:884)
> at
> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:938)
> at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
> at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
> at
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
> at java.lang.Thread.run(Unknown Source)
>
>
>
>
>
>
>
>
>
>
>
> On Friday, October 19, 2012 12:26:15 PM UTC-4, larry google groups wrote:
>>
>> >you have `username` a symbol as the key in your map, but you are
>> >looking for `:username` they keyword as a key
>>
>> At some point I tried:
>>
>> (get new-user-entry "username")
>>
>> but that had the same result.
>>
>> Username is clearly a key, yes?
>>
>> What would you suggest?
>>
>>
>>
>>
>> On Friday, October 19, 2012 12:06:10 PM UTC-4, red...@gmail.com wrote:
>>>
>>> you have `username` a symbol as the key in your map, but you are
>>> looking for `:username` they keyword as a key
>>>
>>> On Fri, Oct 19, 2012 at 8:47 AM, larry google groups
>>>  wrote:
>>> >
>>> >
>>> > Also:
>>> >
>>> >
>>> >
>>> >> I suggesting adding printlns or logging or a debugger and checking
>>> the
>>> >> value of this-users-params, it is almost certainly not what you
>>> expect
>>> >> it to be.
>>> >
>>> > I showed the output previously, but I will do it again.
>>> >
>>> > If I add a println like this:
>>> >
>>> >
>>> > (defn add-to-logged-in-registry [this-users-params]
>>> >   (let [right-now (. (Date.) getTime)
>>> > new-user-entry (conj this-users-params { "updated" right-now
>>> })]
>>> > (println apply str new-user-entry)
>>> >
>>> > (if (:use

Re: I can get this if() clause to ever be true

2012-10-19 Thread AtKaaZ
On Fri, Oct 19, 2012 at 6:39 PM, larry google groups <
lawrencecloj...@gmail.com> wrote:

> >you have `username` a symbol as the key in your map, but you are
> >looking for `:username` they keyword as a key
>
> Ah, interesting, perhaps I tested this somewhere else. To be sure, I tried
> this again:
>
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (println apply str new-user-entry)
> (if-not (nil? (get new-user-entry "username"))
>
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
also don't forget this here

>
> And now I am back to the error I had before I had any if() statement, so
> now I think data is getting into registry. My problem with JSON must be
> elsewhere, but I don't understand what, exactly, the problem is.
>
> # # clojure.core$str@34902478> {updated 1350664352323, username Raer,
> first_name Raier, last_name Lis, user_image Raier_phptZ2nEJ.jpg, site
> www.javascriptquestions.com}
> 2012-10-19
> 12:32:32.324:WARN:oejs.AbstractHttpConnection:/?username=Raier&first_name=Raier&last_name=Lis&user_image=Raier_phptZ2nEJ.jpg&site=
> www.javascriptquestions.com
>
> java.lang.Exception: JSON object properties may not be nil
> at clojure.data.json$default_write_key_fn.invoke(json.clj:28)
> at clojure.data.json$write_object.invoke(json.clj:313)
> at clojure.data.json$fn__109$G__104__116.invoke(json.clj:279)
> at clojure.data.json$write.doInvoke(json.clj:423)
> at clojure.lang.RestFn.invoke(RestFn.java:425)
> at clojure.lang.AFn.applyToHelper(AFn.java:163)
> at clojure.lang.RestFn.applyTo(RestFn.java:132)
> at clojure.core$apply.invoke(core.clj:604)
> at clojure.data.json$write_str.doInvoke(json.clj:430)
> at clojure.lang.RestFn.invoke(RestFn.java:410)
> at who_is_logged_in.core$current_users.invoke(core.clj:43)
> at clojure.lang.AFn.applyToHelper(AFn.java:161)
> at clojure.lang.AFn.applyTo(AFn.java:151)
> at clojure.core$apply.invoke(core.clj:602)
> at net.cgrand.moustache$delegate$fn__397.invoke(moustache.clj:186)
> at who_is_logged_in.core$fn__536.invoke(core.clj:50)
> at ring.middleware.params$wrap_params$fn__271.invoke(params.clj:55)
> at clojure.lang.Var.invoke(Var.java:401)
> at ring.adapter.jetty$proxy_handler$fn__496.invoke(jetty.clj:18)
> at
> ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle(Unknown
> Source)
> at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
> at org.eclipse.jetty.server.Server.handle(Server.java:349)
> at
> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
> at
> org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:884)
> at
> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:938)
> at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
> at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
> at
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
> at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
> at java.lang.Thread.run(Unknown Source)
>
>
>
>
>
>
>
>
>
>
>
> On Friday, October 19, 2012 12:26:15 PM UTC-4, larry google groups wrote:
>>
>> >you have `username` a symbol as the key in your map, but you are
>> >looking for `:username` they keyword as a key
>>
>> At some point I tried:
>>
>> (get new-user-entry "username")
>>
>> but that had the same result.
>>
>> Username is clearly a key, yes?
>>
>> What would you suggest?
>>
>>
>>
>>
>> On Friday, October 19, 2012 12:06:10 PM UTC-4, red...@gmail.com wrote:
>>>
>>> you have `username` a symbol as the key in your map, but you are
>>> looking for `:username` they keyword as a key
>>>
>>> On Fri, Oct 19, 2012 at 8:47 AM, larry google groups
>>>  wrote:
>>> >
>>> >
>>> > Also:
>>> >
>>> >
>>> >
>>> >> I suggesting adding printlns or logging or a debugger and checking
>>> the
>>> >> value of this-users-params, it is almost certainly not what you
>>> expect
>>> >> it to be.
>>> >
>>> > I showed the output previously, but I will do it again.
>>> >
>>> > If I add a println like this:
>>> >
>>> >
>>> > (defn add-to-logged-in-registry [this-users-params]
>>> >   (let [right-now (. (Date.) getTime)
>>> > new-user-entry (conj this-users-params { "updated" right-now
>>> })]
>>> > (println apply str new-user-entry)
>>> >
>>> > (if (:username new-user-en

Is there any reason to make different file extension (clj and cljs) for Clojure and ClojureScript?

2012-10-19 Thread Mamun
Hi All,

I've just started to learn Clojure and interested to see more 
ClojureScript. It is really nice stuff- data structure, function and code 
sharing. But Is there any reason to make different file extension (*.clj 
and *.cljs) for Clojure and ClojureScript?

Regards,
Mamun

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread AtKaaZ
On Fri, Oct 19, 2012 at 5:47 PM, larry google groups <
lawrencecloj...@gmail.com> wrote:

>
>
> Also:
>
>
>
> > I suggesting adding printlns or logging or a debugger and checking the
> > value of this-users-params, it is almost certainly not what you expect
> > it to be.
>
> I showed the output previously, but I will do it again.
>
> If I add a println like this:
>
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (println apply str new-user-entry)
>
> (if (:username new-user-entry)
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> This code works perfectly at the REPL so to show a problem I have to
> upload this to the live server. So I compile this and upload it to the
> server and start it up and immediately the Javascript in the browsers of
> dozens of users starts to bombard the app:
>
> java -jar who-is-logged-in-1.0.1-standalone.jar 4
> App 'Who is logged in?' is starting
> port:  4
> 2012-10-19 11:37:02.731:INFO:oejs.Server:jetty-7.x.y-SNAPSHOT
> 2012-10-19 11:37:02.846:INFO:oejs.AbstractConnector:Started
> SelectChannelConnector@0.0.0.0:4
>
> # # clojure.core$str@7dfde44e> {updated 1350661023079, username rumbella,
> first_name , last_name , user_image , site www.wpquestions.com}
>
I'm a little confused here, is first_name nil or missing the value ? if it
were nil then nil would show

>
> # # clojure.core$str@7dfde44e> {updated 1350661023140, username karlorihoo,
> first_name Karlo, last_name Rihoo, user_image , site www.wpquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661023698}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024149, username Rainner,
> first_name Rainner, last_name Lins, user_image Rainner_phptZ2nEJ.jpg, site
> www.javascriptquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024159}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024269}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024646}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024833, username dbranes,
> first_name Dbranes, last_name , user_image dbranes_phpPJVl3f.jpg, site
> www.wpquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661025140, username Christianto,
> first_name Christianto, last_name , user_image Christianto_phpqESzHW.jpg,
> site www.wpquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661025337, username jsoni,
> first_name Jatin, last_name Soni, user_image jsoni_phpYlWQTr.jpg, site
> www.wpquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661025651}
>
> # # clojure.core$str@7dfde44e> {updated 1350661025996}
>
> So, why does this not work? And what is the right way to be sure that this:
>
> {updated 1350661025996}
>
> Is never added to the registry (since there is no username).
>
>
>
>
>
>
>
>
>
>
> On Friday, October 19, 2012 3:53:26 AM UTC-4, red...@gmail.com wrote:
>
>> conj can surely produce maps, and does so happily in the following cases:
>>
>> (conj {} [:foo :bar])
>> (conj {} {:foo :bar})
>>
>> I suggesting adding printlns or logging or a debugger and checking the
>> value of this-users-params, it is almost certainly not what you expect
>> it to be.
>>
>> as a side note creating a date object just to call getTime is kind of
>> gross, try (System/currentTimeMillis)
>>
>> On Fri, Oct 19, 2012 at 12:42 AM, Sean Corfield 
>> wrote:
>> > On Fri, Oct 19, 2012 at 12:10 AM, larry google groups
>> >  wrote:
>> >>
>> >> (defn add-to-logged-in-registry [this-users-params]
>> >>   (let [right-now (. (Date.) getTime)
>> >> new-user-entry (conj this-users-params { "updated" right-now
>> })]
>> >> (if (:username new-user-entry)
>> >>   (swap! registry assoc (:username new-user-entry)
>> new-user-entry
>> >>
>> >> The if statement seems to never be true.
>> >
>> >
>> > conj produces a sequence, not a map, so the lookup of :username fails.
>> Try
>> > new-user-entry (assoc this-users-params "updated" right-now)
>> > --
>> > 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 clo...@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+u...@**googlegroups.com
>> > For more options, visit this group at
>> > http://groups.google.com/**group/clojure?hl=en
>>
>>
>>
>> --
>> And what is good, Phaedrus,
>> And what is not good—
>> Need we ask anyone to tell us these things?
>>
>  --
> You received this message because you are subs

Re: I can get this if() clause to ever be true

2012-10-19 Thread AtKaaZ
(get {:username "a"} "username")
nil
(get {:username "a"} :username)
"a"
*(get {'username "a"} :username)*
nil
(get {'username "a"} 'username)
"a"
(get {:username "a"} 'username)
nil
*(get {'username "a"} "username")*
nil

On Fri, Oct 19, 2012 at 6:26 PM, larry google groups <
lawrencecloj...@gmail.com> wrote:

> >you have `username` a symbol as the key in your map, but you are
> >looking for `:username` they keyword as a key
>
> At some point I tried:
>
> (get new-user-entry "username")
>
> but that had the same result.
>
> Username is clearly a key, yes?
>
> What would you suggest?
>
>
>
>
>
> On Friday, October 19, 2012 12:06:10 PM UTC-4, red...@gmail.com wrote:
>
>> you have `username` a symbol as the key in your map, but you are
>> looking for `:username` they keyword as a key
>>
>> On Fri, Oct 19, 2012 at 8:47 AM, larry google groups
>>  wrote:
>> >
>> >
>> > Also:
>> >
>> >
>> >
>> >> I suggesting adding printlns or logging or a debugger and checking the
>> >> value of this-users-params, it is almost certainly not what you expect
>> >> it to be.
>> >
>> > I showed the output previously, but I will do it again.
>> >
>> > If I add a println like this:
>> >
>> >
>> > (defn add-to-logged-in-registry [this-users-params]
>> >   (let [right-now (. (Date.) getTime)
>> > new-user-entry (conj this-users-params { "updated" right-now
>> })]
>> > (println apply str new-user-entry)
>> >
>> > (if (:username new-user-entry)
>> >   (swap! registry assoc (:username new-user-entry)
>> new-user-entry
>> >
>> > This code works perfectly at the REPL so to show a problem I have to
>> upload
>> > this to the live server. So I compile this and upload it to the server
>> and
>> > start it up and immediately the Javascript in the browsers of dozens of
>> > users starts to bombard the app:
>> >
>> > java -jar who-is-logged-in-1.0.1-**standalone.jar 4
>> > App 'Who is logged in?' is starting
>> > port:  4
>> > 2012-10-19 11:37:02.731:INFO:oejs.Server:**jetty-7.x.y-SNAPSHOT
>> > 2012-10-19 11:37:02.846:INFO:oejs.**AbstractConnector:Started
>> > SelectChannelConnector@0.0.0.**0:4
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661023079, username rumbella,
>> > first_name , last_name , user_image , site www.wpquestions.com}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661023140, username
>> karlorihoo,
>> > first_name Karlo, last_name Rihoo, user_image , site
>> www.wpquestions.com}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661023698}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661024149, username Rainner,
>> > first_name Rainner, last_name Lins, user_image Rainner_phptZ2nEJ.jpg,
>> site
>> > www.javascriptquestions.com}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661024159}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661024269}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661024646}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661024833, username dbranes,
>> > first_name Dbranes, last_name , user_image dbranes_phpPJVl3f.jpg, site
>> > www.wpquestions.com}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661025140, username
>> Christianto,
>> > first_name Christianto, last_name , user_image
>> Christianto_phpqESzHW.jpg,
>> > site www.wpquestions.com}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661025337, username jsoni,
>> > first_name Jatin, last_name Soni, user_image jsoni_phpYlWQTr.jpg, site
>> > www.wpquestions.com}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661025651}
>> >
>> > # #> > clojure.core$str@7dfde44e> {updated 1350661025996}
>> >
>> > So, why does this not work? And what is the right way to be sure that
>> this:
>> >
>> > {updated 1350661025996}
>> >
>> > Is never added to the registry (since there is no username).
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Friday, October 19, 2012 3:53:26 AM UTC-4, red...@gmail.com wrote:
>> >>
>> >> conj can surely produce maps, and does so happily in the following
>> cases:
>> >>
>> >> (conj {} [:foo :bar])
>> >> (conj {} {:foo :bar})
>> >>
>> >> I suggesting adding printlns or logging or a debugger and checking the
>> >> value of this-users-params, it is almost certainly not what you expect
>> >> it to be.
>> >>
>> >> as a side note creating a date object just to call getTime is kind of
>> >> gross, try (System/currentTimeMillis)
>> >>
>> >> On Fri, Oct 19, 2012 at 12:42 AM, Sean Corfield 
>> >> wrote:
>> >> > On Fri, Oct 19, 2012 at 12:10 AM, larry google groups
>> >> >  wrote:
>> >> >>
>> >> >> (defn add-to-logged-in-registry [this-users-params]
>> >> >>   (let [right-now (. (Date.) getTime)
>> >> >> new-user-entry (conj this-users-params { "updated"
>> right-now
>> >> >> })]
>> >> >> (if (:username new-user-entry)
>> >> >>   (swap! registry assoc (:username new-user-entry)
>> >> >> new-user-entry
>> >> >>
>> >> >> The if statemen

Re: I can get this if() clause to ever be true

2012-10-19 Thread larry google groups
Okay, thanks for that last tip. I removed the use of :username everywhere 
and instead replaced it with:

(get new-user-entry "username")

everywhere in the code. Now everything works fine. I realize now that was 
the big difference between the REPL and the live server -- I used :username 
at the REPL, but the Ajax calls are sending in strings that become symbols. 








On Friday, October 19, 2012 3:10:19 AM UTC-4, larry google groups wrote:
>
> Assume data that looks like this:
>
> {ziri {:last_name ziri, :image ziggy_stardust.jpg, :username larry, 
> :first_name larry, updated 1350626694791}, erich {:last_name 7ich, 
> :image 7ot_mein.jpg, :username erich, :first_name 754545_halle, 
> updated 1350626679436}}
>
>
> When fed into the next function, the data looks like this:
>
> {:last_name 7ich, :image 7ot_mein.jpg, :username erich, 
> :first_name 754545_halle, updated 1350626679436}
>
> The function looks like this, but I can not get the if statement to ever 
> run as if true. 
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (if (:username new-user-entry)
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> The if statement seems to never be true. 
>
> I also tried: 
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (if-not (nil? (:username new-user-entry))
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
>
> and I tried this with "contains": 
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (if (contains?  new-user-entry :username))
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> But it seems as if the branch following the if statement is never run, no 
> matter what I do. 
>
> Why? 
>
>
>
>

-- 
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: UTF-8 behavior ClojureScript (vs. Clojure)

2012-10-19 Thread Chas Emerick
On Oct 19, 2012, at 11:25 AM, David Nolen wrote:

> On Fri, Oct 19, 2012 at 4:52 AM, Henrik Mohr  wrote:
> Still I hope someone can answer the question on why ClojureScript behaves 
> differently from Clojure.
> 
> Output from Clojure:
> user=> (str "ø")
> "ø"
> 
> Output from ClojureScript:
>   #_=> (str "ø")
> "\xF8"
> 
> Output from node.js:
> > console.log ("ø");
> ø
> 
> Output from Chrome Console:
> console.log ("ø")
> ø
> 
> Anyone from Clojure Core that can comment on this?
> 
> Thanks in advance.
> 
> BRgds,
> Henrik
> 
> I believe this may be due to the logic in compiler.clj on lines 70-84. 
> Perhaps the condition on line 82 should be a bit broader, (< 31 cp 256) 
> instead of (< 31 cp 127) ?
> 
> I'm not sure ... if somebody else could chime in on that logic that would 
> help.

It's simpler than that; cljs is just using an inappropriate string quoting 
mechanism.

See http://groups.google.com/group/clojure-dev/msg/f679b8759b3fc54f and the 
linked issue and proposed patch.  (…which I've not filed with an issue yet 
because I think we should first come to some closure on whether it or the 
originally-proposed enhancement to JVM Clojure in CLJ-1025 is a better path.)

- Chas


-- 
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: Core.logic performance of looping over a list with tabling

2012-10-19 Thread David Nolen
On Fri, Oct 19, 2012 at 11:47 AM, Coen De Roover  wrote:

> Hi David,
>
> What are your plans about the tables?
> I would side with the title of the issue rather than its description :)
>

I don't have any current plans to further improve the performance of
tabling. The only thing I am looking to fix is the inability to reset
tables between runs. In fact I think it should be the default behavior -
they reset.

I agree that there should be some way to preserve the current behavior if
that is desirable.

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: I can get this if() clause to ever be true

2012-10-19 Thread larry google groups
>you have `username` a symbol as the key in your map, but you are 
>looking for `:username` they keyword as a key 

Ah, interesting, perhaps I tested this somewhere else. To be sure, I tried 
this again:

(defn add-to-logged-in-registry [this-users-params]
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { "updated" right-now })]
(println apply str new-user-entry)
(if-not (nil? (get new-user-entry "username"))
  (swap! registry assoc (:username new-user-entry) new-user-entry

And now I am back to the error I had before I had any if() statement, so 
now I think data is getting into registry. My problem with JSON must be 
elsewhere, but I don't understand what, exactly, the problem is. 

# # {updated 1350664352323, username Raer, 
first_name Raier, last_name Lis, user_image Raier_phptZ2nEJ.jpg, site 
www.javascriptquestions.com}
2012-10-19 
12:32:32.324:WARN:oejs.AbstractHttpConnection:/?username=Raier&first_name=Raier&last_name=Lis&user_image=Raier_phptZ2nEJ.jpg&site=www.javascriptquestions.com
java.lang.Exception: JSON object properties may not be nil
at clojure.data.json$default_write_key_fn.invoke(json.clj:28)
at clojure.data.json$write_object.invoke(json.clj:313)
at clojure.data.json$fn__109$G__104__116.invoke(json.clj:279)
at clojure.data.json$write.doInvoke(json.clj:423)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invoke(core.clj:604)
at clojure.data.json$write_str.doInvoke(json.clj:430)
at clojure.lang.RestFn.invoke(RestFn.java:410)
at who_is_logged_in.core$current_users.invoke(core.clj:43)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:602)
at net.cgrand.moustache$delegate$fn__397.invoke(moustache.clj:186)
at who_is_logged_in.core$fn__536.invoke(core.clj:50)
at ring.middleware.params$wrap_params$fn__271.invoke(params.clj:55)
at clojure.lang.Var.invoke(Var.java:401)
at ring.adapter.jetty$proxy_handler$fn__496.invoke(jetty.clj:18)
at 
ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle(Unknown
 
Source)
at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at 
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
at 
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:884)
at 
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:938)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:634)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
at 
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
at java.lang.Thread.run(Unknown Source)










On Friday, October 19, 2012 12:26:15 PM UTC-4, larry google groups wrote:
>
> >you have `username` a symbol as the key in your map, but you are 
> >looking for `:username` they keyword as a key 
>
> At some point I tried:
>
> (get new-user-entry "username")
>
> but that had the same result. 
>
> Username is clearly a key, yes? 
>
> What would you suggest?
>
>
>
>
> On Friday, October 19, 2012 12:06:10 PM UTC-4, red...@gmail.com wrote:
>>
>> you have `username` a symbol as the key in your map, but you are 
>> looking for `:username` they keyword as a key 
>>
>> On Fri, Oct 19, 2012 at 8:47 AM, larry google groups 
>>  wrote: 
>> > 
>> > 
>> > Also: 
>> > 
>> > 
>> > 
>> >> I suggesting adding printlns or logging or a debugger and checking the 
>> >> value of this-users-params, it is almost certainly not what you expect 
>> >> it to be. 
>> > 
>> > I showed the output previously, but I will do it again. 
>> > 
>> > If I add a println like this: 
>> > 
>> > 
>> > (defn add-to-logged-in-registry [this-users-params] 
>> >   (let [right-now (. (Date.) getTime) 
>> > new-user-entry (conj this-users-params { "updated" right-now 
>> })] 
>> > (println apply str new-user-entry) 
>> > 
>> > (if (:username new-user-entry) 
>> >   (swap! registry assoc (:username new-user-entry) 
>> new-user-entry 
>> > 
>> > This code works perfectly at the REPL so to show a problem I have to 
>> upload 
>> > this to the live server. So I compile this and upload it to the server 
>> and 
>> > start it up and immediately the Javascript in t

Re: XML parsing with namespace prefixes

2012-10-19 Thread Jack Moffitt
>> (zf/xml-> zipper :ListRecords :record :metadata :oai_dc:dc :dc:language
>> zf/text)

This would require a namespace aware thing, but a possible syntax for
this (called Clark notation) is to use the URI of the namespace
instead of the prefix:

(zf/xml-> zipper :ListRecords :record :metadata :dc
:language zf/text)

jack.

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread larry google groups
>you have `username` a symbol as the key in your map, but you are 
>looking for `:username` they keyword as a key 

At some point I tried:

(get new-user-entry "username")

but that had the same result. 

Username is clearly a key, yes? 

What would you suggest?




On Friday, October 19, 2012 12:06:10 PM UTC-4, red...@gmail.com wrote:
>
> you have `username` a symbol as the key in your map, but you are 
> looking for `:username` they keyword as a key 
>
> On Fri, Oct 19, 2012 at 8:47 AM, larry google groups 
> > wrote: 
> > 
> > 
> > Also: 
> > 
> > 
> > 
> >> I suggesting adding printlns or logging or a debugger and checking the 
> >> value of this-users-params, it is almost certainly not what you expect 
> >> it to be. 
> > 
> > I showed the output previously, but I will do it again. 
> > 
> > If I add a println like this: 
> > 
> > 
> > (defn add-to-logged-in-registry [this-users-params] 
> >   (let [right-now (. (Date.) getTime) 
> > new-user-entry (conj this-users-params { "updated" right-now })] 
> > (println apply str new-user-entry) 
> > 
> > (if (:username new-user-entry) 
> >   (swap! registry assoc (:username new-user-entry) 
> new-user-entry 
> > 
> > This code works perfectly at the REPL so to show a problem I have to 
> upload 
> > this to the live server. So I compile this and upload it to the server 
> and 
> > start it up and immediately the Javascript in the browsers of dozens of 
> > users starts to bombard the app: 
> > 
> > java -jar who-is-logged-in-1.0.1-standalone.jar 4 
> > App 'Who is logged in?' is starting 
> > port:  4 
> > 2012-10-19 11:37:02.731:INFO:oejs.Server:jetty-7.x.y-SNAPSHOT 
> > 2012-10-19 11:37:02.846:INFO:oejs.AbstractConnector:Started 
> > SelectChannelConnector@0.0.0.0:4 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661023079, username rumbella, 
> > first_name , last_name , user_image , site www.wpquestions.com} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661023140, username karlorihoo, 
> > first_name Karlo, last_name Rihoo, user_image , site www.wpquestions.com} 
>
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661023698} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661024149, username Rainner, 
> > first_name Rainner, last_name Lins, user_image Rainner_phptZ2nEJ.jpg, 
> site 
> > www.javascriptquestions.com} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661024159} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661024269} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661024646} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661024833, username dbranes, 
> > first_name Dbranes, last_name , user_image dbranes_phpPJVl3f.jpg, site 
> > www.wpquestions.com} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661025140, username Christianto, 
> > first_name Christianto, last_name , user_image 
> Christianto_phpqESzHW.jpg, 
> > site www.wpquestions.com} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661025337, username jsoni, 
> > first_name Jatin, last_name Soni, user_image jsoni_phpYlWQTr.jpg, site 
> > www.wpquestions.com} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661025651} 
> > 
> > # # > clojure.core$str@7dfde44e> {updated 1350661025996} 
> > 
> > So, why does this not work? And what is the right way to be sure that 
> this: 
> > 
> > {updated 1350661025996} 
> > 
> > Is never added to the registry (since there is no username). 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Friday, October 19, 2012 3:53:26 AM UTC-4, red...@gmail.com wrote: 
> >> 
> >> conj can surely produce maps, and does so happily in the following 
> cases: 
> >> 
> >> (conj {} [:foo :bar]) 
> >> (conj {} {:foo :bar}) 
> >> 
> >> I suggesting adding printlns or logging or a debugger and checking the 
> >> value of this-users-params, it is almost certainly not what you expect 
> >> it to be. 
> >> 
> >> as a side note creating a date object just to call getTime is kind of 
> >> gross, try (System/currentTimeMillis) 
> >> 
> >> On Fri, Oct 19, 2012 at 12:42 AM, Sean Corfield  
> >> wrote: 
> >> > On Fri, Oct 19, 2012 at 12:10 AM, larry google groups 
> >> >  wrote: 
> >> >> 
> >> >> (defn add-to-logged-in-registry [this-users-params] 
> >> >>   (let [right-now (. (Date.) getTime) 
> >> >> new-user-entry (conj this-users-params { "updated" right-now 
> >> >> })] 
> >> >> (if (:username new-user-entry) 
> >> >>   (swap! registry assoc (:username new-user-entry) 
> >> >> new-user-entry 
> >> >> 
> >> >> The if statement seems to never be true. 
> >> > 
> >> > 
> >> > conj produces a sequence, not a map, so the lookup of :username 
> fails. 
> >> > Try 
> >> > new-user-entry (assoc this-users-params "updated" right-now) 
> >> > -- 
> >> > 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 g

Re: I can get this if() clause to ever be true

2012-10-19 Thread Kevin Downey
you have `username` a symbol as the key in your map, but you are
looking for `:username` they keyword as a key

On Fri, Oct 19, 2012 at 8:47 AM, larry google groups
 wrote:
>
>
> Also:
>
>
>
>> I suggesting adding printlns or logging or a debugger and checking the
>> value of this-users-params, it is almost certainly not what you expect
>> it to be.
>
> I showed the output previously, but I will do it again.
>
> If I add a println like this:
>
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (println apply str new-user-entry)
>
> (if (:username new-user-entry)
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> This code works perfectly at the REPL so to show a problem I have to upload
> this to the live server. So I compile this and upload it to the server and
> start it up and immediately the Javascript in the browsers of dozens of
> users starts to bombard the app:
>
> java -jar who-is-logged-in-1.0.1-standalone.jar 4
> App 'Who is logged in?' is starting
> port:  4
> 2012-10-19 11:37:02.731:INFO:oejs.Server:jetty-7.x.y-SNAPSHOT
> 2012-10-19 11:37:02.846:INFO:oejs.AbstractConnector:Started
> SelectChannelConnector@0.0.0.0:4
>
> # # clojure.core$str@7dfde44e> {updated 1350661023079, username rumbella,
> first_name , last_name , user_image , site www.wpquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661023140, username karlorihoo,
> first_name Karlo, last_name Rihoo, user_image , site www.wpquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661023698}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024149, username Rainner,
> first_name Rainner, last_name Lins, user_image Rainner_phptZ2nEJ.jpg, site
> www.javascriptquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024159}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024269}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024646}
>
> # # clojure.core$str@7dfde44e> {updated 1350661024833, username dbranes,
> first_name Dbranes, last_name , user_image dbranes_phpPJVl3f.jpg, site
> www.wpquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661025140, username Christianto,
> first_name Christianto, last_name , user_image Christianto_phpqESzHW.jpg,
> site www.wpquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661025337, username jsoni,
> first_name Jatin, last_name Soni, user_image jsoni_phpYlWQTr.jpg, site
> www.wpquestions.com}
>
> # # clojure.core$str@7dfde44e> {updated 1350661025651}
>
> # # clojure.core$str@7dfde44e> {updated 1350661025996}
>
> So, why does this not work? And what is the right way to be sure that this:
>
> {updated 1350661025996}
>
> Is never added to the registry (since there is no username).
>
>
>
>
>
>
>
>
>
>
> On Friday, October 19, 2012 3:53:26 AM UTC-4, red...@gmail.com wrote:
>>
>> conj can surely produce maps, and does so happily in the following cases:
>>
>> (conj {} [:foo :bar])
>> (conj {} {:foo :bar})
>>
>> I suggesting adding printlns or logging or a debugger and checking the
>> value of this-users-params, it is almost certainly not what you expect
>> it to be.
>>
>> as a side note creating a date object just to call getTime is kind of
>> gross, try (System/currentTimeMillis)
>>
>> On Fri, Oct 19, 2012 at 12:42 AM, Sean Corfield 
>> wrote:
>> > On Fri, Oct 19, 2012 at 12:10 AM, larry google groups
>> >  wrote:
>> >>
>> >> (defn add-to-logged-in-registry [this-users-params]
>> >>   (let [right-now (. (Date.) getTime)
>> >> new-user-entry (conj this-users-params { "updated" right-now
>> >> })]
>> >> (if (:username new-user-entry)
>> >>   (swap! registry assoc (:username new-user-entry)
>> >> new-user-entry
>> >>
>> >> The if statement seems to never be true.
>> >
>> >
>> > conj produces a sequence, not a map, so the lookup of :username fails.
>> > Try
>> > new-user-entry (assoc this-users-params "updated" right-now)
>> > --
>> > 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 clo...@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+u...@googlegroups.com
>> > For more options, visit this group at
>> > http://groups.google.com/group/clojure?hl=en
>>
>>
>>
>> --
>> And what is good, Phaedrus,
>> And what is not good—
>> Need we ask anyone to tell us these things?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this gro

Re: Core.logic performance of looping over a list with tabling

2012-10-19 Thread Coen De Roover

On 17 Oct 2012, at 19:31, David Nolen  wrote:

> On Mon, Oct 8, 2012 at 10:00 AM, Reinout Stevens  wrote:
> Another question: is it possible to manually reset the contents of the tables?
> 
> 
> Thanks a lot
> 
> 
> Reinout
> 
> After some more thinking, I agree that the current behavior is not only 
> counter intuitive, but simply awful :) 
> 
> http://dev.clojure.org/jira/browse/LOGIC-59
> 
> I'd like to address this issue before taking 0.8.0 out of beta.
> 
> David


Hi David,

What are your plans about the tables? 
I would side with the title of the issue rather than its description :) 

At least for Ekeko, it does not make sense to keep the tables in between runs 
as the Eclipse workspace that is being queried changes continuously. The same 
is probably true for all applications that query an external data structure. 
The downside of volatile tables is that applications with a more static "fact 
base" incur an overhead.
A compromise might be to provide hooks through which the tables can be reset. 
In general, the ideal solution is probably application-specfic but it never 
hurts to err on the safe side :)

Coen

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread larry google groups


Also:


> I suggesting adding printlns or logging or a debugger and checking the 
> value of this-users-params, it is almost certainly not what you expect 
> it to be. 

I showed the output previously, but I will do it again. 

If I add a println like this:

(defn add-to-logged-in-registry [this-users-params]
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { "updated" right-now })]
(println apply str new-user-entry)
(if (:username new-user-entry)
  (swap! registry assoc (:username new-user-entry) new-user-entry

This code works perfectly at the REPL so to show a problem I have to upload 
this to the live server. So I compile this and upload it to the server and 
start it up and immediately the Javascript in the browsers of dozens of 
users starts to bombard the app:

java -jar who-is-logged-in-1.0.1-standalone.jar 4
App 'Who is logged in?' is starting
port:  4
2012-10-19 11:37:02.731:INFO:oejs.Server:jetty-7.x.y-SNAPSHOT
2012-10-19 11:37:02.846:INFO:oejs.AbstractConnector:Started 
SelectChannelConnector@0.0.0.0:4

# # {updated 1350661023079, username rumbella, 
first_name , last_name , user_image , site www.wpquestions.com}

# # {updated 1350661023140, username karlorihoo, 
first_name Karlo, last_name Rihoo, user_image , site www.wpquestions.com}

# # {updated 1350661023698}

# # {updated 1350661024149, username Rainner, 
first_name Rainner, last_name Lins, user_image Rainner_phptZ2nEJ.jpg, site 
www.javascriptquestions.com}

# # {updated 1350661024159}

# # {updated 1350661024269}

# # {updated 1350661024646}

# # {updated 1350661024833, username dbranes, 
first_name Dbranes, last_name , user_image dbranes_phpPJVl3f.jpg, site 
www.wpquestions.com}

# # {updated 1350661025140, username Christianto, 
first_name Christianto, last_name , user_image Christianto_phpqESzHW.jpg, 
site www.wpquestions.com}

# # {updated 1350661025337, username jsoni, 
first_name Jatin, last_name Soni, user_image jsoni_phpYlWQTr.jpg, site 
www.wpquestions.com}

# # {updated 1350661025651}

# # {updated 1350661025996}

So, why does this not work? And what is the right way to be sure that this:

{updated 1350661025996}

Is never added to the registry (since there is no username). 










On Friday, October 19, 2012 3:53:26 AM UTC-4, red...@gmail.com wrote:
>
> conj can surely produce maps, and does so happily in the following cases: 
>
> (conj {} [:foo :bar]) 
> (conj {} {:foo :bar}) 
>
> I suggesting adding printlns or logging or a debugger and checking the 
> value of this-users-params, it is almost certainly not what you expect 
> it to be. 
>
> as a side note creating a date object just to call getTime is kind of 
> gross, try (System/currentTimeMillis) 
>
> On Fri, Oct 19, 2012 at 12:42 AM, Sean Corfield 
> > 
> wrote: 
> > On Fri, Oct 19, 2012 at 12:10 AM, larry google groups 
> > > wrote: 
> >> 
> >> (defn add-to-logged-in-registry [this-users-params] 
> >>   (let [right-now (. (Date.) getTime) 
> >> new-user-entry (conj this-users-params { "updated" right-now 
> })] 
> >> (if (:username new-user-entry) 
> >>   (swap! registry assoc (:username new-user-entry) 
> new-user-entry 
> >> 
> >> The if statement seems to never be true. 
> > 
> > 
> > conj produces a sequence, not a map, so the lookup of :username fails. 
> Try 
> > new-user-entry (assoc this-users-params "updated" right-now) 
> > -- 
> > 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 clo...@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+u...@googlegroups.com  
> > For more options, visit this group at 
> > http://groups.google.com/group/clojure?hl=en 
>
>
>
> -- 
> And what is good, Phaedrus, 
> And what is not good— 
> Need we ask anyone to tell us these things? 
>

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread larry google groups


On Friday, October 19, 2012 3:10:19 AM UTC-4, larry google groups wrote:
>
> Assume data that looks like this:
>
> {ziri {:last_name ziri, :image ziggy_stardust.jpg, :username larry, 
> :first_name larry, updated 1350626694791}, erich {:last_name 7ich, 
> :image 7ot_mein.jpg, :username erich, :first_name 754545_halle, 
> updated 1350626679436}}
>
>
> When fed into the next function, the data looks like this:
>
> {:last_name 7ich, :image 7ot_mein.jpg, :username erich, 
> :first_name 754545_halle, updated 1350626679436}
>
> The function looks like this, but I can not get the if statement to ever 
> run as if true. 
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (if (:username new-user-entry)
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> The if statement seems to never be true. 
>
> I also tried: 
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (if-not (nil? (:username new-user-entry))
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
>
> and I tried this with "contains": 
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (if (contains?  new-user-entry :username))
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> But it seems as if the branch following the if statement is never run, no 
> matter what I do. 
>
> Why? 
>
>
>
>

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread larry google groups

> I suggesting adding printlns or logging or a debugger 
> and checking the 
> value of this-users-params, it is almost certainly not 
> what you expect 
> it to be. 

I already showed the output of the println statements I'd done, but I'll go 
through this again. 

I eventually try to output my info as JSON, like this:

(defn current-users [request]
  "The default action of this app. Add new users to the registry, and 
delete the ones that are more than 15 seconds old"
  (let [this-users-params (:params request)]
(add-to-logged-in-registry this-users-params)
(remove-old-registrants)
(response (apply str (json/write-str @registry)

When I ran this at the REPL, everything worked great, but I was feeding it 
ideal information (no nil values). When I uploaded it to the server and the 
site users started hitting this thing (the Javascript in their browsers 
sent all kinds of calls). Then I started getting strange values, including 
a lot of empty calls. I can fix the Javascript, and I will, but I decided I 
also needed to protect the Clojure code. 

I originally had this:

(def registry (atom {}))

(defn add-to-logged-in-registry [this-users-params]
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { "updated" right-now })]
(println apply str new-user-entry)
  (swap! registry assoc (:username new-user-entry) new-user-entry)))

But on the server I would get errors like: 

2012-10-19 
02:01:26.214:WARN:oejs.AbstractHttpConnection:/?username=karlorihoo&first_name=Karlo&last_name=Rihoo&user_image=java.lang.Exception:
 
JSON object properties may not be nil
at clojure.data.json$default_write_key_fn.invoke(json.clj:28)
at clojure.data.json$write_object.invoke(json.clj:313)
at clojure.data.json$fn__109$G__104__116.invoke(json.clj:279)

So I wanted to add this if statement:

(defn add-to-logged-in-registry [this-users-params]
  "We assume some user is looking at a site such as wpquestions.com and the 
Javascript on that site is sending an Ajax request to this app, every 10 
seconds, with a map of information about the user, which we need to store 
in the registry."
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { "updated" right-now })]
(println apply str new-user-entry)
(if-not (nil? (:username new-user-entry))
  (swap! registry assoc (:username new-user-entry) new-user-entry

But then the line with swap! never seemed to get called and the registry 
remained empty no matter what I threw at this, including hardcoded "nil"s. 









On Friday, October 19, 2012 3:53:26 AM UTC-4, red...@gmail.com wrote:
>
> conj can surely produce maps, and does so happily in the following cases: 
>
> (conj {} [:foo :bar]) 
> (conj {} {:foo :bar}) 
>
> I suggesting adding printlns or logging or a debugger and checking the 
> value of this-users-params, it is almost certainly not what you expect 
> it to be. 
>
> as a side note creating a date object just to call getTime is kind of 
> gross, try (System/currentTimeMillis) 
>
> On Fri, Oct 19, 2012 at 12:42 AM, Sean Corfield 
> > 
> wrote: 
> > On Fri, Oct 19, 2012 at 12:10 AM, larry google groups 
> > > wrote: 
> >> 
> >> (defn add-to-logged-in-registry [this-users-params] 
> >>   (let [right-now (. (Date.) getTime) 
> >> new-user-entry (conj this-users-params { "updated" right-now 
> })] 
> >> (if (:username new-user-entry) 
> >>   (swap! registry assoc (:username new-user-entry) 
> new-user-entry 
> >> 
> >> The if statement seems to never be true. 
> > 
> > 
> > conj produces a sequence, not a map, so the lookup of :username fails. 
> Try 
> > new-user-entry (assoc this-users-params "updated" right-now) 
> > -- 
> > 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 clo...@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+u...@googlegroups.com  
> > For more options, visit this group at 
> > http://groups.google.com/group/clojure?hl=en 
>
>
>
> -- 
> And what is good, Phaedrus, 
> And what is not good— 
> Need we ask anyone to tell us these things? 
>

-- 
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: UTF-8 behavior ClojureScript (vs. Clojure)

2012-10-19 Thread David Nolen
On Fri, Oct 19, 2012 at 4:52 AM, Henrik Mohr  wrote:

> Still I hope someone can answer the question on why ClojureScript behaves
> differently from Clojure.
>
> Output from Clojure:
> user=> (str "ø")
> *"ø"*
>
> Output from ClojureScript:
>   #_=> (str "ø")
> *"\xF8"*
>
> Output from node.js:
> > console.log ("ø");
> *ø*
>
> Output from Chrome Console:
> console.log ("ø")
> *ø*
>
> Anyone from Clojure Core that can comment on this?
>
> Thanks in advance.
>
> BRgds,
> Henrik
>

I believe this may be due to the logic in compiler.clj on lines 70-84.
Perhaps the condition on line 82 should be a bit broader, (< 31 cp 256)
instead of (< 31 cp 127) ?

I'm not sure ... if somebody else could chime in on that logic that would
help.

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: Redubicle NIO

2012-10-19 Thread Herwig Hochleitner
>  - Herwig Holchleitner: how would that solution with protocols be? I write
> a protocol that defines methods like `get` and `duplicate` and extend it
> for each buffer, delegating the methods to their specific implementations?
> ie, (defprotocol UnifiedBuffers (get [buff] "get data from buf") (duplicate
> [buff] "duplicates buff")), (extend-protocol UnifiedBuffers ByteBuffer
> (get [buff] (.get buff)) LongBuffer (get [buff] (.get buff)))?
>
>
exactly!


>  - David: about the solution you propose, is it somehow considered
> "cleaner" or "faster" or "more idiomatic" or, in any way, "better" than the
> solution I'm proposing? The advantages might be way more subtle than my
> small knowledge of Clojure allow me to understand -- I'm new in the Clojure
> community, I might be missing some common idioms. I'd be glad if you could
> expand on that!
>
>
David's solution is more decomposed. You get the full speed of hinted types
without needing to worry about macro stuff like double eval and with the
generated code being first-class and reusable.

kind regards

-- 
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: Replacing nested let statements with assignments

2012-10-19 Thread Bob Hutchison

On 2012-10-18, at 2:11 PM, Evan Gamble  wrote:

> For the situation where the lets are nested because you're checking the 
> values in some way after each binding, I wrote a macro called let?. I find it 
> very useful and use it in nearly all my code. 
> https://github.com/egamble/let-else

Hmmm, I can see how that might be very handy… like having guards on each 
binding. Thanks.

Cheers,
Bob

> 
> 
> -- 
> 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: Rouge: Ruby + Clojure

2012-10-19 Thread Arlen Christian Mart Cuss
Hi again,

On Friday, October 12, 2012 10:40:28 PM UTC+11, Arlen Christian Mart Cuss 
wrote:
>
> https://github.com/unnali/rouge#readme
>

As an aside, I've set up a Google Group mailing list for discussion and 
announcements:

https://groups.google.com/forum/#!forum/rouge-talk 

Cheers,

Arlen

-- 
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: Rouge: Ruby + Clojure

2012-10-19 Thread Arlen Christian Mart Cuss
Hi Armando,

On Wednesday, October 17, 2012 2:48:44 AM UTC+11, Armando Blancas wrote:
>
> Finally came around to install a recent Ruby build and ran a little test 
> script just to get a feel for the startup time. Looks good, though the 
> faster the merrier.


That's a neat little check!  It's encouraging, too, as I haven't done much 
work in terms of optimisation yet.  I think we have a lot of scope for 
further improvement! :)

Cheers,

Arlen

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread AtKaaZ
On Fri, Oct 19, 2012 at 9:10 AM, larry google groups <
lawrencecloj...@gmail.com> wrote:

> Assume data that looks like this:
>
> {ziri {:last_name ziri, :image ziggy_stardust.jpg, :username larry,
> :first_name larry, updated 1350626694791}, erich {:last_name 7ich,
> :image 7ot_mein.jpg, :username erich, :first_name 754545_halle,
> updated 1350626679436}}
>
>
> When fed into the next function, the data looks like this:
>
> {:last_name 7ich, :image 7ot_mein.jpg, :username erich,
> :first_name 754545_halle, updated 1350626679436}
>
> The function looks like this, but I can not get the if statement to ever
> run as if true.
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
>
so if you replace this:

> (if (:username new-user-entry)
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
with like (println (:username new-user-entry)) or even just
(println new-user-entry)
do you see what's expected? I imagine on the latter you would see this?
{:last_name 7ich, :image 7ot_mein.jpg, :username erich,
:first_name 754545_halle, updated 1350626679436}

>
> The if statement seems to never be true.
>
> I also tried:
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (if-not (nil? (:username new-user-entry))
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
>
> and I tried this with "contains":
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (if (contains?  new-user-entry :username))
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> But it seems as if the branch following the if statement is never run, no
> matter what I do.
>
> Why?
>
>
>
>  --
> 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




-- 
I may be wrong or incomplete.
Please express any corrections / additions,
they are encouraged and appreciated.
At least one entity is bound to be transformed if you do ;)

-- 
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: Rouge: Ruby + Clojure

2012-10-19 Thread Arlen Christian Mart Cuss
On Wednesday, October 17, 2012 2:20:09 PM UTC+11, Brian Marick wrote:

>  hash.become(TimesliceShaped) 
>

For the longest time I thought you were talking about the core Hash#become 
(Hash#replace since 2002!).  I've since become acquainted with Stunted. :)

That said, I'm a sucker for "non-OO" design, even in Ruby—I tend to prefer 
explicitly naming the (module+)function and thus making it clear how data 
are being transformed.  This is just a personal preference, but I suppose 
it might also help with not internalising any bad ideas about a given 
(Functional)Hash *being* a particular thing by virtue of the methods we've 
attached thus far.

(I'll admit here and now, though, that I'm out of depth in experience, and 
will see how wrong I can prove myself in the coming days. :-))

-- 
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: UTF-8 behavior ClojureScript (vs. Clojure)

2012-10-19 Thread Henrik Mohr
Still I hope someone can answer the question on why ClojureScript behaves 
differently from Clojure.

Output from Clojure:
user=> (str "ø")
*"ø"*

Output from ClojureScript:
  #_=> (str "ø")
*"\xF8"*

Output from node.js:
> console.log ("ø");
*ø*

Output from Chrome Console:
console.log ("ø")
*ø*

Anyone from Clojure Core that can comment on this?

Thanks in advance.

BRgds,
Henrik



On Thursday, October 18, 2012 2:17:22 PM UTC+2, Andy Fingerhut wrote:
>
> Hopefully someone else can answer why there is a difference in the output 
> of the str function.  I suspect in ClojureScript's case, it is simply the 
> default behavior to use \x and two hex digits to display a character in a 
> string with a code point in the range 128 through 255, inherited from 
> JavaScript, whereas in Clojure/JVM it uses the currently specified 
> character set encoding of the underlying JVM.
>
> As far as Clojure/JVM being able to read strings encoded in this way, 
> there is an enhancement request ticket CLJ-1025 open, and there is recent 
> discussion on the Clojure Dev group about whether this enhancement should 
> be included in the yet-to-be-released Clojure 1.5:
>
> http://dev.clojure.org/jira/browse/CLJ-1025
>
> Andy
>
> On Oct 18, 2012, at 4:12 AM, Henrik Mohr wrote:
>
> Hi there!
>
> I'm wondering why ClojureScript seems to handle international characters 
> differently from Clojure.
>
> Simple example in Clojure (= my preferred behaviour):
> user=> (str "ø")
> "ø"
>
> The same example in ClojureScript:
> ClojureScript:cljs.user>   #_=> (str 'ø')
> "\xF8'"
>
> Can anyone explain to me why ClojureScript behaves like that?
>
> I need to send strings from ClojureScript to a remote service, so I need 
> the output from ClojureScript to be straight UTF-8 encoded strings.
>
> Because when the (Clojure based) remote service receives the string from 
> ClojureScript it doesn't decode it correctly with read-string:
> Exception: java.lang.RuntimeException: Unsupported escape character: \x
>
> Anyone?
>
> Thanks.
>
> Best regards,
> Henrik
>
>

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread Kevin Downey
conj can surely produce maps, and does so happily in the following cases:

(conj {} [:foo :bar])
(conj {} {:foo :bar})

I suggesting adding printlns or logging or a debugger and checking the
value of this-users-params, it is almost certainly not what you expect
it to be.

as a side note creating a date object just to call getTime is kind of
gross, try (System/currentTimeMillis)

On Fri, Oct 19, 2012 at 12:42 AM, Sean Corfield  wrote:
> On Fri, Oct 19, 2012 at 12:10 AM, larry google groups
>  wrote:
>>
>> (defn add-to-logged-in-registry [this-users-params]
>>   (let [right-now (. (Date.) getTime)
>> new-user-entry (conj this-users-params { "updated" right-now })]
>> (if (:username new-user-entry)
>>   (swap! registry assoc (:username new-user-entry) new-user-entry
>>
>> The if statement seems to never be true.
>
>
> conj produces a sequence, not a map, so the lookup of :username fails. Try
> new-user-entry (assoc this-users-params "updated" right-now)
> --
> 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



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

-- 
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: I can get this if() clause to ever be true

2012-10-19 Thread Sean Corfield
On Fri, Oct 19, 2012 at 12:10 AM, larry google groups <
lawrencecloj...@gmail.com> wrote:

> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
> new-user-entry (conj this-users-params { "updated" right-now })]
> (if (:username new-user-entry)
>   (swap! registry assoc (:username new-user-entry) new-user-entry
>
> The if statement seems to never be true.
>

conj produces a sequence, not a map, so the lookup of :username fails. Try
new-user-entry (assoc this-users-params "updated" right-now)
-- 
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: ANN: cljs-info 1.0.0 "Help and reflection facilities for ClojureScript"

2012-10-19 Thread Sean Corfield
Frank demo'd a lot of this to the Bay Area Clojure Meetup tonight and it is
very cool stuff that makes development with ClojureScript a lot more
interactive and "natural". Great work!

On Thu, Oct 18, 2012 at 12:28 AM, Frank Siebenlist <
frank.siebenl...@gmail.com> wrote:

> "cljs-info" is a collection of Clojure-functions to provide basic help and
> reflection facilities for ClojureScript.
>
> Some of the functions provided are:
>
> cljs-doc, cljs-doc*, cljs-find-doc, cljs-apropos, cljs-source
>
> cljs-ns-map, cljs-ns-publics, cljs-ns-refers, cljs-ns-aliases,
> cljs-ns-privates,
> cljs-ns-interns, cljs-ns-resolve, cljs-all-ns, cljs-find-ns,
> cljs-the-ns
>
> cljs->repl, js->repl
>
> Note that all those fns run on the clojure side of the fence and are not
> cljs-functions!
> I've tried to explain "why" in the README. In short, clojurescript
> development is a somewhat schizophrenic process dealing with the
> split-personality of your clojurescript's virtual-world(s)… ;-).
>
> For details see: "https://github.com/franks42/cljs-info";
>
> The README has more info about install, usage, and the what, where and how.
>
> Suggestions & comments are very welcome - This is version 1.0 and a "work
> in progress".
>
> Enjoy, FrankS.
>
>

-- 
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: Coming from Common Lisp to Clojure

2012-10-19 Thread Sean Corfield
On Thu, Oct 18, 2012 at 4:28 PM, Brian Craft  wrote:

> C is a "C-language", and it seems a lot simpler than clojure to me. K&R is
> about 200 pages. I expect you mean C++, Java, etc.


No, I think Clojure is a lot simpler than C. As for C++, I was on the
standards committee for eight years so I know C++ is a lot more complex
than C. I was peripherally involved with the C standards process before
that (I co-wrote one of the first ANSI-validated C implementations).


> Not meaning to start a language war, but my own experiences with C++ and
> Java have mostly convinced me that the added complexity in those languages
> don't lead to better code: quite the opposite.


Happy to agree with you there. I look back at several things I was involved
with in the design of C++ and hang my head in shame, a little :)


> So far it's all been good, except for when I have to muck with java stuff.
> ;)
>

Cool. Hopefully the longer you spend with Clojure, the more you'll grow to
love it...
-- 
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

I can get this if() clause to ever be true

2012-10-19 Thread larry google groups
Assume data that looks like this:

{ziri {:last_name ziri, :image ziggy_stardust.jpg, :username larry, 
:first_name larry, updated 1350626694791}, erich {:last_name 7ich, 
:image 7ot_mein.jpg, :username erich, :first_name 754545_halle, 
updated 1350626679436}}


When fed into the next function, the data looks like this:

{:last_name 7ich, :image 7ot_mein.jpg, :username erich, 
:first_name 754545_halle, updated 1350626679436}

The function looks like this, but I can not get the if statement to ever 
run as if true. 

(defn add-to-logged-in-registry [this-users-params]
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { "updated" right-now })]
(if (:username new-user-entry)
  (swap! registry assoc (:username new-user-entry) new-user-entry

The if statement seems to never be true. 

I also tried: 

(defn add-to-logged-in-registry [this-users-params]
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { "updated" right-now })]
(if-not (nil? (:username new-user-entry))
  (swap! registry assoc (:username new-user-entry) new-user-entry


and I tried this with "contains": 

(defn add-to-logged-in-registry [this-users-params]
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { "updated" right-now })]
(if (contains?  new-user-entry :username))
  (swap! registry assoc (:username new-user-entry) new-user-entry

But it seems as if the branch following the if statement is never run, no 
matter what I do. 

Why? 



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