Re: ANN: clojure.contrib.error-kit

2009-02-08 Thread David Nolen
So far this is fantastic! And I haven't even got around to playing with the restart mechanism :) I'm using it in Spinoza to provide contextual errors (malformed slot list, missing base class etc.). I notice the contrib libraries in general are very good at throwing exceptions so that consumers

Re: Generic functions: things, models, and protocols revisited

2009-02-12 Thread David Nolen
project might meet up soon? Or am I totally wrong? On Thu, Feb 12, 2009 at 12:02 PM, mikel mev...@mac.com wrote: David Nolen and I were recently discussing CLOS and method dispatch. I implemented such a scheme for my own use. This post is an FYI for David and anyone else who might

Re: Newbie at macros: Manipulating a vector of bindings

2009-02-14 Thread David Nolen
You can pretty much call anything outside of the quote, in fact all runtime information is available (you have access to anything that was previously read). The main thing to understand is that all parameters passed to your macro are unevaluated. On Sat, Feb 14, 2009 at 10:45 AM, samppi

Re: Newbie: Separating and grouping the elements in a bunch of vectors

2009-02-15 Thread David Nolen
(map (fn [ rest] (apply vector rest)) [1 2 3] ['a 'b 'c] [cat dog bird]) On Sun, Feb 15, 2009 at 7:16 PM, samppi rbysam...@gmail.com wrote: What would I do if I wanted this: [[a0 a1 a2] [b0 b1 b2] ...] - [[a0 b0 ...] [a1 b1 ...] [a2 b2 ...]] I could write a loop, I guess, but is there a

Re: Newbie: Separating and grouping the elements in a bunch of vectors

2009-02-15 Thread David Nolen
Actually something closer to your exact expression is this: (apply (partial map (fn [ rest] (apply vector rest))) [[1 2 3] ['a 'b 'c] [cat dog bird]]) On Sun, Feb 15, 2009 at 7:42 PM, David Nolen dnolen.li...@gmail.com wrote: (map (fn [ rest] (apply vector rest)) [1 2 3] ['a 'b 'c] [cat dog

Re: ANN: clojure.contrib.error-kit

2009-02-15 Thread David Nolen
Would it be possible to make the arguments to handle be optional? Is this a good or bad idea? It seems to me, in the case of setting up test fixtures that check for raised errors, often you don't care what arguments the error takes. David On Fri, Feb 6, 2009 at 9:10 PM, Chouser

Re: Newbie: Separating and grouping the elements in a bunch of vectors

2009-02-15 Thread David Nolen
I'm sure it can be done, but it's not clear to me if you have a vector of vectors how Stuart's solution would work: 1:15 user= (map vector vecs) ([[:a0 :a1 :a2]] [[:b0 :b1 :b2]]) (apply (partial map vector) [[1 2 3] ['a 'b 'c] [cat dog bird]]) works on a vector of vectors. The OP wanted a

Re: error-kit + test-is

2009-02-15 Thread David Nolen
:height]))) Much nicer than those ugly Java Exceptions, no? ;) On a last note, I've found your qualify-sym fn quite handy and have been using it elsewhere ;) On Sun, Feb 15, 2009 at 11:52 PM, Chouser chou...@gmail.com wrote: On Sun, Feb 15, 2009 at 10:06 PM, David Nolen dnolen.li...@gmail.com

Re: error-kit + test-is

2009-02-15 Thread David Nolen
Heh not macro, I meant multimethod. Here is the macro that seems to work, any improvements much appreciated ;) This fails when no error is raised, when the wrong error type is raised, and I believe it's captures errors which are derived but not the exact error (is this a weird behavior?).

Re: error-kit + test-is

2009-02-15 Thread David Nolen
I don't quite understand why you got through all that work to get error-str -- isn't it just (str (qualify-sym error-type))? ...and since you then use it only as an arg to 'symbol' or 'str', you could just use the symbol itself instead of converting it to a string and back. If I bring the

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-16 Thread David Nolen
butlast, doall, dorun, doseq, dosync, dotimes, doto, fnseq, gensym, macroexpand, macroexpand-1, mapcat, nthrest -1 Because they are similar to other Lisps I assume. The same reason for println vs print-line. Changing these are a bad idea in IMHO. Breaking the meaning of rest with Common

Re: compiling a GUI app and also: interference of Java's built-in architechture

