Re: c.c and IBM JDK?

2009-09-07 Thread Michael Reid
On Mon, Sep 7, 2009 at 5:37 AM, David Andrews wrote: > > > triddell wrote: >> This patch fixed the issue for me on the IBM JDK. > > Sadly, not for me!  (IBM 1.5.0) c/c/pprint/ColumnWriter still fails > with: >  [java] java.lang.ClassFormatError: (clojure/contrib/pprint/ > ColumnWriter) field name

Re: deadlocks and race conditions

2009-08-17 Thread Michael Reid
Hi, Ditto on the ordering example. Clojure can't infer which order your code needs to run any more than it can figure out what your code is supposed to do. On the deadlock question, it is my understanding from a prior post by Rich that Clojure's STM acquires locks in such a way that deadlocks ca

Re: (create-struct) without keys.

2009-06-24 Thread Michael Reid
On Wed, Jun 24, 2009 at 11:41 AM, Nicolas Oury wrote: > > This is useful when you write a macro that generates a structure with a > known set of fields at macro-expansion time. But sometimes this > known set of fields will be empty. > > ( Imagine a macro allowing to shortly write some kind of reco

Re: Dynamically accessing static fields

2009-06-17 Thread Michael Reid
On Mon, Jun 15, 2009 at 9:13 AM, Parth wrote: > > > > On Jun 15, 7:08 am, James Koppel wrote: >> I am trying to write a function to simplify working with GridBagConstraints >> -- that is, instead of writing >> >> (let [c (GridBagConstraints.)] >>     (set! (.weightx c) 2.0) >>     (set! (.gridwid

Re: You know you've been writing too much Clojure when...

2009-06-02 Thread Michael Reid
On Fri, May 29, 2009 at 2:51 PM, Paul Stadig wrote: > You meant to type disclosure, but instead you typed disclojure. > > Paul > How about when you try to write code in other languages, and reflexively place parentheses before function/method names? (len 'Foo') <-- not valid Python. :( /mike.

Re: STM & Resource transactions

2009-06-02 Thread Michael Reid
On Tue, Jun 2, 2009 at 8:12 AM, Robert Campbell wrote: > > I've been looking at using the clojure.set functions to create a > simple in-memory database cache. Basically when the app boost up, load > entire db into memory, work with it through the basic relational > algebra functions provided. Any

Re: macro issue

2009-05-20 Thread Michael Reid
On Wed, May 20, 2009 at 8:44 AM, pmf wrote: > > On May 20, 4:47 am, Per wrote: >> ;; The macro >> (defmacro def-fields [name tgs] >> `(defstruct ~name ~@(map #(symbol (str ":" %)) tgs)) >> ) > > If you replace the call to 'symbol' with a call to 'keyword', it works > (I think this is what you

Re: Accessing java objects from SLIME using Swank (was: Starting Swank from Java)

2009-03-18 Thread Michael Reid
On Wed, Mar 18, 2009 at 4:02 AM, Tassilo Horn wrote: > > Tassilo Horn writes: > >>> Take a look at this blog post: >>> http://avodonosov.blogspot.com/2008/12/simpler-clojureslime-embedding.html >>> >>> I think you will find it useful. >> >> Cool, but I had to modify it a bit to get it working: >

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-17 Thread Michael Reid
On Mon, Feb 16, 2009 at 12:05 PM, Perry Trolard wrote: > > I agree with the majority of posters that the breaking changes in the > service of optimal names is the right way to go. > > I found the explanation & recipe for porting at clojure.org/lazier > clear & easy to follow. I didn't do full por

Re: A pipe macro for left-to-right coll streams

2009-02-10 Thread Michael Reid
On Tue, Feb 10, 2009 at 5:02 PM, MattH wrote: > > The pipe macro is definitely not a new idea btw. It's taken from a > thread posted on another lisp group. > > Someone posted a silly inflammatory attack on lisp, contrasting unix: > "cat a b c | grep xyz | sort | uniq" > to how they'd imagine it

Re: Multi-CPU on Mac Not Exploited?

2009-01-27 Thread Michael Reid
On Tue, Jan 27, 2009 at 3:04 AM, Keith Bennett wrote: > > All - > > I tried testing the code at http://clojure.org/Refs to see what the > benefit of multicore processing would be. To my surprise, the my-pmap > function took *more* time, not less, than the map function. > > Whereas the times list

Re: Calling Clojure from Java (again)

2009-01-22 Thread Michael Reid
On Thu, Jan 22, 2009 at 4:43 PM, Peter Wolf wrote: > > This is a rejuvenation of the old "calling Java from Clojure" thread > > I have been looking at the solutions from Mark > / > 1) From a Java application, read a text file containing Clojure code > and invoke specific functions it defines

Re: is it type hint?

2009-01-19 Thread Michael Reid
On Mon, Jan 19, 2009 at 12:34 PM, Chouser wrote: > > On Mon, Jan 19, 2009 at 11:03 AM, Michael Reid wrote: >> >> (defn index-of [#^String s #^String substr] >> (.indexOf s substr)) >> >> Then the compiler will generate an optimized code path that direc

Re: fit for contribution to clojure.contrib.ns-utils?

2009-01-19 Thread Michael Reid
On Sat, Jan 17, 2009 at 8:25 PM, Dan Larkin wrote: > > > On Jan 17, 2009, at 6:29 PM, Stephen C. Gilardi wrote: >> >> Hi Dan, >> >> That's interesting. I've given it some thought and I've come to see >> it as a version of resolve that tries harder than the default. >> Here's an implementation tha

Re: repl-utils show

2009-01-19 Thread Michael Reid
On Mon, Jan 19, 2009 at 11:59 AM, Chouser wrote: > > On Sat, Jan 17, 2009 at 8:03 PM, pc wrote: >> >> This is very useful. For me it was useful to be able to limit the >> output to lines that contained a few selected letters. >> >> (show String "pper") >> === public final java.lang.String ===

Re: is it type hint?

2009-01-19 Thread Michael Reid
On Fri, Jan 16, 2009 at 9:57 PM, David Nolen wrote: > Just made sense to me today as well. > #^Class > is short form for saying set the metadata for the symbol being defined (in > this case list) to the map {:tag Class}. > #^ is a reader macro for setting metadata for the compiler. That code is

Re: Macros in interaction with Functions

2009-01-16 Thread Michael Reid
> Is there anyway to write a macro/function that acts as a function when > necessary (so it can be passed as an argument), but expands into a > macro (for speed) when deemed possible? I don't think this is possible without some sort of support for a macro/function duality in core Clojure. In the

Re: Delays and their efficiency

2009-01-14 Thread Michael Reid
On Tue, Jan 13, 2009 at 12:39 PM, samppi wrote: > > Recently, I asked how to make a function evaluate its arguments lazily > (http://groups.google.com/group/clojure/browse_thread/thread/ > cd01ef39c2b62530), and I was given a good solution: use Delay objects > (with the delay and force functions)

Re: what does -> mean?

2009-01-12 Thread Michael Reid
On Sun, Jan 11, 2009 at 9:12 PM, Mark Triggs wrote: > > I've also found this useful for accessing members in nested maps. For > example: > > (let [me {:person {:name {:first "Mark" >:last "Triggs"} > :email "mark.h.tri...@gmail.com"}}] >(-> me

Re: Some code review for clj-record?

2009-01-05 Thread Michael Reid
> I guess it comes down to what belongs in metadata. While errors are > certainly data about other data, they don't feel to me like metadata a > la :doc, :tag, :file, :line, and :test. They're the sort of thing I'd > show in an application's UI as part of normal user interactions, > rather than so

Re: clj-backtrace: more readable backtraces for Clojure

2009-01-02 Thread Michael Reid
Hi, I don't have Clojure in front of me right now to try this out, but from the looks of the README let me be the first to give you an emphatic *Thank you*. This is looking rather useful. Nice work. My one concern with this is how brittle is this with respect to Clojure's development? Have you

Re: Swank in Tomcat via JSP: classpath issues

2008-12-29 Thread Michael Reid
Doh! I just read your discussion w/ Anton on his blog. Seems you've already looked at the context classloader. *shrug*. I'm stumped. /mike. On Mon, Dec 29, 2008 at 12:46 PM, Michael Reid wrote: > Hi, > > I'm not sure how to integrate this into the Tomcat JSP sce

Re: Swank in Tomcat via JSP: classpath issues

2008-12-29 Thread Michael Reid
Hi, I'm not sure how to integrate this into the Tomcat JSP scenario, but I think the issue is that *use-context-classloader* is not set to true (it defaults to nil). Again, I'm not positive how to get your JSP to do this, but an untested stab at it would be just to wrap the call to clojure.main/

Re: trolltech QT opengl SLIME REPL mac os x

2008-12-18 Thread Michael Reid
For what its worth, I've had a similar setup working on Mac OS X 10.5: Aquamacs SLIME jogl-1.1.1 I'm pretty sure I'm running Java 1.6 (can't check now). I had no issues with hangs. Perhaps QT is the bad ingredient. /mike. On Thu, Dec 18, 2008 at 2:40 PM, chris wrote: > > I think you are abso

Re: Microsoft SQL Server and the sql contrib

2008-12-17 Thread Michael Reid
On Wed, Dec 17, 2008 at 11:00 AM, Scott Jaderholm wrote: > Thanks for the idea. Although those are definitely necessary steps, > unfortunately the problem still persists. > Can you get a similar Java program work correctly? i.e. we want to try and separate if this is specific to JDBC in Clojure

Re: Macro Style Question: Expanding to Multiple (def ...) Forms

2008-12-15 Thread Michael Reid
Hi Randall, Seems the general consensus is that there is nothing inherently bad with such a design. The idea of macros is to give you the power to generate code from commonly occurring templates. Emitting multiple def forms certainly falls under this umbrella. /mike. On Mon, Dec 15, 2008 at

Re: Math as multimethods

2008-12-08 Thread Michael Reid
I've been toying with something similar. The approach I took was to define multi-methods for the various operators: (defmulti add class) (defmulti sub class) (defmulti mul class) (defmulti div class) ... Then I of course write the implementations for various different types. Then, because the m

Re: BUG: resultset-seq breaks on duplicate column names

2008-12-08 Thread Michael Reid
Has anybody else hit this? I just did. Its not tricky to alter resultset-seq to return maps with qualified keys: (defn resultset-seq "Creates and returns a lazy sequence of structmaps corresponding to the rows in the java.sql.ResultSet rs" [#^java.sql.ResultSet rs] (let [rsmeta (. rs (g

Re: delimited continuations for web development

2008-12-04 Thread Michael Reid
> with a delimited continuation, you're capturing it from the outside, so you > don't have that problem. > Yeah I'm pretty sure its possible. I've been intrigued by this continuations based web programming trend as well. Early on when I learned of Clojure I made a very poor attempt to port cl-cont

Re: AOT/gen-class docs

2008-11-27 Thread Michael Reid
> gen-class will always create a relationship between the stub class and > the load (__init) class, as well as the namespace in which the > implementations will be found, the naming conventions for matching > etc. It's a high-level feature with a lot of power, but by no means > represents a univer

Re: Isolating I/O and other side-effects?

2008-11-24 Thread Michael Reid
> Is there anyway to assert that code does have side effects & should > never be called in a transaction? > > (dosync > (assert (not (in-transaction -> "Assert: Can't call this code in > a transaction" > > That could be useful for debug builds of IO libraries. I don't know that there's anyth

Re: Creating temporary namespaces from a function fails; why?

2008-11-21 Thread Michael Reid
Hi, I think what is going on here is that the namespace ns-a does not exist until the code is executed; however, in order execute the code it must be first compiled. It is during the compilation phase that the namespace 'ns-a' cannot be found, because indeed, it does not yet exist. I cannot thi

Re: macro/eval question

2008-11-07 Thread Michael Reid
Hi, > On Nov 7, 3:48 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote: >> The following macro in lancet defines an ant task. >> >>(defmacro define-ant-task [task-name] >> `(def ~(symbol task-name) (create-ant-task ~task-name))) >> >> (At least) one of the following assumptions is wrong: >>

Re: Bug in genclass?

2008-11-06 Thread Michael Reid
+(str mname "$void"))) I am not 100% sure this doesn't haven't any other effects within the genclass code, but I did a test and it seems to be behave properly. /mike. On Thu, Nov 6, 2008 at 1:12 PM, Michael Reid <[EMAIL PROTECTED]> wrote: > Hi, > > I am

Bug in genclass?

2008-11-06 Thread Michael Reid
Hi, I am getting the following error trying to extend java.lang.Exception in the latest revision of Clojure: user=>(defmacro defexception [name] `(try (gen-and-load-class (quote ~name) :extends Exception) (catch java.lang.LinkageError le# (. le# (printStackTrace) user=> (

Re: Clojure Poll 09/2008

2008-09-10 Thread Michael Reid
Hi, On Wed, Sep 10, 2008 at 2:40 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > What are you doing with Clojure? > Currently I'm working on writing extensions to JSF (JavaServer Faces) that allow seamless use from Clojure. One offshoot of this is to experiment with a browser-based Clojure IDE. >

Nested (defn)

2008-09-10 Thread Michael Reid
Hi folks, There was a thread a little while back (http://groups.google.com/group/clojure/browse_thread/thread/8c4bea21298693ca) about implementing true data hiding by nesting defns under a let, e.g.: (let [hidden-ref (ref 10)] (defn get-secret [] @hidden-ref)) This was mentioned to be bad st

Re: Exception while setting namespace from Java

2008-09-04 Thread Michael Reid
Hi, On Thu, Sep 4, 2008 at 6:19 AM, Josip Gracin <[EMAIL PROTECTED]> wrote: > Thanks, Mike! Works perfectly! (btw, only on Java 1.5 and not on 1.6. > On 1.6 there's a problem with arguments to RT.map) Care to share? I've been using Clojure on OpenJDK 1.6.0 for some time without trouble. This in

Re: clojure/ns and gen-and-save-class

2008-09-03 Thread Michael Reid
Hi, > Good point. It seems that :use would suffice except if both of the following > are true for a particular namespace: > - it's defined outside of a lib, > - it's reasonable to want to refer to it. > > I'm not aware of any uses of namespaces that meet both of those criteria. > Does anyone else

Re: Exception while setting namespace from Java

2008-09-03 Thread Michael Reid
Hi Josip, Have a look in jvm/clojure/lang/Repl.java which demonstrates creating and entering the 'user namespace. The key is that you need to wrap the call to in-ns in Var.pushThreadBindings(IPersistentMap) / Var.popThreadBindings(). This is analogous to: (binding [*ns* *ns*] ;; bind a thread-

Re: Local recursive lazy sequences

2008-09-01 Thread Michael Reid
Hi Achim, On Sun, Aug 31, 2008 at 1:58 PM, Achim Passen <[EMAIL PROTECTED]> wrote: > Now suppose you want to define a function which returns the nth > fibonacci number, but you down want "fibs" around globally. My guess > was: > >(defn fib [n] > (let [fibs2 (lazy-cat '(0 1) (map

Re: lib integrated into clojure namespace

2008-08-28 Thread Michael Reid
Hi, May I be the first to say: Thanks Steve and Rich! This is a great addition and really helps tie up the loose ends in the stuff I am currently working on--I didn't want to reimplement anything that I knew was coming into the language. Cheers, /mike. --~--~-~--~~~

Re: executing shell command

2008-08-25 Thread Michael Reid
Hi Parth, On 8/25/08, Parth Malwankar <[EMAIL PROTECTED]> wrote: > > I want to run a shell command through Clojure > so I tried the following which doesn't work: > By "doesn't work" do you mean that you don't see any output from the processes? First thing to understand is that processes creat