Re: Clojure on PyPy

2012-02-09 Thread kovas boguta
This article on RPython and PyPy is pretty good, helped me understand
what the fuss is about:

http://tratt.net/laurie/tech_articles/articles/fast_enough_vms_in_fast_enough_time

Pretty cool stuff.

Will clojure-py allow us to write our own VM's using clojure?



On Mon, Nov 28, 2011 at 9:23 AM, Timothy Baldridge  wrote:
>> IMO better to hack on VMKit (llvm) than to start a new one atop of PyPy.
>
> Seeing as VMkit is a method level jit, and PyPy creates tracing JITs,
> basing a JVM off of VMKit to run clojure on it kindof defeats the
> whole purpose.
>
> Timothy
>
> --
> “One of the main causes of the fall of the Roman Empire was
> that–lacking zero–they had no way to indicate successful termination
> of their C programs.”
> (Robert Firth)
>
> --
> 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: Destructuring a seq of maps

2012-02-09 Thread Manuel Paccagnella

On 08/02/2012 03:05, Asim Jalis wrote:

I frequently find myself passing around maps that are basically structs.
I use this macro to destructure the fields into let variables.

; Macro.

(defmacro def-fields [struct-name & fields]
   (let [field-symbol-vector (->> fields (map name) (map symbol) vec)
 arg (gensym)
 body (gensym)
 macro-name (symbol (str "let-" struct-name))]
 `(defmacro ~macro-name [~arg & ~body]
   `(let [{:keys ~'~field-symbol-vector} ~~arg] ~@~body
; How to use it.

(def-fields person :first-name :last-name :city)

(defn print-person [p]
   (let-person p
 (println "First name:" first-name)
 (println "Last name:" last-name)
 (println "City:" city)))

(def person1 {:first-name "John" :last-name "Smith" :city "San Francisco"})
(print-person person1)



I haven't come around macros yet, but when I'll tackle the subject 
(soon) your example will be useful. Nice! Now I understand a little more 
the notion of extensible language.


--
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: Calling all Melbourne, Australia, Clojure users

2012-02-09 Thread James Sofra
Leonardo,

Thanks for the support, if I am ever in Sydney I'll come and visit.

Cheers,
James

-- 
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: Calling all Melbourne, Australia, Clojure users

2012-02-09 Thread James Sofra
Hi all,

Good to see some interest!

I have now started a meetup page http://www.meetup.com/clj-melb/

Will organise more once we have some members.

We have a place we should be able to meet in the CBD.

Cheers,
James Sofra

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure on PyPy

2012-02-09 Thread Timothy Baldridge
> Will clojure-py allow us to write our own VM's using clojure?

TL/DR: yes

Long version: RPython simply is a restriction on what bytecodes can do
in a given set of branches in a python program. So the cool thing
about RPython is, you define a main(argv[]) function, and then point
the PyPy translator at that function. Any code touched by that
function must conform to the RPython restrictions. But any code used
to generate that function can use standard Python.

So writing a RPython program is very much possible in clojure-py.

However the restrictions of RPython start to manifest themselves a bit
more in clojure-py. For instance most of clojure.core will be totally
useless to you. RPython states that "any function can take one and
only one type for each argument". This means that the following code
will not compile via RPython.

(defn foo [x] x)

(print (foo 1))
(print (foo "2"))

Now, the way we get around this is by wrapping everything:

(defprotocol W)

(deftype W_int [x]
W
(toString [self] x.__str__))

(deftype W_string [x]
W
(toString [self] x.__str__))

Now we can do what we want:

(defn foo [x] (.toString x))

(print (foo (W_int. 1)))
(print (foo (W_string "2")))

I'm hoping Macros and the like will help us get around allot of these
issues, but still, it's going to take some knowledge of how RPython
works to get clojure-py to work with it.

Timothy

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Ann [js-wrap "0.0.1"] wrap js libs for clojurescript

2012-02-09 Thread Dave Sann
Following on from my question this afternoon on foreign 
libs (https://groups.google.com/d/topic/clojure/kqtCC_stbEU/discussion)

alpha

Wraps a no gclosure compliant js file.
Injects a script tag directly into your page whenever you require and use 
the wrapper lib
No need to include js files in you html. just load bootstrap.js

clojars : [js-wrap "0.0.1"]

github :  https://github.com/davesann/wrap-js

example that uses it: https://github.com/davesann/cljs-bcrypt-wrapper

I would like to but don't know how to inject the required externs file into 
the build (without the need to reference in the cljs opts). 
If anyone has ideas please advise.

As always comments, opinions suggestions are welcome.


Cheers

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 [js-wrap "0.0.1"] wrap js libs for clojurescript

2012-02-09 Thread Dave Sann
apologies 

the lib is called wrap-js

[wrap-js "0.0.1"]


-- 
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 [js-wrap "0.0.1"] wrap js libs for clojurescript

2012-02-09 Thread Dave Sann
updated to 0.0.2 - supporting urls as well as local files.

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

Google Summer of Code 2012 - any mentors?

2012-02-09 Thread Alexander Yakushev
Hello,

I am wondering if there is there anybody willing to take part in this
year's GSoC as a mentor? I would be happy to contribute this summer's
time to hacking Clojure and there are probably more students that
would.

Best regards,
Alexander

-- 
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: No show?

2012-02-09 Thread Stuart Halloway
> clojure.reflect/reflect gets you the same information as a big 'ole data 
> structure. You can pprint it for readability.
> 
> The only thing that was not ported was the formatted text output, which would 
> be easy enough to reproduce based on `reflect`.

In particular, reflect + clojure.pprint/print-table.

Stu


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

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Google Summer of Code 2012 - any mentors?

2012-02-09 Thread Baishampayan Ghose
Alexander,

A discussion is currently ongoing in the Clojure Dev mailing list.

We are still waiting for someone from Clojure/core to chime in.

Regards,
BG

On Thu, Feb 9, 2012 at 8:53 PM, Alexander Yakushev
 wrote:
> Hello,
>
> I am wondering if there is there anybody willing to take part in this
> year's GSoC as a mentor? I would be happy to contribute this summer's
> time to hacking Clojure and there are probably more students that
> would.
>
> Best regards,
> Alexander
>
> --
> 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



-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojurescript options :foreign-libs (and an idea seeking opinions)

2012-02-09 Thread David Nolen
I'm not following your line of reasoning -
http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html,
shows that :foreign-libs and advanced compilation work fine together.

David

On Wed, Feb 8, 2012 at 9:22 PM, Dave Sann  wrote:

> I think that the use of :foreign-libs to include non closure js libs in
> cljs builds may be hazardous
>
> My reasoning as as follows:
>
> if you use :foreign-libs, you create a namespace for the library - and
> must require this namespace in order for it to be included in the build.
>
> But, if you plan to use advanced compilation and use :externs this
> namespace is never provided.
>
> The result is that switching for simple to advance compilation requires a
> change in every file that required the dependency - to remove it.
>
> Probably not a huge issue - but not ideal either.
> ---
>
> Following on from this I have an Idea for browser targeted foreign js libs
> and I would like input/opinions
>
> suppose a macro
>
> (wrap-js js-file externs-file options
>   (foo [] (.foo js/SomeClass)
> )
>
> to be used something like:
>
> (ns my-wrapper)
>
> (wrap-js "some.js" "some.externs.js" {:inline true}
>  ...fn definitions...
> )
>
>
> this will then:
>  1. ensure that the externs file is included in the build.
>  2. generate a function that is called in the client when bootstrap.js is
> loaded to insert a 

Re: Clojure CDT up, cont, down, local-names throws arity errors after hitting breakpoint

2012-02-09 Thread Sean Corfield
On Wed, Feb 8, 2012 at 10:16 PM, George Jahad
 wrote:
> If you use Emacs and Swank-clojure, it is much
> easier to use swank-cdt, as your UI:
>
> http://georgejahad.com/clojure/swank-cdt.html

I just want to chime in and say swank-clojure 1.4.0 has made this
process so much simpler and it really is a pleasure to work with! I
had a nasty bug in my code the other day and was able to track it down
and fix in "only" about an hour and a half using CDT this way - I
dread to think how long it would have taken with a less integrated
tool chain setup...
-- 
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


novice question, performance surprise

2012-02-09 Thread Manuel Paccagnella
Sorry for what I guess is a pretty basic question. I've written for 
practice a simple function that takes a sequence of numbers and returns 
a map with the odd and even ones. No big deal:


(defn separate-nums [coll]
  (hash-map :even (filter even? coll) :odd (filter odd? coll)))

But I thought that I actually filter the same sequence two times (one 
for taking out odd numbers and another one for even ones). So, why don't 
write a "procedural" version and see how it compares to the functional one?


(defn separate-nums-it [coll]
  (loop [odd [] even [] nums coll]
(let [n (first nums)]
  (if (nil? n)
(hash-map :even even :odd odd)
(if (even? n)
 (recur odd (conj even n) (rest nums))
 (recur (conj odd n) even (rest nums)))

Weeping for the second version, I wrote a quick&dirty timing test:

(let [nums (range 65536)]
  (do (time (separate-nums nums))
  (time (separate-nums-it nums

The output surprised me:

"Elapsed time: 0.083074 msecs"
"Elapsed time: 51.026659 msecs"

Following my previous reasoning, iterating over a sequence of numbers 
only once should have been faster... What I'm missing? The iterative 
version is so bad? I see that the filter function source code is much 
more complex than I thought, so maybe there are important optimizations 
in there.



--
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: novice question, performance surprise

2012-02-09 Thread Steve Miner
filter is lazy so it won't actually do the work unless the values are needed.  
To get a reasonable time, you need to use the result for some computation.  Try 
something like this:

(defn sum-all [m] (reduce + (apply map + (vals m

(time (sum-all (separate-nums (range 1


On Feb 9, 2012, at 5:12 PM, Manuel Paccagnella wrote:

> Sorry for what I guess is a pretty basic question. I've written for practice 
> a simple function that takes a sequence of numbers and returns a map with the 
> odd and even ones. No big deal:
> 
>(defn separate-nums [coll]
>  (hash-map :even (filter even? coll) :odd (filter odd? coll)))
> 
> But I thought that I actually filter the same sequence two times (one for 
> taking out odd numbers and another one for even ones). So, why don't write a 
> "procedural" version and see how it compares to the functional one?
> 
>(defn separate-nums-it [coll]
>  (loop [odd [] even [] nums coll]
>(let [n (first nums)]
>  (if (nil? n)
>(hash-map :even even :odd odd)
>(if (even? n)
> (recur odd (conj even n) (rest nums))
> (recur (conj odd n) even (rest nums)))
> 
> Weeping for the second version, I wrote a quick&dirty timing test:
> 
>(let [nums (range 65536)]
>  (do (time (separate-nums nums))
>  (time (separate-nums-it nums
> 
> The output surprised me:
> 
>"Elapsed time: 0.083074 msecs"
>"Elapsed time: 51.026659 msecs"
> 
> Following my previous reasoning, iterating over a sequence of numbers only 
> once should have been faster... What I'm missing? The iterative version is so 
> bad? I see that the filter function source code is much more complex than I 
> thought, so maybe there are important optimizations in there.

-- 
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: noob question on lein and 1.4

2012-02-09 Thread ambert ho
ok, thanks so much! :)

On Wed, Feb 8, 2012 at 1:58 PM, Phil Hagelberg  wrote:

> Ambert Ho  writes:
>
> > So I bought a couple of books on Clojure and one of them tells me to
> > use Lein, the other tells me to download from github.
> >
> > - in lein repl, (clojure-version) gives me '1.2'
> > - in the github d/l'd version, (clojure-version) gives me '1.4'
> >
> > I googled a bit, and when I type 'lein' I don't see anything about
> > upgrading clojures version.
>
> If you run inside a project (generated with "lein new") then it will use
> whatever version of Clojure the project specifies. You can't change the
> version of "lein repl" outside a project though; it has to use whatever
> version Leiningen uses. Leiningen is mostly centered around project
> automation, so mostly you work inside the context of projects.
>
> -Phil
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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: Persistent collections and garbage collection

2012-02-09 Thread dgrnbrg
It seems to me that a generational collector would have problems
collecting Clojure's garbage production pattern. Luckily, the oracle/
hotspot jvm has a continuous collecting compacting GC called G1. That
should mitigate oldspace collection latency spikes. Enable with -XX:
+UnlockExperimentalVMOptions -XX:+UseG1GC

On Feb 7, 11:16 am, pron  wrote:
> Hi. I have a question:
> I love Clojure's persistent collections, but don't they generate many
> long-lived objects (that go to the surving generations) that are hard to
> garbage-collect? After all, the discarded nodes after "modification" are
> not necessarily short lived. It seems like they would behave badly from the
> GC perspective. Am I wrong?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureScript def, vars, and binding

2012-02-09 Thread Brandon Bloom
It seems like the missing word from my vocabulary was "conveyance".

I've spent a fair bit of time toying with Clojure, ClojureScript, and their 
respective implementations. It seems like Clojure 1.3 augmented futures and 
agents with binding-conveyor-fn, clojure.lang.Var/getThreadBindingFrame, 
and clojure.lang.Var/resetThreadBindingFrame.

Despite the lack of threading, it seems like this conveyance concept has 
wide applicability for the common asynchronous code typical in Javascript. 
In particular, I'd like to be able to use some dynamically bound variables 
in callbacks from XHR requests. This would also be extremely useful for 
dynamic var support in Continuation Passing Style transformation macros.

The JVM/Clojure implementation of Var's binding Frame class make clever use 
of persistent maps to make this machinery work, but it appears that 
ClojureScript uses simple Javascript objects/maps as namespaces. Capturing 
a binding frame would involve an O(vars) operation.

Before I dig any deeper into this (including potentially implementing 
conveyance in ClojureScript), I'd appreciate if anyone could fill me in on 
any current thinkings here. I'm sure async is interesting to the key 
ClojureScript contributors, but I've found precious little discussion about 
these topics.

Thanks,
Brandon

-- 
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: mixins/multiple inheritance

2012-02-09 Thread Matthias Diehn Ingesman
The problem with the protocols approach is that it leads to an explosion in 
the number of explicitly defined records. His example was only with labels, 
but I can imagine he might have borders and any number of other decorations 
on the widgets, in which case he would need something like

(defrecord Textfield ...)
(defrecord LabelledTextfield ...)
(defrecord BorderedTextfield ...)
(defrecord LabelledAndBorderedTextfield ...)
; and so on for each combination of decorator and widget

With the other approach he would only need a record for each widget and one 
for each decorator.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure CDT up, cont, down, local-names throws arity errors after hitting breakpoint

2012-02-09 Thread Sean Neilan
It works! Thank you so much for looking into this! I really appreciate what
you have done.

I went through the rest of the documentation and found three other minor
misnomers.

One, if you set a breakpoint on a function defined in the repl, you'll have
problems. As long as anything you set a breakpoint on is defined in a
clojure source file, one should be fine.

Two, set-catch does not appear to take clojure error objects:
user=> (set-catch clojure.lang.ArityException :all)
IllegalArgumentException No reference type found for class
clojure.lang.ArityException  cdt.events/set-catch (events.clj:326)
set-catch does take java error objects though. I haven't tested this yet.

Three, locals does not appear to work.
user=> (locals (ct) (cf))
RuntimeException Unreadable form  clojure.lang.Util.runtimeException
(Util.java:156)

Thank you again for writing CDT! It is a life saver.

On Thu, Feb 9, 2012 at 12:16 AM, George Jahad
wrote:

> Sorry about that.  As you noticed the doc here was out of date:
>
> http://georgejahad.com/clojure/cdt.html
>
> It should be fixed now.
>
> Just for your reference however that doc only describes the command
> line version of CDT.  If you use Emacs and Swank-clojure, it is much
> easier to use swank-cdt, as your UI:
>
> http://georgejahad.com/clojure/swank-cdt.html
>
>
>
> On Feb 8, 11:11 am, Sean Neilan  wrote:
> > Hi All,
> >
> > I'm using Clojure 1.3.0 with CDT 1.2.6.2 on OSX Lion with Java 1.6.
> >
> > I want to set a breakpoint on -main on the program to be debugged. So,
> > run lein repl on this program. It opens up port 8030 successfully.
> > (This is based off the documentation here:
> http://georgejahad.com/clojure/cdt.html)
> > seans-macaroni-book:gslisp seanneilan$ lein repl
> > Listening for transport dt_socket at address: 8030
> > REPL started; server listening on localhost port 13575
> >
> > Then, I start up a new shell in a different project and do this to
> > attach to the program to be debugged:
> > seans-macaroni-book:cdt seanneilan$ lein repl
> > REPL started; server listening on localhost port 57048
> > user=> (use 'cdt.ui)
> > nil
> > user=> (cdt-attach 8030)
> > nil
> > user=> CDT ready
> >
> > It attaches correctly. Then, I set the breakpoint on -main
> > user=> (set-bp gslisp.core/-main)
> > bp set on (#)
> > nil
> >
> > Then, in the other shell, I call -main
> > gslisp.core=> (-main)
> > which correctly stalls
> >
> > In the debugger shell, I see
> > user=> Breakpoint # > $_main:240 in thread Thread-2> hit
> > CDT location is /Users/seanneilan/BucketsOfNantucket/research/gslisp/
> > src/gslisp/core.clj:240:0:
> >
> > But, if I try to type any debugging commands, I get this:
> > user=> (locals)
> > ArityException Wrong number of args (0) passed to: reval$locals
> > clojure.lang.AFn.throwArity (AFn.java:437)
> > user=> (up)
> > ArityException Wrong number of args (0) passed to: ui$up
> > clojure.lang.AFn.throwArity (AFn.java:437)
> > user=> (down)
> > ArityException Wrong number of args (0) passed to: ui$down
> > clojure.lang.AFn.throwArity (AFn.java:437)
> > user=> (up 1)
> > ArityException Wrong number of args (1) passed to: ui$up
> > clojure.lang.AFn.throwArity (AFn.java:437)
> > user=> (up 0 0)
> > IllegalArgumentException No matching field found: frames for class
> > java.lang.Long  clojure.lang.Reflector.getInstanceField
> > (Reflector.java:289)
> > user=> (print-frames)
> > ArityException Wrong number of args (0) passed to: ui$print-frames
> > clojure.lang.AFn.throwArity (AFn.java:437)
> > user=> (cont)
> > CompilerException java.lang.RuntimeException: Unable to resolve
> > symbol: cont in this context, compiling:(NO_SOURCE_PATH:20)
> >
> > So basically the breakpoint hits but I can't run any debugging
> > commands.
>
> --
> 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: Clojure CDT up, cont, down, local-names throws arity errors after hitting breakpoint

2012-02-09 Thread Sean Neilan
I agree. I'm a Vim user currently but with Lisp/Clojure, Emacs is the way
to go.

On Thu, Feb 9, 2012 at 11:18 AM, Sean Corfield wrote:

> On Wed, Feb 8, 2012 at 10:16 PM, George Jahad
>  wrote:
> > If you use Emacs and Swank-clojure, it is much
> > easier to use swank-cdt, as your UI:
> >
> > http://georgejahad.com/clojure/swank-cdt.html
>
> I just want to chime in and say swank-clojure 1.4.0 has made this
> process so much simpler and it really is a pleasure to work with! I
> had a nasty bug in my code the other day and was able to track it down
> and fix in "only" about an hour and a half using CDT this way - I
> dread to think how long it would have taken with a less integrated
> tool chain setup...
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure CDT up, cont, down, local-names throws arity errors after hitting breakpoint

2012-02-09 Thread Sean Neilan
There's so much documentation about how to set up emacs with clojure but
not a lot of sources saying which documentation works.

Should I trust the readme for swank-clojure, the dev.clojure.org site, the
comments on dev.clojure.org, the blog post at technomancy.us/149 or the
radically simplified setup
here?
Or, if I use the readme from swank-clojure, can I trust the part about how
swank-clojure is available as an emacs package? (I remember somebody
somewhere said it doesn't currently work.) Also, somebody somewhere else
said there are issues with swank-clojure 1.4.0 and that I should use 1.3.x
instead.

I hope I don't sound annoying.. I just don't know who to follow.

On Thu, Feb 9, 2012 at 11:35 AM, Sean Neilan  wrote:

> I agree. I'm a Vim user currently but with Lisp/Clojure, Emacs is the way
> to go.
>
>
> On Thu, Feb 9, 2012 at 11:18 AM, Sean Corfield wrote:
>
>> On Wed, Feb 8, 2012 at 10:16 PM, George Jahad
>>  wrote:
>> > If you use Emacs and Swank-clojure, it is much
>> > easier to use swank-cdt, as your UI:
>> >
>> > http://georgejahad.com/clojure/swank-cdt.html
>>
>> I just want to chime in and say swank-clojure 1.4.0 has made this
>> process so much simpler and it really is a pleasure to work with! I
>> had a nasty bug in my code the other day and was able to track it down
>> and fix in "only" about an hour and a half using CDT this way - I
>> dread to think how long it would have taken with a less integrated
>> tool chain setup...
>> --
>> Sean A Corfield -- (904) 302-SEAN
>> An Architect's View -- http://corfield.org/
>> World Singles, LLC. -- http://worldsingles.com/
>>
>> "Perfection is the enemy of the good."
>> -- Gustave Flaubert, French realist novelist (1821-1880)
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojurescript options :foreign-libs (and an idea seeking opinions)

2012-02-09 Thread Dave Sann
Maybe - but I don't think so.

I tested with jquery this morning - to try and re-confirm - details 
appended at the end of this post

I think that this falls into the: 
"If the library you want to use simply doesn't work with advanced 
compilation" at the bottom of the link you added

My understanding is as follows - please correct me if I have this wrong.

:foreign-libs are included in the build and are optimised with it.
:externs does not apply to any :foreign-libs - only if you include the lib 
separately (which has no namespace)

so, in advanced mode, var/function names are mangled.

If you just want to include the code - and it runs in its own world - you 
may see some warnings, but this works fine 
but references to vars/functions in the library from clojurescript will not 
work.

Which, I think means pretty much any non-gclosure library in advanced mode.

Dave

-

Test with jquery

with and without :externs, in :simple and :advanced.
jquery - intentionally not referenced externally in the page.

using
{
 :optimizations :advanced
 :externs ["resources/js/jquery-externs.js"]
 :foreign-libs [{:file "resources/js/jquery.1.7.1.min.js" :provides 
["jquery"]}]
 }

the libs in:
resources/js/jquery-externs.js
resources/js/jquery.1.7.1.min.js

main.cljs calls:

(.log js/console (js/JQuery "body"))

respectively.
in simple: Ok

In advanced:
compiles with warnings
in the browser when referencing js/jQuery 

   1. Uncaught ReferenceError: jQuery is not defined
  1. (anonymous function)
  
  

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojurescript options :foreign-libs (and an idea seeking opinions)

2012-02-09 Thread David Nolen
Ah yes. What you want is something like "extern-lib" (not saying it will be
called that) - some way for you to include JS that won't get submitted to
advanced compilation yet which has externs to define.

Please open a ticket in JIRA for this.

David

On Thu, Feb 9, 2012 at 6:24 PM, Dave Sann  wrote:

> Maybe - but I don't think so.
>
> I tested with jquery this morning - to try and re-confirm - details
> appended at the end of this post
>
> I think that this falls into the:
> "If the library you want to use simply doesn't work with advanced
> compilation" at the bottom of the link you added
>
> My understanding is as follows - please correct me if I have this wrong.
>
> :foreign-libs are included in the build and are optimised with it.
> :externs does not apply to any :foreign-libs - only if you include the lib
> separately (which has no namespace)
>
> so, in advanced mode, var/function names are mangled.
>
> If you just want to include the code - and it runs in its own world - you
> may see some warnings, but this works fine
> but references to vars/functions in the library from clojurescript will
> not work.
>
> Which, I think means pretty much any non-gclosure library in advanced mode.
>
> Dave
>
> -
>
> Test with jquery
>
> with and without :externs, in :simple and :advanced.
> jquery - intentionally not referenced externally in the page.
>
> using
> {
>  :optimizations :advanced
>  :externs ["resources/js/jquery-externs.js"]
>  :foreign-libs [{:file "resources/js/jquery.1.7.1.min.js" :provides
> ["jquery"]}]
>  }
>
> the libs in:
> resources/js/jquery-externs.js
> resources/js/jquery.1.7.1.min.js
>
> main.cljs calls:
>
> (.log js/console (js/JQuery "body"))
>
> respectively.
> in simple: Ok
>
> In advanced:
> compiles with warnings
> in the browser when referencing js/jQuery
>
>1. Uncaught ReferenceError: jQuery is not defined
>   1. (anonymous function)
>
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojurescript options :foreign-libs (and an idea seeking opinions)

2012-02-09 Thread Dave Sann
yes exactly, but I would like to be able to package js libs as jars - not 
specify them directly to the build in the cljsc opts.

I have done half of this, here: 
https://github.com/davesann/wrap-js

see the following examples:

https://github.com/davesann/cljs-bcrypt-wrapper
https://github.com/davesann/jayq( extending to 
ibdknox/jayq
 )

To complete it, I need a way to specify that the externs file/files 
provided should used by the compiler.

possibly something along the lines of the *require-externs* added below

(ns jayq.inline-jquery 
  (:require [wrap-js.core :as wrap-js])
  (:require-macros [wrap-js.macros.file-contents :as mfc]))

;; Just require this namespace if you want JQuery inlined and inserted into 
your webpage.
;; do this before you require jayq.core

*;; specify externs for the compiler*
*(require-externs "js/jquery-externs.1.7.1.js")*
; inline from local
(def jquery-src (mfc/from-local-file "js/jquery.1.7.1.min.js"))
(wrap-js/add-inline! jquery-src)



The nice thing here is that if you don't require this namespace jquery is 
omitted from your page and your bootstrap.
no compiler options required. 

Currently though - you must specify the externs to the compiler if using 
advanced mode.

I suspect that the above call may be hard to add - or undesirable.
A simple alternative to this would be to use a convention 
  - for example - that the compiler will always read, as an externs file, 
any js file found on the classpath in "js/externs"
 

D

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojurescript options :foreign-libs (and an idea seeking opinions)

2012-02-09 Thread Dave Sann
created:

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

with pointer to discussion here.

-- 
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: Persistent collections and garbage collection

2012-02-09 Thread pron
Yes, that's what I thought. Does anyone have any experience with Clojure's 
garbage production pattern (esp. due to the persistent collection) and it's 
behavior with the older GCs as well as with G1? 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure on PyPy

2012-02-09 Thread kovas boguta
This stuff is amazing.

The big question for me is how this relates to macros. This sounds
like a metaprogramming ability, where instead of changing the source
code, you are changing the implementation layer.

Here is a concrete use case I'm interested in: optimizing algorithms.
I have some set of algorithms that needs such-and-such operations to
be as fast as possible. Can I create a VM that is tailored for that?
For example, tailor a VM around core.logic. Or would this be a silly
thing to do?


On Thu, Feb 9, 2012 at 7:26 AM, Timothy Baldridge  wrote:
>> Will clojure-py allow us to write our own VM's using clojure?
>
> TL/DR: yes
>
> Long version: RPython simply is a restriction on what bytecodes can do
> in a given set of branches in a python program. So the cool thing
> about RPython is, you define a main(argv[]) function, and then point
> the PyPy translator at that function. Any code touched by that
> function must conform to the RPython restrictions. But any code used
> to generate that function can use standard Python.
>
> So writing a RPython program is very much possible in clojure-py.
>
> However the restrictions of RPython start to manifest themselves a bit
> more in clojure-py. For instance most of clojure.core will be totally
> useless to you. RPython states that "any function can take one and
> only one type for each argument". This means that the following code
> will not compile via RPython.
>
> (defn foo [x] x)
>
> (print (foo 1))
> (print (foo "2"))
>
> Now, the way we get around this is by wrapping everything:
>
> (defprotocol W)
>
> (deftype W_int [x]
>    W
>    (toString [self] x.__str__))
>
> (deftype W_string [x]
>    W
>    (toString [self] x.__str__))
>
> Now we can do what we want:
>
> (defn foo [x] (.toString x))
>
> (print (foo (W_int. 1)))
> (print (foo (W_string "2")))
>
> I'm hoping Macros and the like will help us get around allot of these
> issues, but still, it's going to take some knowledge of how RPython
> works to get clojure-py to work with it.
>
> Timothy
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure CDT up, cont, down, local-names throws arity errors after hitting breakpoint

2012-02-09 Thread Phil Hagelberg
Sean Neilan  writes:

> Should I trust the readme for swank-clojure, the dev.clojure.org
> site, the comments on dev.clojure.org, the blog post at 
> technomancy.us/149 or the radically simplified setup here?

The swank-clojure readme should be the most reliable. You may find a
better explanation of how all the pieces fit together elsewhere, but for
swank-clojure itself, trust the readme.

> can I trust the part about how swank-clojure is available as an emacs
> package?

No, that's very old. Where are you seeing it?

> Also, somebody somewhere else said there are issues with swank-clojure
> 1.4.0 and that I should use 1.3.x instead.

Do you remember any details? For a time the 1.4.0-SNAPSHOT was behind on
the elisp payload stuff, but it should be fine now.

-Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure on PyPy

2012-02-09 Thread kovas boguta
Another question: can multiple VMs live inside the same process
boundary? So that code in VM1 (clojure-py) can call code in VM2 (pypy)
with no overhead.

There is also a third case, intermediate between optimizing vms for
algorithms and optimizing for full blown languages.

Think about implementing erlang-style actors. They send messages, have
the mailbox, and reduce a certain number forms when their turn comes.
Ignoring everything else in the language (the primitives in the actor
body that do the computation associated with message), this skeleton
system requires a certain kind of VM. Can we reify the clojure VM to
enable these properties?

It would be pretty impressive if one could parameterize the VM space,
and access different parts of that space within a contiguous clojure
program.



On Thu, Feb 9, 2012 at 7:43 PM, kovas boguta  wrote:
> This stuff is amazing.
>
> The big question for me is how this relates to macros. This sounds
> like a metaprogramming ability, where instead of changing the source
> code, you are changing the implementation layer.
>
> Here is a concrete use case I'm interested in: optimizing algorithms.
> I have some set of algorithms that needs such-and-such operations to
> be as fast as possible. Can I create a VM that is tailored for that?
> For example, tailor a VM around core.logic. Or would this be a silly
> thing to do?
>
>
> On Thu, Feb 9, 2012 at 7:26 AM, Timothy Baldridge  
> wrote:
>>> Will clojure-py allow us to write our own VM's using clojure?
>>
>> TL/DR: yes
>>
>> Long version: RPython simply is a restriction on what bytecodes can do
>> in a given set of branches in a python program. So the cool thing
>> about RPython is, you define a main(argv[]) function, and then point
>> the PyPy translator at that function. Any code touched by that
>> function must conform to the RPython restrictions. But any code used
>> to generate that function can use standard Python.
>>
>> So writing a RPython program is very much possible in clojure-py.
>>
>> However the restrictions of RPython start to manifest themselves a bit
>> more in clojure-py. For instance most of clojure.core will be totally
>> useless to you. RPython states that "any function can take one and
>> only one type for each argument". This means that the following code
>> will not compile via RPython.
>>
>> (defn foo [x] x)
>>
>> (print (foo 1))
>> (print (foo "2"))
>>
>> Now, the way we get around this is by wrapping everything:
>>
>> (defprotocol W)
>>
>> (deftype W_int [x]
>>    W
>>    (toString [self] x.__str__))
>>
>> (deftype W_string [x]
>>    W
>>    (toString [self] x.__str__))
>>
>> Now we can do what we want:
>>
>> (defn foo [x] (.toString x))
>>
>> (print (foo (W_int. 1)))
>> (print (foo (W_string "2")))
>>
>> I'm hoping Macros and the like will help us get around allot of these
>> issues, but still, it's going to take some knowledge of how RPython
>> works to get clojure-py to work with it.
>>
>> Timothy
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure CDT up, cont, down, local-names throws arity errors after hitting breakpoint

2012-02-09 Thread Sean Neilan
On Thu, Feb 9, 2012 at 7:06 PM, Phil Hagelberg  wrote:

> Sean Neilan  writes:
>
> > Should I trust the readme for swank-clojure, the dev.clojure.org
> > site, the comments on dev.clojure.org, the blog post at
> > technomancy.us/149 or the radically simplified setup here?
>
> The swank-clojure readme should be the most reliable. You may find a
> better explanation of how all the pieces fit together elsewhere, but for
> swank-clojure itself, trust the readme.
>
> > can I trust the part about how swank-clojure is available as an emacs
> > package?
>
> No, that's very old. Where are you seeing it?
>

It's on the github page at the top.
The emacs packages are mentioned as deprecated here:
http://groups.google.com/group/clojure/browse_thread/thread/1d3f308b1bc3dc61
I guess I confused the marmelade repo with whatever repo was mentioned in
that thread.

I'm sorry, I'm used to really bad documentation in the open source world.
If someone says somewhere
something is not working, my instinct is to take that with a grain of salt
even if it's just a random person
on the internet. I'll give swank-clojure a shot tonight.

Clearly, your software is more polished than I assumed it would be. :)
(based on too much past experience in the open source world.)


>
> > Also, somebody somewhere else said there are issues with swank-clojure
> > 1.4.0 and that I should use 1.3.x instead.
>
> Do you remember any details? For a time the 1.4.0-SNAPSHOT was behind on
> the elisp payload stuff, but it should be fine now.
>

I can't find it again :( But, it was about how the 1.4.0-SNAPSHOT was
behind.

It does say to use 1.3.4 over here:
http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
That's definitely one of the things I got confused on. As a noob, I take
dev.clojure.org as g
ospel since it's part of clojure.org.


>
> -Phil
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure CDT up, cont, down, local-names throws arity errors after hitting breakpoint

2012-02-09 Thread Phil Hagelberg
Sean Neilan  writes:

> It's on the github page at the top.

Forgive me if I'm slow, but I can't find it. Can you be more specific?

The canonical page for swank-clojure is
https://github.com/technomancy/swank-clojure

Are you talking about instructions for using swank-clojure.el or
something else?

> It does say to use 1.3.4 over here:
> http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
> That's definitely one of the things I got confused on. As a noob, I
> take dev.clojure.org as gospel since it's part of clojure.org.

Yes, that was a bit confusing because development on 1.4.0 was blocked
on getting a stable version of the cdt debugger released, so we went
back to working on 1.3.x for a while. But that's no longer an issue.

-Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: mixins/multiple inheritance

2012-02-09 Thread David Nolen
I think the suggestions thus far are not ideal. Both protocols and
multimethods provide a way to define a default case. The default case gives
you opportunity to adopt a delegation / component based design.

(defprotocol IFlightOrgan
  (flight-organ [this]))

(defprotocol IFlight
  (can-fly? [this])
  (fly [this] [this body]))

(extend-type Object
  IFlight
  (can-fly? [this]
(satisfies? IFlightOrgan this))
  (fly
([this]
   (fly (flight-organ this) this))
([this body]
   (fly (flight-organ this) body

Now any type that provides a flight-organ can fly (note we even handle the
self-sufficient case). How the flight organ is acquired is completely up to
the provider - it could be a field or it could done via map lookup (if you
need the type to be the aggregate of many components).

This paper is really worth reading, "Organizing Programs Without Classes"
http://cs.au.dk/~hosc/local/LaSC-4-3-pp223-242.pdf

David

On Sun, Feb 5, 2012 at 4:15 PM, Razvan Rotaru wrote:

> Hi,
>
> I found some posts about this topic, but they did not clarify things
> in my head well enough, so I have to start my own... :)
>
> I'm basically craving for multiple inheritance or mixins, at least
> with my current way of thinking. I haven't really gone deep enough
> with multimethods or protocols, so I might be a little off track by
> looking for multiple inheritance.
>
> Let's take an example:
>
> I want to implement some gui widgets, so there's a main method
> "render" which draws the widget on the screen. I want to have two
> types:
>
> - Textfield
> - Datetimepicker
>
> Each can be "mixed" with the Label widget, so that we have:
>
> - LabelledTextfield
> - LabelledDatetimepicker
>
> So, two challenges occur:
> 1/ the render method for Label needs to call the render method for
> it's "mixed" widget (either Textfield or Datetimepicker) - let's
> assume that labels are rendered "around" the actual widget, so that we
> have a simple way to mix the implementations of render method
> 2/ the Label widget comes with its own data (the label text)
>
> For the second thing, I think it will work with defrecords, since the
> label can be a map entry which can be stored in the actual widget,
> even if it's not mixed with Label. I still want to point this out in
> case there are other ways of achieving this.
>
> How can I achieve 1? Are there alternatives for 2?
>
> Thanks for reading,
> Razvan
>
> --
> 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: Persistent collections and garbage collection

2012-02-09 Thread Sean Corfield
On Thu, Feb 9, 2012 at 4:30 PM, pron  wrote:
> Yes, that's what I thought. Does anyone have any experience with Clojure's
> garbage production pattern (esp. due to the persistent collection) and it's
> behavior with the older GCs as well as with G1?

These are the options we run with in production - Clojure is loaded at
runtime into a Tomcat application:

-Dsun.rmi.dgc.client.gcInterval=60
-Dsun.rmi.dgc.server.gcInterval=60
-XX:+ExplicitGCInvokesConcurrent -XX:+UseConcMarkSweepGC

That's the usual RMI GC fix, and selection of CMS GC which seemed to
suit our memory usage better.

Part of the middleware we use explicitly requests GC approximately
every minute. Disabling those explicit GC calls led to long
stop-the-world GC cycles often enough to have a noticeable effect on
the end user experience so we set explicit calls to use CMS. This had
two benefits for us: consistent performance (the CMS GC bails if takes
too long so our request processing times stay fairly consistent) and
keeping memory usage to reasonable levels (which means we only get
occasional stop-the-world GC cycles and only under extreme bursts of
load). We have min/max heap set to 2.5GB. We may revisit this as we
ramp up traffic but for now this is working pretty well.

The amount of time per request spent in Clojure code varies between 5%
and 80% (depending on the type of request - some logic hardly hits the
Clojure code, some logic is implemented almost entirely in Clojure -
we expect the balance to continue to shift toward Clojure over time).
-- 
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


wrap-js : clojurescript - want some jquery plugins? managed? no problem.

2012-02-09 Thread Dave Sann
I have what I think is a really nice method for using jquery and other js 
libs and their dependencies sanely in clojurescript.

(it will be even better if/when http://dev.clojure.org/jira/browse/CLJS-147 is 
resolved)


by using wrap-js (https://github.com/davesann/wrap-js) you can have 
clojurescript require manage the dependencies for you and insert the 
scripts into the page on bootstrap.js load. In the right order. no manual 
effort required.

briefly:

1. just jQuery

clojars [dsann/dsann-cljs-jquery "0.0.1"]( cljs-jquery was already 
taken)

(ns my client
  (:require [cljs-jquery.inline :as _jq]))

; use js/jQuery here - works - no need to include jquery in your html page

2. Even better: jQuery and plugin

clojars [cljs-jquery-sparkline "0.0.1"]   

(ns my client
  (:require [cljs-jquery-sparkline.inline :as _sl]))

; use js/jQuery and (.sparkline ($ ...)) here.  works - no need to include 
jquery or the plugin in your html page

3. And:

feel free to use jayq or any other library building apis on top of jquery.
just be sure to require  [cljs-jquery.inline :as _jq] before you make 
reference to jQuery

4. And!

Its *really *easy to wrap your own libs. 5 minutes and you are away.

see https://github.com/davesann/cljs-jquery-sparkline for an example

see also
https://github.com/davesann/cljs-jquery



Cheers

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: wrap-js : clojurescript - want some jquery plugins? managed? no problem.

2012-02-09 Thread Dave Sann
one note that just came to mind.

I can see a potential issue arising with the versions of wrapped js libs 
and compatibility - particularly for things like plugins.

I haven't done this yet. But it I think that it may be important to be be 
explicit about the version of the js lib you are wrapping.

so rather than naming the project 
"cljs-jquery" you would name it "cljs-jquery-1-7-1"

This will allow users/clients to choose which versions they want and manage 
compatibility.

D


-- 
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: wrap-js : clojurescript - want some jquery plugins? managed? no problem.

2012-02-09 Thread Dave Sann
ok rules for wrapping.

1. include the version of the wrapped js lib in the name of the project/jar 
- so that users can choose which version they want.
2. use a generic namespace to inline the js lib - e.g jquery.inline - not 
jquery-1-7.inline  (allows you to switch versions)
3. do not include any wrapped libs as dependencies in your project.clj file 
- let the user be explicit about which lib the want to depend on in their 
project.clj. (if you don't do this, there will be no end of problems with 
multiple js libs and conflicts in the same page.)




-- 
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: wrap-js : clojurescript - want some jquery plugins? managed? no problem.

2012-02-09 Thread Dave Sann
updated to follow my own rules and by way of example:

* [cljs-query-1-7-1 "0.0.1"]   for jquery version 1.7.1
* [cljs-jquery-sparkline-1-6 "0.0.1"]   for sparkline version 1.6

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