2009-02-16 Thread David Nolen
On Mon, Feb 16, 2009 at 10:27 AM, rob levy r.p.l...@gmail.com wrote: So if I am right about these two facts, it seems like Clojure should include a native way of making applets/applications that both enables the truly functional style that Clojure is built on, and doesn't require writing Java

Re: error-kit + test-is

2009-02-16 Thread David Nolen
(defmethod assert-expr 'raised? [msg [_ error-type body :as form]] (let [error-name (qualify-sym error-type)] `(with-handler (do ~...@body (report :fail ~msg '~form ~(str error-name not raised.))) (handle ~error-type {:as err#} (report :pass ~msg '~form

Re: Idiomatic Way to Write the Following:

2009-02-17 Thread David Nolen
Is using subvec for something like this a bad idea? On Wed, Feb 18, 2009 at 12:38 AM, CuppoJava patrickli_2...@hotmail.comwrote: Hi, I'm wondering if there's a terser more idiomatic way to write the following. I want to get a new vector with the specified indexes removed. I found myself

Re: Performance of (fn [] ...)?

2009-02-17 Thread David Nolen
new MBP 2.53ghz (defn create-fn [] (fn [] (println hi))) (time (dotimes [x 4000] (create-fn))) Elapsed time: 1034.409 msecs Hopefully you don't need 40,000,000 functions in less than a second ;) On Wed, Feb 18, 2009 at 1:16 AM, CuppoJava patrickli_2...@hotmail.comwrote: (defn

Re: Idiomatic Way to Write the Following:

2009-02-17 Thread David Nolen
My point was that you could use subvec to do vector splicing and build your remove function off of that. I'm sure the more experienced Clojurians can chime in on what is the most idiomatic form. On Wed, Feb 18, 2009 at 1:10 AM, CuppoJava patrickli_2...@hotmail.comwrote: Mmm, subvec doesn't

Re: how to learn clojure ?

2009-02-18 Thread David Nolen
Practical Common Lisp is also online and free. Though there are significant differences between the two languages many of the strange and beautiful concepts that Clojure embraces are covered there. Especially dynamic variables, macros, destructuring bind, and multiple dispatch. On Wed, Feb 18,

Re: bug affecting clojure.core/bean?

2009-02-18 Thread David Nolen
If I've been following things correct: rest _used_ to force the seq, it does no longer. next forces the seq In my own mind i'm thinking next to mean (return the seq with the next value computed), rest now means just give me the uncomputed remaining values of the seq. On Wed, Feb 18, 2009 at

Re: how to learn clojure ?

2009-02-19 Thread David Nolen
Of course I beg to differ. The Stuart Halloway's book is fantastic of course, I have it myself. It's absolutely required reading. Stuart does his best to describe the ins and outs of the language while giving a crash course on the Lisp philosophy. And yes Clojure is syntactically different

Re: how to learn clojure ?

2009-02-19 Thread David Nolen
No offense here to Lispers but when I learn a new language, I try to learn it as it is and I make parallels and connections with what I know at the moment. Otherwise you end up learning more than one thing at the same time and it can get quite confusing. If your experience is made mostly

Re: how to learn clojure ?

2009-02-19 Thread David Nolen
Great list. On Thu, Feb 19, 2009 at 11:39 AM, Stuart Halloway stuart.hallo...@gmail.com wrote: Thanks for the kind words, David. I hope many people will like Programming Clojure and find it useful. Clojure has a *ton* of goodness in it. I think many of the chapters in Programming Clojure

Re: Error Handling paradigms in Clojure

2009-02-19 Thread David Nolen
Check out Chouser's error-kit in clojure-contrib. It borrows from the condition/restart system of Common Lisp. On Thu, Feb 19, 2009 at 5:25 PM, levand luke.vanderh...@gmail.com wrote: So, my project is reaching a sufficient level of complexity where I really need good error tracking - when

Re: structmap instance test

2009-02-21 Thread David Nolen
This not hard to implement. This exactly what Spinoza does. Feel free to lift any of my code. On Sat, Feb 21, 2009 at 9:08 AM, Mark Volkmann r.mark.volkm...@gmail.comwrote: Is there a way to test whether a given object is an instance of a given structmap? For example, (defstruct dog-struct

Re: structmap instance test

2009-02-21 Thread David Nolen
For example, with Spinoza: (def my-circle (make-instance circle)) (instance-of? my-circle circle) ; true circle is just a struct. On Sat, Feb 21, 2009 at 2:09 PM, David Nolen dnolen.li...@gmail.com wrote: This not hard to implement. This exactly what Spinoza does. Feel free to lift any

Re: generic functions update

2009-02-21 Thread David Nolen
I'm interested as well. On Sat, Feb 21, 2009 at 3:03 PM, Dan Larkin d...@danlarkin.org wrote: On Feb 21, 2009, at 2:23 PM, mikel wrote: If there's interest in having models and generic functions in contrib, I'll get a contributor agreement to Rich. Aye there is, from me at least.

Re: Clojure Naming Conventions

2009-02-21 Thread David Nolen
+name+ is also in line with Common Lisp patterns http://www.cliki.net/Naming%20conventions On Sat, Feb 21, 2009 at 4:07 PM, Luc Prefontaine lprefonta...@softaddicts.ca wrote: In our software, we use uppercase or +name+ as constant names. Both Java and RUBY use uppercase, I think it's more a

Re: Clojure Naming Conventions

2009-02-21 Thread David Nolen
The fact that the Clojure data structures are immutable and that some of those data structures might be used logically constants are two separate concerns. When reading Clojure code, we've already internalized the fact that the data structures are immutable. Using a naming convention for a

Re: dotimes suggestion

2009-02-21 Thread David Nolen
(defmacro again [n body] `(dotimes [~'_ ~n] ~...@body)) (again 3 (println Ho)) On Sat, Feb 21, 2009 at 5:51 PM, samppi rbysam...@gmail.com wrote: For now, I do: (dotimes [_ 3] (print Ho)) But I also think it would be a nice, natural addition. On Feb 21, 3:07 pm, Timothy Pratley

Re: arguments to dissoc and select-keys

2009-02-21 Thread David Nolen
dissoc is like assoc. If you want to use collections with dissoc you can always use apply. It's not too much to type: (def my-map {:first Bob, :middle Joe, :last Smith}) (apply dissoc my-map [:first :middle]) On Sat, Feb 21, 2009 at 5:58 PM, samppi rbysam...@gmail.com wrote: Allowing dissoc

Re: arguments to dissoc and select-keys

2009-02-21 Thread David Nolen
want? On Sat, Feb 21, 2009 at 6:24 PM, Mark Volkmann r.mark.volkm...@gmail.comwrote: On Sat, Feb 21, 2009 at 5:07 PM, David Nolen dnolen.li...@gmail.com wrote: dissoc is like assoc. If you want to use collections with dissoc you can always use apply. It's not too much to type: (def my

Re: arguments to dissoc and select-keys

2009-02-21 Thread David Nolen
On Feb 21, 5:58 pm, samppi rbysam...@gmail.com wrote: Allowing dissoc and select-keys to accept both keys as arguments and as a collection would be nice, and backwards compatible. Nope - Collections can be keys. Ah the power of Clojure ;) The fact that (almost?) anything can be a key is

Re: Clojure Naming Conventions

2009-02-21 Thread David Nolen
Thanks for the points. What I was thinking, was that for things like π, in Clojure (as in CL), perhaps it makes to sense to mark it like so: +pi+ On Sat, Feb 21, 2009 at 8:59 PM, Chouser chou...@gmail.com wrote: On Sat, Feb 21, 2009 at 5:36 PM, David Nolen dnolen.li...@gmail.com wrote: My

Re: dotimes suggestion

2009-02-22 Thread David Nolen
In general, I find that multiple arguments types for a function confusing. If dotimes is going to take multiple types it should be a multifn. That seems to imply a performance hit. I think Clojure wisely does not (or rarely does not?) allow for multiple types to be passed into a function. On top

Re: dotimes suggestion

2009-02-22 Thread David Nolen
, David Nolen dnolen.li...@gmail.com wrote: In general, I find that multiple arguments types for a function confusing. If dotimes is going to take multiple types it should be a multifn. That seems to imply a performance hit. I think Clojure wisely does not (or rarely does not?) allow

Re: alternate syntax

2009-02-23 Thread David Nolen
Interesting thread on LtU on this subject: http://lambda-the-ultimate.org/node/1646 On Mon, Feb 23, 2009 at 10:42 AM, Mark Volkmann r.mark.volkm...@gmail.comwrote: I have an idea I'd like to float to see if there are reasons why it's a bad idea. What if Clojure had an alternate surface

Clojure Slime, how to jump to a def/defn?

2009-02-23 Thread David Nolen
Is this supported yet? M-. is supposed to handle this, but I get an error when I try. 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

Re: Operating on multidimensional primitive arrays without reflection?

2009-02-23 Thread David Nolen
(time (let [arr (make-array Float/TYPE 1 1)] (dotimes [_ 10] (let [#^floats sub-arr (aget arr 0)] (aset-float sub-arr 0 0.0) Seems to work? Looks an eligible candidate for a macro. On Mon, Feb 23, 2009 at 9:04 PM, Jason Wolfe jawo...@berkeley.edu wrote: I'm trying to call some

Re: Clojure Slime, how to jump to a def/defn?

2009-02-23 Thread David Nolen
You're right, works perfectly on clojure sources, but not the instances you've described. It would be great if this would work again. I don't understand swank/slime well enough to try it myself. On Mon, Feb 23, 2009 at 9:23 PM, Alec Berryman a...@thened.net wrote: David Nolen on 2009-02-23 16

Re: Algebraic data types in clojure.contrib

2009-02-25 Thread David Nolen
1) User-friendly printing. I implement the multimethods print-method and print-dup for my classes, which allows me to specify how objects are printed. print- method and print-dup dispatch on class, so my types need to be classes or at least derive from a class that is distinct from the

Re: Multimethods in other namespaces

2009-02-25 Thread David Nolen
That should work fine as far as I can tell. On Wed, Feb 25, 2009 at 3:36 PM, Jeffrey Straszheim straszheimjeff...@gmail.com wrote: If in namespace one I define (defmulti fred dispatch-fred) and have imported that ns into another, can I just do (defmethod fred ::val [x] ), or

Re: Algebraic data types in clojure.contrib

2009-02-25 Thread David Nolen
25, 12:19 pm, Konrad Hinsen konrad.hin...@laposte.net wrote: On Feb 25, 2009, at 17:40, David Nolen wrote: Should print and println be multimethods? It seems the ability to custom print a data structure would be generally useful. It's already there, just not documented as far as I know

Re: Mathy operations on non-numerics

2009-02-27 Thread David Nolen
What about something like: (defn gt [str1 str2] (first (sort [str1 str2]))) (gt Zoe Bob) ; - Bob On Fri, Feb 27, 2009 at 12:03 PM, Phil Hagelberg p...@hagelb.org wrote: Christian Vest Hansen karmazi...@gmail.com writes: Are you referring to using , , =, with objects that implement

Re: Laziness madness

2009-03-01 Thread David Nolen
Remember that you can force lazy sequences if you need to as you are with doseq with doall (retains head) and dorun (does not) as well. You probably want (dorun (map #(add-watch % watcher callback-fn) all-agents)) I think it's pretty clear here what's going on. Your code needs side-effects. In

Re: Question on names of errors in error-kit

2009-03-03 Thread David Nolen
I appreciate that they stand out. Again, this is similar to the constants conversation earlier, visually marking the intended use is a good habit, IMHO. Of course this doesn't mean that error-kit should define the base error this way, but I intend to keep on wrapping my errors in earmuffs :)

Re: Question on names of errors in error-kit

2009-03-03 Thread David Nolen
capitals seems pretty weird for a Lisp. Now that I think about it, perhaps foo-error isn't so bad. David On Tue, Mar 3, 2009 at 10:54 PM, Chouser chou...@gmail.com wrote: On Tue, Mar 3, 2009 at 10:36 PM, David Nolen dnolen.li...@gmail.com wrote: I appreciate that they stand out. Again

Re: hash-map based on identity

2009-03-07 Thread David Nolen
Depending on what you are doing perhaps you could use (hash x). This might not be very helpful if you need to update keys frequently. However if you're mostly doing lookups, then this would help quite a bit. On Sat, Mar 7, 2009 at 3:44 PM, Mark Engelberg mark.engelb...@gmail.comwrote: Here's

Re: On the importance of recognizing and using maps

2009-03-08 Thread David Nolen
Structs are maps with shared keys and positional constructors as Rich mentions in the original post. I think Rich is saying that maps should indeed be abused ;) By building all higher level structures on top of them, consumers are guaranteed not only your custom functionality, but all the

Re: macros

2009-03-10 Thread David Nolen
It does. Also Practical Common Lisp and On Lisp cover this in depth as well, though you'll need to convert commas into tildes as well as use ~' for each level of backquote depth that you don't want Clojure to namespace free symbols. On Tue, Mar 10, 2009 at 6:05 PM, .Bill Smith

Re: macros

2009-03-10 Thread David Nolen
Practical Common Lisp and On Lisp are available online and free. On Tue, Mar 10, 2009 at 6:16 PM, David Nolen dnolen.li...@gmail.com wrote: It does. Also Practical Common Lisp and On Lisp cover this in depth as well, though you'll need to convert commas into tildes as well as use ~' for each

Re: Question about throwing errors

2009-03-11 Thread David Nolen
Doesn't error-kit do this? On Wed, Mar 11, 2009 at 10:15 PM, Mark Engelberg mark.engelb...@gmail.comwrote: I'm thinking about implementing a backtracking mechanism that throws errors as a way to escape out of the current computation and try another possibility. I'd want to create a specific

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
Amazing stuff. In particular this finally makes debugging macros sane. For those of you that are using swank-clojure you only need to make minor modifications to swank-clojure to pretty-print your macro expansions to the macro expansion buffer. Even better you can move the cursor to subform

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
So that people can copy and paste the change in basic.clj (defn- apply-macro-expander [expander string] (binding [*print-suppress-namespaces* true] (let [astr (with-out-str (with-pprint-dispatch *code-dispatch* (pprint (expander (read-from-string string)] (subs astr 0 (dec

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
I suppose the following is more idiomatic: (defn- apply-macro-expander [expander string] (let [astr (with-out-str (binding [*print-suppress-namespaces* true] (with-pprint-dispatch *code-dispatch* (pprint (expander (read-from-string string))] (subs astr 0 (dec (count

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
* true] (with-pprint-dispatch *code-dispatch* (write (expander (read-from-string string)) :pretty true :stream nil Completely untested! :-) Tom On Mar 12, 11:07 am, David Nolen dnolen.li...@gmail.com wrote: I suppose the following is more idiomatic: (defn- apply-macro

Re: swank-clojure: swank-clojure-init-files not used

2009-03-16 Thread David Nolen
On Mon, Mar 16, 2009 at 3:42 AM, Tassilo Horn tass...@member.fsf.orgwrote: When adding ~/.clojure/ to `swank-clojure-extra-classpaths' and starting SLIME, htop shows that this directory is not in the -cp java option. Sending a SIGINT kills the clojure process and doesn't interrupt the

Re: Symbols evaluated at compile time?

2009-03-16 Thread David Nolen
This has come up before. You can actually work around this (search the mailing list for declare) I think that when not hacking against the REPL that the default behavior is a good one. Having to use declare bugged me a little at first, but I now consider it a very minor annoyance compared to the

Re: Symbols evaluated at compile time?

2009-03-16 Thread David Nolen
in another thread about declare and someone had hacked the reader to not bail immediately on undefined symbols). In CL, if you have definitions out of order in the compiler will issue warnings. I'm not saying it's an easy change... Paul On Mon, Mar 16, 2009 at 3:45 PM, David Nolen dnolen.li

Re: Clojure Web Framework, what I want to add

2009-03-16 Thread David Nolen
I'm mostly a front-end UI person with crazy amounts of JS experience so most of my input will be from that stand point. 1. I agree with Sean on this one. No need to bring in middleware that can't be expressed in 10X-20X less code in pure Clojure. 2. The framework should allow for any backend

Re: Can Clojure simulate Class?Lisp can do it!

2009-03-19 Thread David Nolen
Doesn't On Lisp talk about simulating CLOS with closures? It's free online. I would like to add as the creator that I would not use Spinoza yet ;) And I've put it on hold as I'm currently obsessed with trying to port cl-cont. Spinoza still needs quite a bit of work, I started on that before a

ANN: Delimited Continuations for Clojure

2009-03-19 Thread David Nolen
You can get it here: http://github.com/swannodette/clj-cont/tree/master So over the past week I've been porting cl-cont ( http://common-lisp.net/project/cl-cont/) originally written by Slava Akhmechet to Clojure. I've now ported most of the functionality that's translatable from Common Lisp

Re: New release 20090320

2009-03-20 Thread David Nolen
Congrats! It's been said many a time, but it bears being said again, Clojure makes hacking fun again. It's great working with a language that is very production ready, yet still evolving at a quick clip. It's also fascinating that a language supports so many different usage patterns- the

Help with the dot operator special form

2009-03-21 Thread David Nolen
I'm wondering if it's possible to create a Clojure function that does what the dot operator does. It seems like this would be possible with definline but I'm unable to get this to work or figure it out. For example I want to be able write something like the following: (dot Hello world (list

Re: Help with the dot operator special form

2009-03-21 Thread David Nolen
On Sat, Mar 21, 2009 at 9:10 PM, Kevin Downey redc...@gmail.com wrote: you want defmacro not definline. the result of a macro is a data structure. that data structure is then evaluated in place of the call to the macro. definline (I think?) behaves similar to a function, so if it returns a

Re: Help with the dot operator special form

2009-03-21 Thread David Nolen
Or rather I did not express that requirement clearly enough. On Sat, Mar 21, 2009 at 9:21 PM, David Nolen dnolen.li...@gmail.com wrote: On Sat, Mar 21, 2009 at 9:10 PM, Kevin Downey redc...@gmail.com wrote: you want defmacro not definline. the result of a macro is a data structure

Re: Help with the dot operator special form

2009-03-22 Thread David Nolen
Thanks all for the pointers, this looks like a workable approach. In my case I'm not bothered by the performance hit from reflection (CPS transformation creates an obscene number of anonymous functions anyway). However I am running into an issue. Here's my dot function: (def not-seq? (comp not

Re: Help with the dot operator special form

2009-03-22 Thread David Nolen
That was it! At one point I knew these things. Thanks much. On Sun, Mar 22, 2009 at 2:18 PM, Eric Tschetter eched...@gmail.com wrote: (let [myref (ref {})] (dot clojure.lang.LockingTransaction (list 'runInTransaction (fn [] (commute myref assoc :mykey :myval) I'm getting a

Re: Help with the dot operator special form

2009-03-22 Thread David Nolen
on reflection you can't expect this code to be super performant. That may or may matter depending on your use case ;) On Sun, Mar 22, 2009 at 5:28 PM, David Nolen dnolen.li...@gmail.com wrote: That was it! At one point I knew these things. Thanks much. On Sun, Mar 22, 2009 at 2:18 PM, Eric Tschetter

Re: Information Hiding

2009-03-23 Thread David Nolen
You could always build something where setters/getters are auto-magically created if specified by the constructor macro. And with clojure.contrib.def you could auto-magically generate private setters/getters. On Mon, Mar 23, 2009 at 4:27 AM, Mark Engelberg mark.engelb...@gmail.comwrote: I've

Re: Slime errors with clojure_20090320

2009-03-23 Thread David Nolen
You need to make sure all the different moving parts are based on the newest version of Clojure as well. This includes swank-clojure, clojure-mode, and any other libs you might be using. On Mon, Mar 23, 2009 at 9:51 AM, Dan Pomohaci dan.pomoh...@gmail.comwrote: Hi, When I start slime with

Re: Problem with CLASSPATH

2009-03-24 Thread David Nolen
The latest version of Clojure incorporated lazy sequences which broke many libraries early on. Most of these problems have been worked out. In my experience you should use the cutting edge version of everything including SLIME. I clone everything from GitHub (clojure, clojure-contrib,

Re: Suggestion for Java Clojure code, use of checkstyle or code formatter

2009-03-24 Thread David Nolen
Javadoc would be nice, but I do note that Rich's Java code is pretty darn clear ;) I also note the indentation style is similar to Whitesmith's according to Wikipedia http://en.wikipedia.org/wiki/Indent_style. I've always preferred the BSD curly brace level matching convention over the KR

Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread David Nolen
For what it's worth I'm a big fan of the wishful thinking programming style. I write some functions how I think they should look, declare the functions I haven't defined yet. Then I implement the lower level functions, write some tests- then usually the higher level stuff works without too much

Re: oo

2009-03-28 Thread David Nolen
On Sat, Mar 28, 2009 at 4:40 PM, mikel mev...@mac.com wrote: So, at minimum, to make a solid port, you need to add a function that can return a sensible type value for any input Enjoying the thread. Out of curiosity for which Clojure values is the return value of the type function undefined?

Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)

2009-03-28 Thread David Nolen
Having thought a little about multiple inheritance when implementing Spinoza I also ran into this problem. However at the time I wasn't hindered by multifn dispatch as much as the fact that parents cannot be ordered (because calling parents on a tag returns a set) as pointed out by Mark. I

Re: new in contrib.test-is: fixtures

2009-03-28 Thread David Nolen
very cool :) On 3/28/09, Stuart Sierra the.stuart.sie...@gmail.com wrote: Hi folks, I finally came up with fixtures for clojure.contrib.test-is. Now you can do before/after setup for each test case. Here's the documentation, let me know what you think. -Stuart Sierra ;; FIXTURES

Re: oo

2009-03-29 Thread David Nolen
On Sun, Mar 29, 2009 at 1:25 AM, mikel mev...@mac.com wrote: (type (proxy [clojure.lang.IMeta clojure.lang.IRef][])) java.lang.UnsupportedOperationException: meta (NO_SOURCE_FILE:0) [Thrown class clojure.lang.Compiler$CompilerException] No doubt someone is going to point out that the

Re: What's a convenient way of calling super.method()?

2009-03-29 Thread David Nolen
Glad to be of help. To be totally honest I hadn't really tested it too much, so I don't know ;) One obvious limitation here is that it doesn't work with multiple inheritance (it only looks at the first item in the parents set). As long you're sticking with a Java-style single inheritance model

Re: Please suggest a way to learn just enough Java for Clojure

2009-03-30 Thread David Nolen
There's a few posts on the mailing list suggesting some good starting points. You can get far in Clojure without resorting to Java but it definitely helps to know some if you really want to advance your knowledge of Clojure's inner workings as well as get it to interoperate with Java libraries.

Re: I need help tracking down a performance problem.

2009-03-31 Thread David Nolen
Did you try using aset-int instead of aset? On Tue, Mar 31, 2009 at 8:25 AM, Vincent Foley vfo...@gmail.com wrote: For those interested, I managed to improve the performance of my original program from 2 minutes 40 seconds to decode 1000+ files down to 2 minutes. I'm still far from my goal,

Re: I need help tracking down a performance problem.

2009-03-31 Thread David Nolen
defense I did not know such a function existed :) I'll give it a whirl and report back! On Mar 31, 9:57 am, David Nolen dnolen.li...@gmail.com wrote: Did you try using aset-int instead of aset? On Tue, Mar 31, 2009 at 8:25 AM, Vincent Foley vfo...@gmail.com wrote: For those

Re: I need help tracking down a performance problem.

2009-03-31 Thread David Nolen
Other VM operations 0.0% 1 Class loader 0.0% 2 Unknown code 176.257 secs On Mar 31, 8:57 pm, David Nolen dnolen.li...@gmail.com wrote: Thanks to cl-format: (fn [buf__2572__auto__ len__2573__auto__] (if (= len__2573__auto__ 1

Re: I need help tracking down a performance problem.

2009-03-31 Thread David Nolen
Foley vfo...@gmail.com wrote: I tried it just now; it made no difference. Nevertheless, thank you for you help and time! On Mar 31, 9:38 pm, David Nolen dnolen.li...@gmail.com wrote: Did you try (int (mask8 (. buf__2572__auto__ (get ? Your macro should like this: (defmacro

Re: - vs. comp

2009-03-31 Thread David Nolen
comp creates a new function that you can store. - threads a value through a series of expressions. On Wed, Apr 1, 2009 at 12:52 AM, kkw kevin.k@gmail.com wrote: Hi folks, I have some code where I wanted to: - take a list of stuff (which includes another list inside) - use

Re: Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)

2009-04-01 Thread David Nolen
Very cool. On Wed, Apr 1, 2009 at 8:47 AM, Rich Hickey richhic...@gmail.com wrote: I've added get-method (SVN 1338). (derive ::Circle ::Shape) (derive ::Rect ::Shape) (defmulti area :Shape) ;note - you can name methods (defmethod area ::Shape area-shape [x] nil) (get-method area

Re: Array of primitives

2009-04-02 Thread David Nolen
you should look into float-array and friends. On Fri, Apr 3, 2009 at 12:04 AM, Sean francoisdev...@gmail.com wrote: I'm working with AWT, and there is a method that requires a float[] (The java.awt.BasicStroke constructor). Is it possible to directly create an array of primitives directly

Re: Simple dosync/alter question

2009-04-06 Thread David Nolen
I think what you want is: (def foo (ref 0)) (defn square [x] (* x x)) (defn square-ref [x] (dosync (ref-set foo (square x (square-ref 2) On Mon, Apr 6, 2009 at 3:02 PM, bgray graybran...@gmail.com wrote: I have a some what (I believe) easy question. Could someone let me know what I'm

Re: A large Clojure deployment

2009-04-07 Thread David Nolen
Congrats! Perhaps soon there should be a Projects Using Clojure section on the main site? Good way to get the word out that people are using Clojure in the real world David On Tue, Apr 7, 2009 at 10:47 AM, Sean francoisdev...@gmail.com wrote: Okay wow... it'll take some time to fully

Re: Clojure on Google AppEngine

2009-04-07 Thread David Nolen
Very exciting, thanks for the excellent and informative writeup. On Wed, Apr 8, 2009 at 12:41 AM, John D. Hume duelin.mark...@gmail.comwrote: As predicted, Google has now released Java support for AppEngine. I was lucky enough to get an early look, which I dedicated entirely to Clojure.

Re: Enlive questions

2009-04-10 Thread David Nolen
This is great. I had thought that supporting some kind of partial template thing would be interesting, but that's actually just my poor logic at work ;) It seems like with the new version of Enlive I could do something like this: (deftemplate pageA-template path [] [[:div (attr?

Re: Enlive questions

2009-04-10 Thread David Nolen
Real quick thought: (deftemplate-generator template-generator [args] rule-vector transform-fn) Would produce a template generator. (def template-name (template-generator path-to-xml-or-file-or-xml-string)) Would produce a real template. (apply str (template-name arg1 arg2 arg3))

Re: Amb operator

2009-04-13 Thread David Nolen
Using try-catch for control flow is probably not a good idea. Shameless plug, do you think you could get this to work with clj-cont? clj-cont is a port I did of cl-cont. It has some limitations, but because Clojure has so few special forms (compared to Common Lisp), it has the chance to achieve

Re: Amb operator

2009-04-13 Thread David Nolen
anything else. However, with some quick testing I note that using Exceptions for flow control might be even 2x slower than clj-cont. On Mon, Apr 13, 2009 at 1:54 PM, David Nolen dnolen.li...@gmail.com wrote: Using try-catch for control flow is probably not a good idea. Shameless plug, do you

Re: Amb operator

2009-04-13 Thread David Nolen
throwing away the away stack trace making debugging more difficult? It got me thinking about arbitrary flow control, on the nested loop thread I've added my findings... On Mon, Apr 13, 2009 at 4:24 PM, Victor Rodriguez vict...@gmail.com wrote: On Mon, Apr 13, 2009 at 2:13 PM, David Nolen dnolen.li

Re: Nested loops

2009-04-13 Thread David Nolen
Out of simple curiosity I wondered how hard it would be to implement flow control using proxy. I know Rich isn't hot on non-structured programming, but there may be times where this might be useful: (ns flow.return-from (:import (flow IReturnFrom))) (defn create-return-from [value] (proxy

Re: Javascript generator

2009-04-13 Thread David Nolen
Do you have any plans for continuing to support this? If so are you against putting this on GitHub or Google Code so that people can follow it's development? Thanks for contributing it to the community. On Wed, Feb 25, 2009 at 7:49 PM, jim jim.d...@gmail.com wrote: I've just uploaded a

Re: Javascript generator

2009-04-13 Thread David Nolen
at 1:19 AM, David Nolen dnolen.li...@gmail.com wrote: Do you have any plans for continuing to support this? If so are you against putting this on GitHub or Google Code so that people can follow it's development? Thanks for contributing it to the community. On Wed, Feb 25, 2009 at 7:49 PM, jim

Re: Javascript generator

2009-04-14 Thread David Nolen
Cool! Rather then waiting, you could host it in the interim on GitHub or Google Code so people like myself can submit patches (which I'm more than willing to do) ;) Just a thought... A couple of things: (println (javascript (var x))) I would expect this to convert to: var x; It does not.

Re: Javascript generator

2009-04-14 Thread David Nolen
Cool! Rather then waiting, you could host it in the interim on GitHub or Google Code so people like myself can submit patches (which I'm more than willing to do) ;) Just a thought... A couple of things: (println (javascript (var x))) I would expect this to convert to: var x; It does not.

Re: [Discuss] Contribs with dependencies

2009-04-14 Thread David Nolen
Joda Time, Colt, Fork/Join seem like projects that truly add something to Clojure. These are projects which solve problems that developers have come to expect from their respective language. Joda Time - sane date/time (really useful when building web services). Colt - enough people want to do

Re: [Discuss] Contribs with dependencies

2009-04-14 Thread David Nolen
again (writing matrix math Clojure apps on top of Clojure vectors...) On Tue, Apr 14, 2009 at 11:01 AM, David Nolen dnolen.li...@gmail.comwrote: Joda Time, Colt, Fork/Join seem like projects that truly add something to Clojure. These are projects which solve problems that developers have come

  1   2   3   4   5   6   7   8   9   10   >