Re: Language similarities

2010-01-01 Thread mbrodersen
Paul Graham might be correct that main stream languages will incorporate features that Lisp had many years ago but the result won't be Lisp. -- 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

Re: Language similarities

2010-01-01 Thread mbrodersen
Everything looks the same if you use a loose enough equality function I guess. Using a loose enough equality function, you can argue that Clojure is just Lisp running on top of a mutable, Object Oriented framework (the JVM). Immutable data structures and controlled changes of immutable values is n

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-14 Thread mbrodersen
abuse of macro, where regular functions would do the job very > well ? > > 2009/12/13 mbrodersen > > > There is nothing "wrong" about objects in Clojure as long as the > > objects are immutable. > > > Some people tend to think that "functional" i

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread mbrodersen
Cleaned it up a bit: (defmacro ? [object value] "Get an object value - same as object.value; in C# but immutable" `(get ~object (keyword (str '~value (defmacro ! [object method & args] "Call an object method - same as object.method(args); in C# but immutable" `

Re: Mapping OOPS concepts to Clojure? Doable or Wrong thinking?

2009-12-12 Thread mbrodersen
There is nothing "wrong" about objects in Clojure as long as the objects are immutable. Some people tend to think that "functional" is anti-"object oriented". That is IMHO the wrong way to think. They complement each other. Why limit the tools in your toolbox? F# (for example) shows how it can be

Re: roll call of production use?

2009-11-23 Thread mbrodersen
I use an internal DSL (Domain Specific Language) in Clojure to generate C++ and C# code. Cheers Morten On Nov 24, 10:00 am, 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 > interes

Re: Understanding Clojure Closures

2009-11-11 Thread mbrodersen
(using alter-var-root!) at any time. The Var > remains the same but the contents of the Var are changed. > > Because of how Clojure is structured, the Var object need only be > resolved from the symbol once (in the generated Java bytecode, the Var > appears as a static final field).

Re: Understanding Clojure Closures

2009-11-11 Thread mbrodersen
Great answer Alex. Thanks! Morten On Nov 12, 12:34 am, Alex Osborne wrote: > mbrodersen wrote: > > In this simple recursive expression: > > > (def t (fn [x] (if (zero? x) 0 (+ x (t (dec x)) > > > The fn special form is evaluated within a context where t is not yet

Understanding Clojure Closures

2009-11-11 Thread mbrodersen
A quick question about how closures work in Clojure. In this simple recursive expression: (def t (fn [x] (if (zero? x) 0 (+ x (t (dec x)) The fn special form is evaluated within a context where t is not yet bound. t is only bound AFTER fn has captured its environment. In other words, the c

(into) improvement

2009-11-03 Thread mbrodersen
Currently (into) takes 2 parameters (destination and source): (into [] [1 2]) => [1 2] but not more than 2: (into [] [1 2] [3 4]) => Wrong number of args... It would be nice to have (into) work for more parameters: (into [] [1 2] [3 4] [5 6 7]) => [1 2 3 4 5 6 7] --~--~-~--~~

(info) improvement?

2009-11-03 Thread mbrodersen
Currently (into) takes 2 parameters (destination and source) (into [] [1 2]) => [1 2] but not more than 2: (into [] [1 2] [3 4]) => Wrong number of args... It would be nice to have (into) work for more parameters: (into [] [1 2] [3 4]) => [1 2 3 4] --~--~-~--~~~--

Re: Dedicated thread for agent or creating thread pool for agent?

2009-10-19 Thread mbrodersen
Good point about the thread pools. I would have preferred to do it in a more platform neutral way but yep that looks like a good solution :-) Thanks Christophe! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cloju

Re: Printing to *out* in another thread

2009-10-18 Thread mbrodersen
> Using atoms is not a good idea. Unless you don't mind if the same > message is sometimes printed more than once. Atoms are implemented > using spin locks with automatic retry. Hmmm...unless add-watch => observer is called only once. So I might be wrong :-) Interesting. Anybody knows more abou

Re: Printing to *out* in another thread

2009-10-18 Thread mbrodersen
Using atoms is not a good idea. Unless you don't mind if the same message is sometimes printed more than once. Atoms are implemented using spin locks with automatic retry. Cheers Morten --~--~-~--~~~---~--~~ You received this message because you are subscribed to

Re: Dedicated thread for agent or creating thread pool for agent?

2009-10-18 Thread mbrodersen
> SWT's equivalent to Swing's SwingUtilities.invokeLater is > Display.asyncExec; the equivalent of SwingUtilities.invokeAndWait is > Display.syncExec (all four take a Runnable as an argument). Thanks pmf! That at least solves the immediate problem. --~--~-~--~~~---~--

Re: Printing to *out* in another thread

2009-10-17 Thread mbrodersen
Hmmm...it works with the normal Clojure REPL. So it must be an Emacs thingy. --~--~-~--~~~---~--~~ 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 post

Re: Dedicated thread for agent or creating thread pool for agent?

2009-10-17 Thread mbrodersen
I don't know SWT well enough to answer that. I am new to the JVM platform (after 20+ years of writing native C++ code). However, the question is not SWT specific. There will be other cases (for example OpenGL) where something like InvokeLater doesn't exist. Cheers Morten --~--~-~--~

Dedicated thread for agent or creating thread pool for agent?

2009-10-17 Thread mbrodersen
Hi all, Is there a way to ensure that only one dedicated thread is used for an agent? The same question was asked some time ago but I don't think it was resolved. My specific problem is that SWT throws an exception if I use different threads to call it even though I am using an agent to avoid r

Re: let-while

2009-10-17 Thread mbrodersen
It would be great to have while-let in contrib. Then I don't have to maintain let-while myself :-) Morten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Printing to *out* in another thread

2009-10-17 Thread mbrodersen
If you want to print to stdout from multiple threads without getting the printing garbeled you can do something like the following (it also logs all printed values): (def wa-debug-agent) (defn wa-debug-make [] (def wa-debug-agent (agent []))) (defn wa-debug-print "This makes it

Re: let-while

2009-10-17 Thread mbrodersen
That's a nice improvement Christophe. Exactly the kind of answer I was looking for. Thanks! Morten --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googleg

Re: let-while

2009-10-17 Thread mbrodersen
> I don't think the multiple evaluation matters in this case, since it's > the name parameter, which will in all sane cases be a simple symbol. > gensyms are needed when multiple evaluation could cause side-effects > or an expensive function to be computed multiple times, which is not > the case h

Re: let-while

2009-10-17 Thread mbrodersen
I think I understand what you are trying to do John but it doesn't have the same semantics though. If you use the first definition, the following expression: (let-while [x (if (> (rand) 0.2) "Yep!" nil)] (println x) (println (str x will work correctly (it will print "Yep!" and "Yep!Yep!" ze

Re: Clojure is two!

2009-10-16 Thread mbrodersen
Congratulations everybody. Clojure is the answer. On Oct 17, 3:12 am, Rich Hickey wrote: > http://clojure.blogspot.com/2009/10/clojure-is-two.html > > Thanks again to all! > > Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

let-while

2009-10-16 Thread mbrodersen
Hi, I am new to Clojure and I am wondering if there is anything similar to the following macro already built in: (defmacro let-while "Makes it easy to continue processing an expression as long as it is true" [[name expr] & forms] `(loop [] (let [~name ~exp

Re: Runtime exception when agent calls sort

2009-01-19 Thread mbrodersen
Thanks Steve. The code is called by another function that handles the agent state so no it is not called directly. Here is the additional code (it is a simple Newbie web server learning project): Here is how the web server is run: (ws-run 3000 wh-handler) The web server:

Runtime exception when agent calls sort

2009-01-18 Thread mbrodersen
Hi The following agent code works fine: (defn html-write-cmd [out cmd] (doseq [key (keys cmd)] (.write out (format "\"%s\" => \"%s\"" key (cmd key) but if I change (keys cmd) to (sort (keys cmd)) then the following runtime exception is trigger

Re: Newbie problem

2009-01-17 Thread mbrodersen
Yes that does indeed fix the problem :-) Thanks Shawn! Cheers Morten --~--~-~--~~~---~--~~ 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 To unsubscribe fro

Newbie problem

2009-01-17 Thread mbrodersen
Hi I am having fun learning Clojure but have a problem with the following code. If you run the code with the ;OK removed then it works. If you run the code with ;ERROR removed then it doesn't. The code is my own implementation of splitting a string into individual words (just a learning exercise