Re: Deep deref

2009-11-24 Thread Christophe Grand
On Mon, Nov 23, 2009 at 11:56 PM, John Harrop  wrote:

> I'm starting to think that for some tasks Clojure could use a concept of
> "row locking" with maps.  It would mean having a map-of-refs type that was
> integrated with the STM, so multiple updates whose keys didn't collide could
> occur concurrently.
>
> It *might* be possible to do this using commute and update-in, with a ref
> wrapping the whole map. The tricky thing is you want the update-ins to
> commute if the keys are not the same, but not if they are. Perhaps we need a
> "conditional commute" that takes two extra arguments, a value to test and a
> binary predicate. Then it could be done with (conditional-commute key = map
> update-in [key] val-transform-fn).
>
> The idea here being, in this case, that if two of these were done in
> overlapping transactions, the first arguments would be compared using the
> second argument. If the result was true one transaction would be retried, if
> false the operations would commute. (If the second arguments to the two
> conditional-commutes differed the transaction would be retried.)
>


I had a similar idea but more general: being able to specify invariants
inside a transaction. Commit will procede only if the invariant still holds.
Your proposed conditional-commute could be rewritten:

;; (conditional-commute key = map update-in [key] val-transform-fn)
(invariant (@map key))
(commute map update-in [key] val-transform-fn)

See the attached patch for a prototype.

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

invariants.patch
Description: Binary data


Re: Monad problems: finding an m-zero

2009-11-24 Thread Konrad Hinsen
On 21 Nov 2009, at 06:31, samppi wrote:

> And no matter what I do, I can't fulfill that second axiom. Has anyone
> created this type of monad before? It seems like it should be a common
> pattern: exactly like (state-t maybe-m), only failures are vector
> pairs too.

One problem I see in your question is the little word "too". A normal  
value in the monad (state-t maybe-m) is of the form (fn [state] ...).  
This is not a vector pair, it's a function.

I am not familiar enough with parsing to understand *why* you want  
failures represented as vector pairs. It might help you to read the  
description of Parsec, an elaborate monadic parsing library in Haskell:
http://legacy.cs.uu.nl/daan/download/papers/parsec-paper.pdf
It discusses many "real-world" issues that are usually left out of  
academic papers on monadic parsing. Perhaps your problem is addressed  
there as well.

Konrad.

-- 
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 User Survey, preparation for 1.1

2009-11-24 Thread bOR_
Can we get an option 'leiningen' at "how do you get clojure"?

On Nov 24, 8:27 am, David Brown  wrote:
> On Mon, Nov 23, 2009 at 09:55:46PM +, the.stuart.sie...@gmail.com wrote:
>
> Since the form only lets me answer one answer for each, but reality is
> much more complicated.
>
> >How do you get Clojure? *
>
> >Download release
> >Github
> >Maven or Ivy
>
> I primarily use the latest development snapshot that I pull down with
> Maven/Ivy.
>
> But, I also keep a git workspace and bounce between master and new.
>
> As far as chunked sequences, I started using clojure after they were
> already in place, so I don't really have anything to compare it with.
>
> 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: roll call of production use?

2009-11-24 Thread Robert Campbell
I've deployed two small mashup apps which combine OpenCalais and our
content repository to annotate documents with metadata (named
entities, relationships, etc) and expose the results over the web.
Good experiences all around, including with the clojure-http-client
and saxon wrapper libs + Compojure.

I did miss having a nice Clojure RDF lib, so maybe I'll make a Jena
wrapper in the future. Parsing the XML-RDF as pure XML w/xpath was
enough for my purposes.


On Tue, Nov 24, 2009 at 6:06 AM, John Harrop  wrote:
> On Mon, Nov 23, 2009 at 9:47 PM, Richard Newman  wrote:
>>>
>>> 1- We have this license server, used to control the use of a
>>> professional software (this one written using delphi).
>>
>> What are the ethics of using an open source product like Clojure to
>> implement DRM restrictions for some other product? Seems there might be
>> something a bit iffy there -- if not legally, perhaps morally.
>>
>> I don't agree. So long as they abide by the Clojure license, everything is
>> A-OK… and the Clojure license doesn't impose restrictions on its use for
>> this purpose.
>
> Hence my "if not legally".
>
>>
>> This use of Clojure is internally consistent, and so I suspect that you're
>> simply slightly offended by the idea of someone making money by using
>> open-source software. In that case, I'd suggest you look first at Red Hat
>> (market cap: $5.09B), and the Linux community's attitude towards them
>> (generally positive).
>
> Oh, I have no problem with making money by using open source software, when
> it's done in the manner that companies like Red Hat do it. It's the use to
> lock down some piece of proprietary software even more than it already is
> that seems, at the very least, ironic.
>
> --
> 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: "Oh, yeah, transients are fast!"

2009-11-24 Thread sross
I believe that this is most likely a symptom of the Apple JVM and not
that of transients
as the change from persistents to transients is far more substantial
on one of our linux
servers than it is on my macbook pro (6x vs 2x speedup)

I'm not entirely sure as to why this is the case but I suspect that GC
has something to
do with it as the following example, which simply bumps a counter in a
map, exhibits
the more impressive performance improvement

(defn make-n [x n]
  (loop [i 0 v []]
(if (< i n)
  (recur (inc i) (conj v x))
  v)))

