Re: Got a Clojure library?

2009-05-01 Thread Mark Derricutt
Is there support in this lib currently for reusing an existing MailSession (or passing in say "java://comp/env/mail/Session" and having it handle the lookup? Shouldn't be hard to add in if its not already there? -- Discouragement is a dissatisfaction with the past, a distaste for the present, an

Re: Why does this not work?

2009-05-01 Thread Michael Wood
On Fri, May 1, 2009 at 10:57 PM, Santanu wrote: > > On May 2, 1:13 am, Meikel Brandmeyer wrote: > >> fn is a macro which expands into a call to fn* which is a special >> form. It is not meant to be used directly. > > So, are these 'entities' that end in * something like > private functions? I d

Re: Why does this not work?

2009-05-01 Thread Stephen C. Gilardi
On May 1, 2009, at 5:24 PM, Michael Wood wrote: I don't think it's so hard and fast. I think of it more like somefunc is the usual thing, and somefunc* is similar, but not as commonly used. Maybe someone else has a better explanation/definition. The special forms are documented at http://cl

Re: Why does this not work?

2009-05-01 Thread Meikel Brandmeyer
Hi, Am 01.05.2009 um 23:24 schrieb Michael Wood: I don't think it's so hard and fast. I think of it more like somefunc is the usual thing, and somefunc* is similar, but not as commonly used. Maybe someone else has a better explanation/definition. I often use driver functions for my macros.

Re: Why does this not work?

2009-05-01 Thread Meikel Brandmeyer
Hi, Am 01.05.2009 um 22:57 schrieb Santanu: So I guess these are directly written in Java. Yes. There are some special forms like def, fn, let, ., new, etc. which are written directly in Java. You can find more about special forms on the clojure site: http://clojure.org/special_forms Sinc

Re: Why does this not work?

2009-05-01 Thread Santanu
On May 2, 1:13 am, Meikel Brandmeyer wrote: > fn is a macro which expands into a call to fn* which is a special > form. It is not meant to be used directly. So, are these 'entities' that end in * something like private functions? I tried to find the definition of fn* inside the clj files in cl

Re: Has anyone on this group ever tried Forth?

2009-05-01 Thread jvt
I know this thread is kind of dead, but I could not help but point out that traditional closures have a more immediate mapping onto quotations in factor than Pinochio indicates in his post above. The factor word '[ provides a kind of intelligent quotation construction (similar to backquote in lis

Re: leveraging Clojure STM in other JVM languages?

2009-05-01 Thread Stuart Sierra
Have not tried it myself, but the (gen-class :state ...) form is supposed to help with this. -SS On May 1, 1:40 pm, Raoul Duke wrote: > hi, > > has anybody experimented with using Clojure code from e.g. Scala, to > get Clojure STM goodness in other languages? > > thanks. --~--~-~--~~

Re: Why does this not work?

2009-05-01 Thread Meikel Brandmeyer
Hi, Am 01.05.2009 um 21:57 schrieb Santanu: Oops! I forgot about macroexpand. I should have tried that first. What does the * in fn* mean? I tried (doc fn*) but got an error instead. fn is a macro which expands into a call to fn* which is a special form. It is not meant to be used directly.

Re: Why does this not work?

2009-05-01 Thread Santanu
On May 2, 12:28 am, Michael Wood wrote: > > user=> (macroexpand-1 '(#(%1 %2) 1 2)) > ((fn* [p1__1 p2__2] (p1__1 p2__2)) 1 2) Oops! I forgot about macroexpand. I should have tried that first. What does the * in fn* mean? I tried (doc fn*) but got an error instead. -Santanu --~--~-~--~--

Re: Why does this not work?

2009-05-01 Thread Santanu
On May 2, 12:27 am, CuppoJava wrote: > #(%1 %2) is equivalent to writing (fn [a b] (a b)) Ah.. I see. Thanks. -Santanu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send em

Re: Why does this not work?

2009-05-01 Thread Michael Wood
On Fri, May 1, 2009 at 9:28 PM, Michael Wood wrote: [...] > i.e. (#(%1 %2) 1 2) > > is not the same as: > ((fn [a b] a b) 1 2) > > but rather: > ((fn [a b] (a b) 1 2) Of course, I mean: ((fn [a b] (a b)) 1 2) -- Michael Wood --~--~-~--~~~---~--~~ You received

Re: Why does this not work?

2009-05-01 Thread Michael Wood
Hi On Fri, May 1, 2009 at 9:13 PM, Santanu wrote: [...] > user> ((fn [a b] a b) 1 2) > 2 [...] > user> (#(%1 %2) 1 2) > java.lang.ClassCastException: java.lang.Integer cannot be cast to > clojure.lang.IF This has come up before on the list, but the following should make it clear what is happeni

Re: Why does this not work?

2009-05-01 Thread CuppoJava
#(%1 %2) is equivalent to writing (fn [a b] (a b)) The #() macro is really designed just for single line functions. You can work around this using do. #(do %1 %2) will do what you want. -Patrick --~--~-~--~~~---~--~~ You received this message because you are su

Why does this not work?

2009-05-01 Thread Santanu
Hi Everybody, Why does this work: - user> ((fn [a b] a b) 1 2) 2 - But this doesn't: - user> (#(%1 %2) 1 2) java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IF - Regards, Santanu --~--~-~--~~~---~--~~

leveraging Clojure STM in other JVM languages?

2009-05-01 Thread Raoul Duke
hi, has anybody experimented with using Clojure code from e.g. Scala, to get Clojure STM goodness in other languages? thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

learning clojure: macro for importing all static public methods of a Java class

2009-05-01 Thread Boris Mizhen
Hello all, below is the code for an utility macro. It wraps all public static functions of a class in closure functions and imports them into the current namespace. Clojure name will be prefix-'method name'. Example: (import-static \"foo\" java.lang.Math) And yes, I saw static import from contr

Re: Does read-string ignore bindings local to forms?

2009-05-01 Thread Julien
Well thank you Christophe. I didn't know it was possible to redirect the output like this. Even got the exception working. Thank you for your expertise and your time, it works perfect, just what wanted. --~--~-~--~~~---~--~~ You received this message because you ar

Re: Got a Clojure library?

2009-05-01 Thread Drew Raines
Rich Hickey wrote: > People regularly post here about Clojure libraries they are working > on, and it is great to see the explosion of new libs for Clojure! > > I'd like to try to get a directory of Clojure libs together and up > on the Clojure site. Towards that end, I'd appreciate it, if you >

Re: Does read-string ignore bindings local to forms?

2009-05-01 Thread Christophe Grand
Rich Hickey a écrit : > That's not completely true - the reader is context-aware for syntax- > quote and :: > Thanks for the precision. -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~-~--~~~---~--~~ You received

Re: Book for Programming Clojure

2009-05-01 Thread Mibu
Mark, Thanks for the excellent article. Your Clojure page is a great resource page too. Loved the Clojure Categorized. It's similar to what Chouser started doing in the official docs. This categorizing and tagging is tremendously helpful for understanding the "vocabulary" of the language in the w

Re: Does read-string ignore bindings local to forms?

2009-05-01 Thread Rich Hickey
On May 1, 9:53 am, Christophe Grand wrote: > Julien a écrit : > > > Here is a quick newbie question. > > >(def test1 "test1") > >(let [test2 "test2"] > >(eval (read-string "(println test1)")) > >(eval (read-string "(println test2)")) > >) > > > -output > >

Re: Does read-string ignore bindings local to forms?

2009-05-01 Thread Christophe Grand
Julien a écrit : > The idea consist of making a jabber bot that would allow me to > remotely execute clojure code from a jabber account(Jabber is an > instant messaging protocol). It would be kind of a remote repl. > Been there, done that but with Rhino. > I need to access to a local binding

Re: The Path to 1.0

2009-05-01 Thread Rich Hickey
On Apr 26, 6:54 pm, Laurent PETIT wrote: > I've created issue 110 with the patch attached in clojure's google code > project. > > > Note: I strongly suggest that the clojure.version.interim property > remains true in svn, so that it's not possible to inadvertently > release a version "too earl

Re: Does read-string ignore bindings local to forms?

2009-05-01 Thread Stuart Sierra
On May 1, 9:28 am, Julien wrote: > How could (read-string "") access to a binding local to a form? > Is this possible? (let...) defines a lexical scope, which is only available to forms that are physically (lexically) inside the let. The result of read- string doesn't count as "inside", because

Re: Does read-string ignore bindings local to forms?

2009-05-01 Thread Julien
Thanks for your quick answer. On May 1, 3:53 pm, Christophe Grand wrote: > > Whate are you trying to achieve? > I'll try to clarify my problem. I'm a newcomer to clojure (enthusiast about it) and I'm working on small project to get familiar with clojure. The idea consist of making a jabber bo

Re: Does read-string ignore bindings local to forms?

2009-05-01 Thread Christophe Grand
Julien a écrit : > Here is a quick newbie question. > > (def test1 "test1") > (let [test2 "test2"] > (eval (read-string "(println test1)")) > (eval (read-string "(println test2)")) > ) > > -output > test1 > 1:1 user=> java.lang.Exception: U

Does read-string ignore bindings local to forms?

2009-05-01 Thread Julien
Here is a quick newbie question. (def test1 "test1") (let [test2 "test2"] (eval (read-string "(println test1)")) (eval (read-string "(println test2)")) ) -output test1 1:1 user=> java.lang.Exception: Unable to resolve symbol

Re: testing the reader...

2009-05-01 Thread Julien
Thanks a lot for this thorough explanation. I appreciate it. Changing \"(println text1)\" to \"(println user/text1)\" actually do the job. I had to read it several time to begin to understand but I do have a better understanding of how compilation and namespaces work now. Thank you Stephen. --~-