(defn make-n2 [x n]
  (loop [i (int 0) v (transient [])]
(if (< i n)
  (recur (inc i) (conj! v x))
  (persistent! v

(dotimes [x 10]
  (do (System/gc) (time (make-n 1 10)) 1))

(dotimes [x 10]
  (do (System/gc) (time (make-n2 1 10)) 1))



On Nov 23, 9:07 pm, Raoul Duke  wrote:
> i have tried:
>
> 1.5
> 1.6
> 1.6 -server
> the last i did both in repl-in-emacs, and in a repl-in-straightup-shell.
>
> the numbers i get are weird. it does seem like v2 is faster than v,
> but never gets stupendously fast (never faster than 500 msec on a dual
> core macbook pro 2.2ghz core 2 duo 4gb ram), and v does a strange
> thing where i run v2 a bunch then the first time i run v it is like 2x
> v2, and then subsequent runs of timing v are like 8x v2. and here i
> thought hotspot was supposed to get faster, not slower, over time.
>
> oy veh.

-- 
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: Datatypes and Protocols - early experience program

2009-11-24 Thread Chouser
On Tue, Nov 24, 2009 at 1:19 AM, Krukow  wrote:
>
>
> On Nov 24, 4:55 am, Allen Rohner  wrote:
>> The first stumbling point I reached is that deftypes provide an
>> automatic implementation for IPersistentMap, but not IFn. I attempted
>> to write (instance key), which exploded, but (key instance) works just
>> fine. My existing code uses (instance key) almost universally. Should
>> I get used to this, or are there plans to provide a default IFn
>> implementation?
>
> I agree that it would be nice with an automatic IFn implementation if
> you specify the interface.

If you use a (:k x) where :k is a literal keyword for
a pre-defined field of x (that is, not an entry you added to that
object using 'assoc'), Clojure will tweak that particular call
site to be very fast.  On the other hand, if you do (x :k) or
have a non-literal key such as a keyword stored in a local or
var, it will not do those extra performance tweaks.

I don't know if it would be possible to make (x :k) as fast as
(:k x), but I sorta doubt it will happen.

--Chouser

-- 
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: roll call of production use?

2009-11-24 Thread Jay Fields
DRW (http://drw.com) uses Clojure for several production applications.

Cheers, Jay

On 23 Nov, 17:00, Raoul Duke  wrote:
> hi,
>
> i'd be interested to hear who has successfully used clojure in
> production. i know of some, as some folks have been vocal; any other
> interesting-but-so-far-silent uses people'd be willing to fess up
> about?
>
> many thanks.

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

2009-11-24 Thread Mark Engelberg
On Mon, Nov 23, 2009 at 11:39 PM, Garth Sheldon-Coulson  wrote:
> Hi Mark,
>
> In Clojuratica I make what I think is "good, clean, compelling use" of
> dynamic vars. I rewrote the code to use dynamic vars after I found that
> doing it the other way became unwieldy and inelegant.

OK this makes sense to me.

Your use case is actually very similar to mine (lots of interrelated
functions where it would be cleaner to have them refer to some sort of
global variable that is set prior to execution).  But I got tripped up
because:
1.  I think I had more use of laziness in my code than how you describe yours.
2.  I didn't know the push-thread-bindings/pop-thread-bindings trick
to fix the spots with laziness (I tried just forcing the lazy
sequences which killed my performance -- I really needed laziness).
3.  Even if I had known the trick, I may have had difficulty
identifying all the spots where laziness was an issue since I was
returning a complex lazy tree structure.  (I probably would have
tried, though.)

So now that you've explained your use of dynamic bindings, I can
totally imagine scenarios where it is easier to "tame the laziness"
than go back to passing all the "globals" around, especially with the
convenient bound-seq macro that Meikel posted.

This brings up another question in my mind.  What kind of impact would
it have on people's code if *all* calls to lazy-seq operated the way
that bound-seq does?  Would this make things more intuitive or less
intuitive?  Would this radically reduce performance?

-- 
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: Datatypes and Protocols - early experience program

2009-11-24 Thread Meikel Brandmeyer
Hi,

On Nov 23, 3:29 pm, Krukow  wrote:

> Two comments.
>
> First is a bug.
> Using newest commit of new: 75cd05080f7260c54007d7728fb280ae53b56f63

Same here: 
http://groups.google.com/group/clojure-dev/browse_thread/thread/6d5cf269b18c4540
but no feedback so far. :(

Sincerely
Meikel

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


Re: roll call of production use?

2009-11-24 Thread Meikel Brandmeyer
Hi,

On Nov 24, 6:06 am, John Harrop  wrote:

> Oh, I have no problem with making money by using open source software, when
> it's done in the manner that companies like Red Hat do it. It's the use to
> lock down some piece of proprietary software even more than it already is
> that seems, at the very least, ironic.

A license server does not necessarily mean restriction. We have a
small in-house app which is also handled via a license server. It just
records, who uses the app and charges 25€ per year and user on the
cost center of the using department. No restriction whatsoever.

To say something productive for the discussion:

I use Clojure to drive our regular quality reporting. It takes
information from different source, mainly different SAP systems but
also supplier data provided via Excel. Everything is imported into
database and after a lot of JOINs, SELECTs and UNIONs a pdf containing
the charts with a home-grown analysis is generated. The charts and pdf
are still work in progress, but everything else works nicely so far.

Sincerely
Meikel

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


Re: Clojure User Survey, preparation for 1.1

2009-11-24 Thread Meikel Brandmeyer
Hi,

On Nov 24, 9:44 am, bOR_  wrote:

> Can we get an option 'leiningen' at "how do you get clojure"?

I think this is basically Maven/Ivy, no?

Sincerely
Meikel

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


problem with resolve

2009-11-24 Thread kony
Hi,

I found that resolve does not work correctly (I guess) when it is
called from other thread than main:

e.g.

let define

(def zz 123)

and afterwords call:

(.start (new Thread #(println (resolve 'zz

for me it does not work (it returns nil)

Workaround is to write a kind of "super-resolve" that search the all
available namespaces:

(defn super-resolve [sym-exp]
(loop [all-namespaces (all-ns) ]
(let [current-namespace (first all-namespaces)]
(let [result (ns-resolve current-namespace sym-exp)]
(if (and (= result nil) (> (count 
all-namespaces) 1))
(recur (rest all-namespaces))
result)

and now is OK:

(.start (new Thread #(println (super-resolve 'zz

The question is, however, whether the resolve shouldn't work in the
same manner as resolve?
What do you think?

-- 
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: Monad problems: finding an m-zero

2009-11-24 Thread samppi
The original reason is that I need to be able to transfer certain
certain metadata such as memoization tables between failure results in
m-plus. I'm writing a PEG-type parser that hopefully can support left-
recursion without any conversion to right-recursive rules. I'm using
metadata because I don't want to resort to mutable state refs; even
though it's making my code more complicated, it avoids all the
problems associated with mutable state, especially keeping track of
what changes them where and how.

Right now, I've been doing fine with returning a special "Failure"
object defined by deftype with the failed state's metadata attached to
it. Thank goodness that metadata doesn't affect equality.

On Nov 24, 1:37 am, Konrad Hinsen  wrote:
> On 21 Nov 2009, at 06:31, samppi wrote:
>
> > And no matter what I do, I can't fulfill that second axiom. Has anyone
> > created this type of monad before? It seems like it should be a common
> > pattern: exactly like (state-t maybe-m), only failures are vector
> > pairs too.
>
> One problem I see in your question is the little word "too". A normal  
> value in the monad (state-t maybe-m) is of the form (fn [state] ...).  
> This is not a vector pair, it's a function.
>
> I am not familiar enough with parsing to understand *why* you want  
> failures represented as vector pairs. It might help you to read the  
> description of Parsec, an elaborate monadic parsing library in Haskell:
>        http://legacy.cs.uu.nl/daan/download/papers/parsec-paper.pdf
> It discusses many "real-world" issues that are usually left out of  
> academic papers on monadic parsing. Perhaps your problem is addressed  
> there as well.
>
> Konrad.

-- 
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: roll call of production use?

2009-11-24 Thread John Harrop
On Tue, Nov 24, 2009 at 1:04 AM, Meikel Brandmeyer  wrote:

> Hi,
>
> On Nov 24, 6:06 am, John Harrop  wrote:
>
> > Oh, I have no problem with making money by using open source software,
> when
> > it's done in the manner that companies like Red Hat do it. It's the use
> to
> > lock down some piece of proprietary software even more than it already is
> > that seems, at the very least, ironic.
>
> A license server does not necessarily mean restriction. We have a
> small in-house app which is also handled via a license server. It just
> records, who uses the app and charges 25€ per year and user on the
> cost center of the using department. No restriction whatsoever.
>

Not enabling people to use it for free = restriction, given that marginal
increased use by them does not correspond to marginal increased costs to
you. (If it means marginal increased costs for support, why not sell the
support and let them use it for free unsupported if they choose to? Charge
per incident, or for a maintenance plan, or whatever. Red Hat makes millions
doing that.)


> To say something productive for the discussion:
>
> I use Clojure to drive our regular quality reporting. It takes
> information from different source, mainly different SAP systems but
> also supplier data provided via Excel. Everything is imported into
> database and after a lot of JOINs, SELECTs and UNIONs a pdf containing
> the charts with a home-grown analysis is generated. The charts and pdf
> are still work in progress, but everything else works nicely so far.


There's a Clojure or a Java library for generating pdf?

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

Re: problem with resolve

2009-11-24 Thread Christophe Grand
On Tue, Nov 24, 2009 at 12:01 PM, kony  wrote:

> Hi,
>
> I found that resolve does not work correctly (I guess) when it is
> called from other thread than main:
>
> e.g.
>
> let define
>
> (def zz 123)
>
> and afterwords call:
>
> (.start (new Thread #(println (resolve 'zz
>
> for me it does not work (it returns nil)
>


This is because the spawned thread isn't in the current namespace:
user=> (.start (Thread. #(println *ns*)))
nil
#

So you have to capture a reference to your current ns one way or the other.
Some examples:
(.start (let [ns *ns*] (Thread. #(binding [*ns* ns] (println (resolve
'zz))
or
(.start (let [ns *ns*] (Thread. #(println (ns-resolve ns 'zz)
or
(.start (let [resolve (partial ns-resolve *ns*)] (Thread. #(println (resolve
'zz)

Note that if your symbol is namespaced that simply works:
(.start (Thread. #(println (resolve 'user/zz
or, simpler:
(.start (Thread. #(println (resolve `zz ; a backquote

hthn

Christophe


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (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: problem with resolve

2009-11-24 Thread John Harrop
On Tue, Nov 24, 2009 at 6:01 AM, kony  wrote:

> Hi,
>
> I found that resolve does not work correctly (I guess) when it is
> called from other thread than main:
>
> e.g.
>
> let define
>
> (def zz 123)
>
> and afterwords call:
>
> (.start (new Thread #(println (resolve 'zz
>
> for me it does not work (it returns nil)
>

Seems to be an issue with *ns*:

sandbox=> *ns*
#
sandbox=> (.start (new Thread #(println *ns*)))
#

It's a dynamic var and I guess clojure.core is the root binding. You'll have
to use (in-ns foo) or (binding [*ns* foo] ...) or something to really fix
it.

-- 
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: problem with resolve

2009-11-24 Thread Krukow


On Nov 24, 12:01 pm, kony  wrote:
> Hi,
>
> I found that resolve does not work correctly (I guess) when it is
> called from other thread than main:

I guess your new thread also has the root binding for *ns* the current
namespace, which apparently is core
user=> (.start (new Thread #(println *ns*)))
nil
user=> #

So you could do this:

user=> (def zz 42)
#'user/zz
user=> (.start (new Thread #(println (ns-resolve 'user 'zz
nil
user=> #'user/zz

What is the use case? Or are you just playing around?
/Karl

-- 
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: problem with resolve

2009-11-24 Thread Krukow

Three concurrent replies. We'd be better off using locks :-)

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

2009-11-24 Thread Garth Sheldon-Coulson
Happy it helped.

I should mention that I used Meikel's docs as a guide, but my code
don't actually push or pop all the thread bindings every time I return
a lazy seq or a fn.

It felt a little ugly to me to bind *all* the dynamic vars in the
namespace when I knew there were only two I needed to care about. So,
in the locations where I build lazy seqs or fns to return to the user,
I "manually" close over and bind *options* and *kernel*.

I'd be really interested in hearing others' views on the propriety of
binding all the dynamic vars every time using bound-fn or equivalent.

On 11/24/09, Mark Engelberg  wrote:
> On Mon, Nov 23, 2009 at 11:39 PM, Garth Sheldon-Coulson 
> wrote:
>> Hi Mark,
>>
>> In Clojuratica I make what I think is "good, clean, compelling use" of
>> dynamic vars. I rewrote the code to use dynamic vars after I found that
>> doing it the other way became unwieldy and inelegant.
>
> OK this makes sense to me.
>
> Your use case is actually very similar to mine (lots of interrelated
> functions where it would be cleaner to have them refer to some sort of
> global variable that is set prior to execution).  But I got tripped up
> because:
> 1.  I think I had more use of laziness in my code than how you describe
> yours.
> 2.  I didn't know the push-thread-bindings/pop-thread-bindings trick
> to fix the spots with laziness (I tried just forcing the lazy
> sequences which killed my performance -- I really needed laziness).
> 3.  Even if I had known the trick, I may have had difficulty
> identifying all the spots where laziness was an issue since I was
> returning a complex lazy tree structure.  (I probably would have
> tried, though.)
>
> So now that you've explained your use of dynamic bindings, I can
> totally imagine scenarios where it is easier to "tame the laziness"
> than go back to passing all the "globals" around, especially with the
> convenient bound-seq macro that Meikel posted.
>
> This brings up another question in my mind.  What kind of impact would
> it have on people's code if *all* calls to lazy-seq operated the way
> that bound-seq does?  Would this make things more intuitive or less
> intuitive?  Would this radically reduce performance?
>
> --
> 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
>

-- 
Sent from my mobile device

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


performance issues with multi-dimensional array

2009-11-24 Thread Amnon
I hope it's not the billion time you get the question.
I wanted to use clojure for image processing. I have a 3 dimensional
array I'm passing to clojure from java.
I then loop on the array to manipulate it.
Even the simplest task takes about half a minutes (I expected it to be
over in less than a second)

For example, I am turning an array to gray scale.
I tried to erase all my false improvements and squeeze everything to a
single function:

grey should get a 3Dim array (WxHx3 colors) and return it in a gray
scale.
Any help would be highly appreciated.
Amnon

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


Setting *warn-on-reflection* such that multiple threads can see it

2009-11-24 Thread Chris Jenkins
Hi,

Is it possible to set *warn-on-reflection* such that it can be seen by
multiple threads? I can't use def to define *warn-on-reflection* because it
is defined in another namespace. I can use set! to change the value of the
binding for one thread but this is not seen by other threads:

(set! *warn-on-reflection* true)
(.start (Thread. #(println *warn-on-reflection*)))

...prints false

The reason that I would like to do this is that I'm writing a program that
uses Swing and I'd like to see if reflection is used on callbacks that
execute on the AWT event thread... ideally without having to figure out how
to make Swing call my function that sets *warn-on-reflection* before it does
anything else.

Cheers,

Chris

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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: performance issues with multi-dimensional array

2009-11-24 Thread Konrad Hinsen
On 24 Nov 2009, at 17:30, Amnon wrote:

> I hope it's not the billion time you get the question.
> I wanted to use clojure for image processing. I have a 3 dimensional
> array I'm passing to clojure from java.
> I then loop on the array to manipulate it.
> Even the simplest task takes about half a minutes (I expected it to be
> over in less than a second)

Could you give some more details? For example, what is the Java class  
you use for the 3D arrays? How are you accessing it from Clojure? How  
do  you do the loops? How do you create the destination array, and how  
do you fill it with the grey-scale values? I suspect that many of  
these steps could be optimized, but it's hard to say without knowing  
how your current code works.

Konrad.

-- 
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: roll call of production use?

2009-11-24 Thread Rich Hickey


On Nov 23, 9:47 pm, Richard Newman  wrote:

> Anyway, apologies for possibly starting a "closed-source is evil"  
> debate. Let's hope it fizzles.

Yes, please, let's end this here. Any further non-Clojure content on
this thread might be moderated.

Thanks,

Rich

-- 
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: "Oh, yeah, transients are fast!"

2009-11-24 Thread Raoul Duke
> I believe that this is most likely a symptom of the Apple JVM and not

yeah, given Apple's wonderful treatment of Java over the years, i
could believe your theory.

-- 
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: "Oh, yeah, transients are fast!"

2009-11-24 Thread Richard Newman
> I believe that this is most likely a symptom of the Apple JVM and not
> that of transients as the change from persistents to transients is  
> far more substantial
> on one of our linux servers than it is on my macbook pro (6x vs 2x  
> speedup)

Not necessarily so. My times earlier in this thread (4GB Core 2 Duo  
MacBook Pro, Apple's JDK 6, Regular Leopard) showed a 10x speedup.

Most likely it's related to the JVM version (1.5 by default), the  
amount of memory allocated (I use -Xmx512m), the amount of L2 cache, a  
HotSpot tuning parameter, or something else along those lines.

There are far too many possibilities to consider, and too little  
evidence, to support a conclusion of "it's just Apple's JVM".

-- 
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: "Oh, yeah, transients are fast!"

2009-11-24 Thread Raoul Duke
> Most likely it's related to the JVM version (1.5 by default), the
> amount of memory allocated (I use -Xmx512m), the amount of L2 cache, a
> HotSpot tuning parameter, or something else along those lines.
>
> There are far too many possibilities to consider, and too little
> evidence, to support a conclusion of "it's just Apple's JVM".

(i love how supposedly we've come so far with our systems, only to
have them become overly complex. it is to sigh. on the other hand i
guess it is 'job security'.)

-- 
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: Deep deref

2009-11-24 Thread Krukow


On Nov 14, 5:42 pm, André Thieme  wrote:
> But in real programs things are not so easy. We have refs in refs.

This is just a thought experiment. But what about actually having refs
in refs? I'm not sure if I am reinventing mutable object here, so
please shoot me down ;-)

Clojure 1.1.0-alpha-SNAPSHOT
user=> (deftype Person [name age friends]
[clojure.lang.IPersistentMap])
#'user/Person
user=> (def *persons* (ref {}))
#'user/*persons*
user=> (dosync (alter *persons* assoc :ethel (ref (Person "ethel" 24
[]
{:ethel #}
user=> (dosync (alter *persons* assoc :fred (ref (Person "fred" 42
[]
{:fred #, :ethel #}
user=> @*persons*
{:fred #, :ethel #}

;;now...

user=> (dosync (alter (:fred @*persons*)
(fn [f] (assoc f :friends (conj (:friends f)
(:ethel @*persons*))
#:Person{:name "fred", :age 42, :friends [#]}
user=> @*persons*
{:fred #]}
>, :ethel #}
user=> (identical? (first (:friends @(:fred @*persons*))) (:ethel
@*persons*))
true

Note that Fred and Ethel are identities, and their corresponding refs
still refer to *immutable* values (the refs themselves).

Now to inc age:

user=> (dosync (alter (:ethel @*persons*) update-in [:age] inc))
#:Person{:name "ethel", :age 25, :friends []}
user=> @*persons*
{:fred #]}
>, :ethel #}

In a way, I like the modeling: the people are actually identities and
there are relations between identities. STM ensures consistent
snapshots.

So am I reinventing objects in a bad way, or is this just recognizing
the true identities?

:-)

/K

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


Re: "Oh, yeah, transients are fast!"

2009-11-24 Thread Richard Newman
> (i love how supposedly we've come so far with our systems, only to
> have them become overly complex. it is to sigh. on the other hand i
> guess it is 'job security'.)

Heh, true. Reading articles about JVM tuning reminds me what the "M"  
stands for -- it's as complicated a topic as optimizing the interface  
between your code and a real machine.

E.g.,

http://blogs.sun.com/bharath/entry/taming_gc_for_sip_applications
http://blog.headius.com/2009/01/my-favorite-hotspot-jvm-flags.html

Your point about job security is spot on, though -- every time the  
topics of VHLLs, autonomic systems, and so on arise, I gently point  
out that somebody needs to figure out what's going on when they stop  
working, and the smarter they get, the more fiendish the problems!

-- 
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: performance issues with multi-dimensional array

2009-11-24 Thread Christophe Grand
On Tue, Nov 24, 2009 at 5:30 PM, Amnon  wrote:

> I hope it's not the billion time you get the question.
> I wanted to use clojure for image processing. I have a 3 dimensional
> array I'm passing to clojure from java.
> I then loop on the array to manipulate it.
> Even the simplest task takes about half a minutes (I expected it to be
> over in less than a second)
>
> For example, I am turning an array to gray scale.
> I tried to erase all my false improvements and squeeze everything to a
> single function:
>
> grey should get a 3Dim array (WxHx3 colors) and return it in a gray
> scale.
> Any help would be highly appreciated.
> Amnon
>


It would be easier with some of your code. Meanwhile, check this post
http://clj-me.cgrand.net/2009/10/15/multidim-arrays/ (it doesn't apply as is
to clojure 1.0, you have to replace #^objects by #^"[Ljava.lang.Object;").

Christophe

-- 
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: Setting *warn-on-reflection* such that multiple threads can see it

2009-11-24 Thread Christophe Grand
Hi,

On Tue, Nov 24, 2009 at 6:38 PM, Chris Jenkins  wrote:

> Is it possible to set *warn-on-reflection* such that it can be seen by
> multiple threads? I can't use def to define *warn-on-reflection* because it
> is defined in another namespace. I can use set! to change the value of the
> binding for one thread but this is not seen by other threads:
>
> (set! *warn-on-reflection* true)
> (.start (Thread. #(println *warn-on-reflection*)))
>
> ...prints false
>
> The reason that I would like to do this is that I'm writing a program that
> uses Swing and I'd like to see if reflection is used on callbacks that
> execute on the AWT event thread... ideally without having to figure out how
> to make Swing call my function that sets *warn-on-reflection* before it does
> anything else.
>

*warn-on-reflection* is a compile-time flag, not a runtime flag so, unless
you are using eval in the event thread, you don't need to care. Clojure
outputs the warnings once: when you define the function.

hth,

Christophe

-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (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: Deep deref

2009-11-24 Thread Krukow


On Nov 24, 7:50 pm, Krukow  wrote:
> On Nov 14, 5:42 pm, André Thieme  wrote:
>
> > But in real programs things are not so easy. We have refs in refs.
>
> This is just a thought experiment. But what about actually having refs
> in refs? I'm not sure if I am reinventing mutable object here, so
> please shoot me down ;-)
>
Please ignore :-( Just realized I didn't actually understand the
original 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


N00B Java Question

2009-11-24 Thread Peter Wolf
Hi all,

Here is a N00B question, but I can not find the answer by Googling, or 
reading Stuart's book.  So, I assume that others will want to find this 
FAQ in the future.

I am calling legacy code, and I need to set the level on the Java Logger.

In Java it would look like this

   import java.util.logging.Logger
   import java.util.logging.Level

   Logger.getLogger("").setLevel(Level.WARNING)

What is the Clojure equivalent?  In particular, what is the equivalent 
of Level.WARNING?

Level.WARNING is a static field of Level, and is an instance of Level.  
There is no getter method.  I can't find anything about accessing static 
fields in the docs.

Thanks in advance
Peter

-- 
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 User Survey, preparation for 1.1

2009-11-24 Thread David Brown
On Tue, Nov 24, 2009 at 01:04:57AM -0800, Meikel Brandmeyer wrote:
>Hi,
>
>On Nov 24, 9:44 am, bOR_  wrote:
>
>> Can we get an option 'leiningen' at "how do you get clojure"?
>
>I think this is basically Maven/Ivy, no?

Leiningen includes, within it's own Jar, a particular version of the
clojure snapshot, which is why it currently only compiles against the
one built into it.  It uses Maven to download other dependencies, but
not Clojure itself.

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: N00B Java Question

2009-11-24 Thread Christophe Grand
Hi,

On Tue, Nov 24, 2009 at 10:39 PM, Peter Wolf  wrote:

> Here is a N00B question, but I can not find the answer by Googling, or
> reading Stuart's book.  So, I assume that others will want to find this
> FAQ in the future.
>
> I am calling legacy code, and I need to set the level on the Java Logger.
>
> In Java it would look like this
>
>   import java.util.logging.Logger
>   import java.util.logging.Level
>
>   Logger.getLogger("").setLevel(Level.WARNING)
>
> What is the Clojure equivalent?  In particular, what is the equivalent
> of Level.WARNING?
>

(.setLevel (Logger/getLogger "") Level/WARNING)
or (-> (Logger/getLogger "") (.setLevel Level/WARNING))

see http://clojure.org/java_interop#toc5

Christophe


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (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: N00B Java Question

2009-11-24 Thread Sean Devlin
Static field are accessed with the / operator

user=>(import (java.util.logging Logger Level))

user=>(let [a-logger (Logger/getLogger "")]
(.setLevel a-logger Level/WARNING))

Or, this could be chained as

user=>(.setLevel (Logger/getLogger "") Level/WARNING)

Hope this helps,
Sean

On Nov 24, 4:39 pm, Peter Wolf  wrote:
> Hi all,
>
> Here is a N00B question, but I can not find the answer by Googling, or
> reading Stuart's book.  So, I assume that others will want to find this
> FAQ in the future.
>
> I am calling legacy code, and I need to set the level on the Java Logger.
>
> In Java it would look like this
>
>    import java.util.logging.Logger
>    import java.util.logging.Level
>
>    Logger.getLogger("").setLevel(Level.WARNING)
>
> What is the Clojure equivalent?  In particular, what is the equivalent
> of Level.WARNING?
>
> Level.WARNING is a static field of Level, and is an instance of Level.  
> There is no getter method.  I can't find anything about accessing static
> fields in the docs.
>
> Thanks in advance
> Peter

-- 
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: N00B Java Question

2009-11-24 Thread David Brown
On Tue, Nov 24, 2009 at 04:39:38PM -0500, Peter Wolf wrote:

>Here is a N00B question, but I can not find the answer by Googling, or
>reading Stuart's book.  So, I assume that others will want to find this
>FAQ in the future.

I think it's also change a bit since the book.

>I am calling legacy code, and I need to set the level on the Java Logger.

Clojure doesn't really consider calling Java to be legacy.  Interop
with Java is fully embraced.

>In Java it would look like this
>
>   import java.util.logging.Logger
>   import java.util.logging.Level
>
>   Logger.getLogger("").setLevel(Level.WARNING)
>
>What is the Clojure equivalent?  In particular, what is the equivalent
>of Level.WARNING?

   (.setLevel (Logger/getLogger "") Level/WARNING)

Although there are other variants that will work.

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: roll call of production use?

2009-11-24 Thread RandyHudson


On Nov 24, 11:30 am, John Harrop  wrote:

> There's a Clojure or a Java library for generating pdf?

Apache FOP is an XSL-FO processor than can generate PDF documents.
I've heard good things about iText, a Java library for generating or
modifying PDF docs.

-- 
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: Setting *warn-on-reflection* such that multiple threads can see it

2009-11-24 Thread Chris Jenkins
That's great - now why didn't I realise that :-)

Thanks,

Chris




2009/11/24 Christophe Grand 

> Hi,
>
>
> On Tue, Nov 24, 2009 at 6:38 PM, Chris Jenkins wrote:
>
>> Is it possible to set *warn-on-reflection* such that it can be seen by
>> multiple threads? I can't use def to define *warn-on-reflection* because it
>> is defined in another namespace. I can use set! to change the value of the
>> binding for one thread but this is not seen by other threads:
>>
>> (set! *warn-on-reflection* true)
>> (.start (Thread. #(println *warn-on-reflection*)))
>>
>> ...prints false
>>
>> The reason that I would like to do this is that I'm writing a program that
>> uses Swing and I'd like to see if reflection is used on callbacks that
>> execute on the AWT event thread... ideally without having to figure out how
>> to make Swing call my function that sets *warn-on-reflection* before it does
>> anything else.
>>
>
> *warn-on-reflection* is a compile-time flag, not a runtime flag so, unless
> you are using eval in the event thread, you don't need to care. Clojure
> outputs the warnings once: when you define the function.
>
> hth,
>
> Christophe
>
> --
> Professional: http://cgrand.net/ (fr)
> On Clojure: http://clj-me.cgrand.net/ (en)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Re: Clojure Scoping Rules

2009-11-24 Thread Meikel Brandmeyer

Hi,

Am 24.11.2009 um 18:47 schrieb Garth Sheldon-Coulson:


I'd be really interested in hearing others' views on the propriety of
binding all the dynamic vars every time using bound-fn or equivalent.


I asked whether it should to take a map or not in the assembla thread  
of the ticket. But there was no response on the question. So I guess  
it is ok. It really only considers vars with a non-root binding. So  
unless you bind thousand different Vars it's likely not a problem. You  
wouldn't use binding inside a tight loop anyway...


Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: roll call of production use?

2009-11-24 Thread Meikel Brandmeyer

Hi,

Am 24.11.2009 um 17:30 schrieb John Harrop:


There's a Clojure or a Java library for generating pdf?


I use enlive to generate a HTML version with CSS of the report. This  
is turned by virtue of flying saucer and iText into PDF. At least that  
is the plan. Whether it will work satisfactory is a different story.  
At least the initial results look promising. :)


Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: problem with resolve

2009-11-24 Thread kony


On 24 Lis, 18:07, Krukow  wrote:
> Three concurrent replies. We'd be better off using locks :-)

Three concurrent replies but each of them brings something new ;)
Thank you very much for all of them!

... what is the use case,... I am just working on some kind of process
algebra simulator written in Clojure. Processes have to be interpreted
in the separate threads, so that is why that problem arose.

BTW: another question is whether the behavior of resolve is a feature
or it is rather implementation error. Be honest I do not have opinion
in this matter. To little I know the Clojure.

-- 
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: N00B Java Question

2009-11-24 Thread Meikel Brandmeyer

Hi,

Am 24.11.2009 um 22:39 schrieb Peter Wolf:


  Logger.getLogger("").setLevel(Level.WARNING)


(.setLevel (Logger/getLogger "") Level/WARNING)

Methods: obj.method(args) => (.method obj args)
Static methods: Class.method(args) => (Class/method args)
Static members: Class.MEMBER => Class/MEMBER

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


clojuresque 1.1.0 released (formerly known as clj-gradle)

2009-11-24 Thread Meikel Brandmeyer

Dear fellow Clojurians,

I'd like to announce a new release of Clojuresque formerly known as  
clj-gradle. There not many changes, but some fixes. Namely:


* compileClojure now fails, when compilation fails
* compileClojure does not depend on compileJava anymore. The user can  
decide now.

* one can specify warn-on-reflection on a per source set basis
* one can change the source directory of a source set (was previously  
hardwired)

* features a new nice name now :)

Quickstart:

buildscript {
repositories {
mavenRepo name: 'clojars', urls: 'http://clojars.org/repo'
}
dependencies {
classpath 'clojuresque:clojuresque:1.1.0'
}
}

usePlugin(clojuresque.ClojurePlugin)

group = 'your.group.here'
version = 'your.version.here'

configurations {
compileOnly {
transitive = false
visible = false
}
compile.extendsFrom(compileOnly)
}

repositories {
mavenRepo name: 'clojars', urls: 'http://clojars.org/repo'
}

dependencies {
compileOnly 'clojuresque:clojuresque:1.1.0'
compile 'org.clojure:clojure:1.0.0'
}

// Dummy to make gradle generate a POM.
uploadArchives {
repositories.mavenDeployer {
repository(url: String.format("file://%s/dummy-repo",  
project.buildDir.path))

}
}

task deployClojars(dependsOn: uploadArchives) << {
ant.exec(executable: '/usr/bin/scp') {
arg(value: String.format("%s/poms/pom-default.xml",
project.buildDir.path))
arg(value: String.format("%s/libs/%s-%s.jar",
project.buildDir.path,
project.name, project.version))
arg(value: "cloj...@clojars.org:")
}
}

Please report issues in the bug tracker on http://bitbucket.org/kotarak/clojuresque 
.


Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: roll call of production use?

2009-11-24 Thread Anniepoo
At my workplace (University of Houston, dept. of Health and Human
Performance) Clojure is our primary language for interacting with our
virtual world presence in Second Life.
We have an automated lesson path building system currently in
production, and several other projects in various states.

automated lesson path building system - user (currently it's too
scratchy to turn the profs loose on this, so I always use it) draws a
learning path out in a 2D swing based clojure app. It compiles a set
of 'prims' that fill the needed shapes (a sort of variation on the
knapsack problem, where you also get a small 'rubber' block that can
fill in small spaces, but it's an optimal packing problem), creates
the textures, controls a C# robot (no java libs for that task) to
upload the textures, and sends commands to a robot in-world to do the
actual build.

Nutrition Goggles system - What I should be doing today, if I weren't
noodling around in Clojure  8cD
(OK, in theory the injectable agent system I'm doing today should be
usable for all these projects)
This is a HUD (tool that attaches to the users screen as additional
UI), when they look at a food item in the virtual environment it shows
the nutrition data. They also can enter nutrition data the same way.
Back end in clojure.

Summoner monitor system - I'm supposed to write this, I'd dearly love
to get there, as it's a tool that alerts me
 that I'm needed in world to help a student. (currently I depend on my
email alerter, which is suboptimal)

Configurable teleporting sign system - a web app that lets users set
up teleporters around the campus sim, while retaining some control
over the appearance of the central entry area. Might not end up being
in clojure, I might do this totally in world.

-- 
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: Clojure API for AllegroGraph

2009-11-24 Thread patrickdlogan
Hi Mike - thanks for this.

I am fairly new to git, but from what I can tell, I have the agraph32
branch as current. The clojure code on the agraph32 branch still seems
to be using the AG 4.0 API. For example...

http://github.com/franzinc/agraph-java-client/blob/agraph32/clojure/test/com/franz/agraph/agtest.clj

Running this against the agraph32 branch java jar results in a class
not found exception...

java.lang.ClassNotFoundException:
com.franz.agraph.repository.AGCatalog (agtest.clj:0)





On Nov 14, 4:05 pm, Mike Hinchey  wrote:
> Franz Inc and I just put the AllegroGraph 3.2 Java API on github with my new
> Clojure API.  The clojure is a wrapper of the java client, which is an
> implementation of openrdf/sesame.  The wrapper is mostly to make it more
> idiomatic clojure so you don't have to deal with so many java classes,
> mutable objects, and resources that have to be closed.  It's a
> work-in-progress, of course, and any feedback is appreciated.
>
> The master branch is for the future release AG 4.0, so you'll want to use
> the agraph32 branch for the current 
> release.http://github.com/franzinc/agraph-java-client/tree/agraph32
>
> This is the code I'll be presenting tomorrow at the Semantic Web
> installfest.http://www.meetup.com/The-San-Francisco-Semantic-Web-Meetup/calendar/...
>
> My future plans for this are to have more advance ways of manipulating
> triples, especially having them linked up in trees rather than a flat lists
> referring to each other, which is what you get back from a query.
>
> By the way, I included the clojure-1.0.jar because I assume this will be
> used by companies that need a stable release, but last I checked, the code
> works fine with master, and I'm happy to officially support master if that's
> what anyone wants.
>
> -Mike

-- 
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: Clojure API for AllegroGraph

2009-11-24 Thread Mike Hinchey
You're right, the tests have not been converted to 3.2, so they are not
running at this time.  The best thing to look at is the tutorial.clj - most
of these work properly, but example6 doesn't return correct results.  The
ones that don't work is where the clj code is incomplete, so I still have
some work to do.  I'll get these fixed or documented in the next few days.

-Mike

On Tue, Nov 24, 2009 at 3:31 PM, patrickdlogan wrote:

> Hi Mike - thanks for this.
>
> I am fairly new to git, but from what I can tell, I have the agraph32
> branch as current. The clojure code on the agraph32 branch still seems
> to be using the AG 4.0 API. For example...
>
>
> http://github.com/franzinc/agraph-java-client/blob/agraph32/clojure/test/com/franz/agraph/agtest.clj
>
> Running this against the agraph32 branch java jar results in a class
> not found exception...
>
> java.lang.ClassNotFoundException:
> com.franz.agraph.repository.AGCatalog (agtest.clj:0)
>
>
>

-- 
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: AOT'd namespaces lose their metadata

2009-11-24 Thread Tom Faulhaber
I did take a little bit of a look at it and it is both simple and
complex.

When you're not AOT compiling code, the symbol that's creating the
namespace gets wrapped with metadata when the ns macro is evaluated.
This metadata is then explicitly moved on to the namespace.

When the compiler runs, it doesn't seem that it is so explicit about
namespace creation. It essentially does (in-ns 'foo) which will create
the ns foo on the fly if appropriate. There is currently no code
generated to do anything *explicit* with the namespace and, therefore,
no place to decide that the namespace has metadata and tack it on.

I got about as far as I could eyeballing the code and wanted to get it
up in the debugger, but I don't have a Java debug environment set up
and my Clojure time has been super limited lately owing to all sorts
of other things happening in my life (I am *so* jealous of you guys
who are doing makor Clojure projects). If I get some time, I'll dig in
enough to make a patch, but it might be a few more months. I feel like
the fix will be pretty easy, once the real flow is well-understood.
This is my first foray into the compiler, so there's a lot to
understand (though it's all pretty straightforward).

So, Phil, if you want to take it from there, it would be great. If you
don't, I'll keep it on my list.

Tom


On Nov 23, 2:38 am, Lauri Pesonen  wrote:
> 2009/11/23 Phil Hagelberg :
>
>
>
> > I noticed an odd bug when working on the help command for leiningen. It
> > uses docstrings on metadata for help output, but when AOTing the
> > project, the docstrings (as well as all other metadata) would be
> > lost. Note that this doesn't happen when metadata is added to the
> > namespace after the fact as is the case with clojure.core and
> > alter-meta!.
>
> > Any idea what might be causing this? I'd like to dig deeper but am
> > unsure where to look.
>
> There's a ticket for it
>
> https://www.assembla.com/spaces/clojure/tickets/130-Namespace-metadat...
>
> but I don't think anyone's spent any time in trying to fix it.
>
> > thanks,
> > Phil
>
> --
>   ! Lauri

-- 
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: N00B Java Question

2009-11-24 Thread dannyo152
Peter:

I recommend pages 60-62 in Stuart's book for demonstrating how to do
this. The notes about (. Math PI) or Math/PI (equivalent notations)
are very much to point.

To demonstrate:

;first the import
user=> (import '(java.util.logging Logger Level))
nil

;create a logger
user=> (def our-logger (. Logger getLogger ""))
#'user/our-logger


;set the level
user=> (. our-logger setLevel Level/WARNING)
nil

;check
user=> (. our-logger getLevel)
#

I only knew where to look because as a java-slinging N00B myself, I
had many questions about java interop.

Dan



On Nov 24, 1:39 pm, Peter Wolf  wrote:
> Hi all,
>
> Here is a N00B question, but I can not find the answer by Googling, or
> reading Stuart's book.  So, I assume that others will want to find this
> FAQ in the future.
>
> I am calling legacy code, and I need to set the level on the Java Logger.
>
> In Java it would look like this
>
>    import java.util.logging.Logger
>    import java.util.logging.Level
>
>    Logger.getLogger("").setLevel(Level.WARNING)
>
> What is the Clojure equivalent?  In particular, what is the equivalent
> of Level.WARNING?
>
> Level.WARNING is a static field of Level, and is an instance of Level.  
> There is no getter method.  I can't find anything about accessing static
> fields in the docs.
>
> Thanks in advance
> Peter

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


Sneak Peek

2009-11-24 Thread jim
Evening all,

I've been working on a library for writing web applications for
compojure. I've got it written and (I think) working. First thing
tomorrow is to write a sample app and post it along with the library.

But in the meantime, I thought I'd let you all read about it if you're
having trouble sleeping. :)

http://intensivesystems.net/tutorials/web_sessions.html

One thing I love about FP in general and Clojure specifically is the
density of code that is possible. This library is only about 80 lines
of code.

Jim

-- 
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: AOT'd namespaces lose their metadata

2009-11-24 Thread Phil Hagelberg
Tom Faulhaber  writes:

> So, Phil, if you want to take it from there, it would be great. If you
> don't, I'll keep it on my list.

Thanks for the notes; nice to see someone has done some detective work
already. I'll probably try to take a look at this once I get Leiningen
1.0 out. It looks like ticket #130 in Assembla is about this problem, so
I'll be sure to add a note to there once I start working on it.

-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: Datatypes and Protocols - early experience program

2009-11-24 Thread Allen Rohner


On Nov 12, 6:10 am, Rich Hickey  wrote:
> An early version of the code for a few important new language
> features, datatypes[1] and protocols[2] is now available in the 'new'
> branch[3]. Note also that the build system[4] has builds of the new
> branch, and that the new branch works with current contrib.
>
> If you have the time and inclination, please try them out. Feedback is
> particularly welcome as they are being refined.
>
> Thanks,
>
> Rich
>
> [1]http://www.assembla.com/wiki/show/clojure/Datatypes
> [2]http://www.assembla.com/wiki/show/clojure/Protocols
> [3]http://github.com/richhickey/clojure/tree/new
> [4]http://build.clojure.org/



On Nov 12, 6:10 am, Rich Hickey  wrote:
> An early version of the code for a few important new language
> features, datatypes[1] and protocols[2] is now available in the 'new'
> branch[3]. Note also that the build system[4] has builds of the new
> branch, and that the new branch works with current contrib.
>
> If you have the time and inclination, please try them out. Feedback is
> particularly welcome as they are being refined.
>
> Thanks,
>
> Rich
>
> [1]http://www.assembla.com/wiki/show/clojure/Datatypes
> [2]http://www.assembla.com/wiki/show/clojure/Protocols
> [3]http://github.com/richhickey/clojure/tree/new
> [4]http://build.clojure.org/

And a feature request: Validators on deftypes. Currently, I have a
bunch of refs that point at maps, with validator functions. The ref
validators mainly validate the contents of the map, i.e. that certain
keys are present and have sane values. It seems to make more sense to
do the checking on the type validator, and then the ref's validator
would just check that the ref's value is the correct type.

Allen

-- 
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: problem with resolve

2009-11-24 Thread Krukow


On Nov 24, 9:45 pm, kony  wrote:
> On 24 Lis, 18:07, Krukow  wrote:
>
> > Three concurrent replies. We'd be better off using locks :-)
>
> Three concurrent replies but each of them brings something new ;)
> Thank you very much for all of them!
>
> ... what is the use case,... I am just working on some kind of process
> algebra simulator written in Clojure. Processes have to be interpreted
> in the separate threads, so that is why that problem arose.
>
> BTW: another question is whether the behavior of resolve is a feature
> or it is rather implementation error. Be honest I do not have opinion
> in this matter. To little I know the Clojure.

It's not an error: vars have a root binding and thread local semantics
(*ns* is root-bound to the clojure.core namespace, and in the repl
thread it is bound to the user namespace). Since you are starting a
new thread that thread sees the root binding.

http://clojure.org/vars

But you usually don't need to use resolve directly:
(If in emacs, make sure you do M-x slime-redirect-inferior-output - if
you don't, you won't see the threads output)

user> (def zz 42)
#'user/zz
user> (.start (Thread. #(println zz)))
42
nil
user> (.start (Thread. #(println (resolve 'zz
nil
nil
user> (.start (Thread. #(println (ns-resolve 'user 'zz
#'user/zz

Regards,
/Karl

-- 
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: roll call of production use?

2009-11-24 Thread Adrian Cuthbertson
For a data analysis/reporting application, I use colt for some matrix
processing, joda time for period calculations, jfreechart to generate
charts, an adaptation clj-html to create some dynamic html, also now
some StringTemplate templates to bring in and manipulate static
content and finally all this (as html) gets fed into XhtmlRenderer to
emit some beautiful css stylized PDF reports.

Sounds like a mish-mash and it is, but clojure has allowed me to
create all the right abstractions, manage the processing flows and
build a complex application leveraging many powerful java libraries
that would have just been too much effort (for me) to do in plain old
java.

The other spin-off of this is that using the repl, one is able to
really explore the api's of these big libraries dynamically and get to
know them much more intimately than when doing static compilation/run
cycles as in the past. So, a major benefit for me of learning clojure
has also been a substantial increase in my depth of knowledge of the
workings of some of the excellent java libraries out there.

- Adrian.

On Tue, Nov 24, 2009 at 8:52 PM, RandyHudson  wrote:
>
>
> On Nov 24, 11:30 am, John Harrop  wrote:
>
>> There's a Clojure or a Java library for generating pdf?
>
> Apache FOP is an XSL-FO processor than can generate PDF documents.
> I've heard good things about iText, a Java library for generating or
> modifying PDF docs.
>
> --
> 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: roll call of production use?

2009-11-24 Thread eyeris
I used clojure to write an application that interpolates SQL results
(from clojureql) into Excel spreadsheets (using Java interop to
Apache's POI lib). I have a two users putting this to use for their
project progress reporting.


On Nov 23, 5:00 pm, Raoul Duke  wrote:
> hi,
>
> i'd be interested to hear who has successfully used clojure in
> production. i know of some, as some folks have been vocal; any other
> interesting-but-so-far-silent uses people'd be willing to fess up
> about?
>
> many thanks.

-- 
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: roll call of production use?

2009-11-24 Thread Daniel Simms
--
Daniel Simms 


On Nov 24, 2009, at 22:23, Adrian Cuthbertson  wrote:

> The other spin-off of this is that using the repl, one is able to
> really explore the api's of these big libraries dynamically and get to
> know them much more intimately than when doing static compilation/run
> cycles as in the past.

Oh, +1 to that.  Similarly, having the repl in production contexts is
super useful.  (No, the repl-ness isn't unique to clojure but it's
really useful.)
>

-- 
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: "arithmetic" change between 1.0.0 and 1.1. 0

2009-11-24 Thread Stephen C. Gilardi

On Nov 16, 2009, at 5:56 AM, prhlava wrote:

> No big deal, the fix is simple - this is heads up if more people find
> their code broke with over-flow to infinity with the new version of
> clojure.
> 
> It looks that float type "propagates" into arithmetics (and it did not
> before) - better explanation welcome.

I think your analysis is likely correct. Certainly Math/floor does return a 
Double and Clojure's number handling has evolved over time.

As an alternative to the code you posted, for positive integers n and m,

(int (Math/floor (/ n m))

is equivalent to

(quot n m)

If negative values are possible, you could write a function based on quot that 
would give the appropriate answer in all cases.

--Steve



smime.p7s
Description: S/MIME cryptographic signature