Re: Simple question using Agents.

2008-12-28 Thread Stephen C. Gilardi
On Dec 28, 2008, at 9:58 AM, Mark Volkmann wrote: Are you sure the code below works? It doesn't work for me with the revision 1185. For me it outputs: #Agent clojure.lang.ag...@355a47 0 and stops. A change to Clojure's behavior at r1158 caused my incorrect (or at least iffy) code break

Re: Proxying in clojure

2008-12-24 Thread Stephen C. Gilardi
On Dec 24, 2008, at 8:11 AM, Chouser wrote: On Wed, Dec 24, 2008 at 1:44 AM, Stephen C. Gilardi squee...@mac.com wrote: Based on Chouser's version, but using atoms, a splash of color, a little more destructuring and more separation of model and view. Would you be willing to explain why

Re: 12 Days of Christmas in idiomatic(?) clojure

2008-12-24 Thread Stephen C. Gilardi
On Dec 24, 2008, at 1:57 PM, MattyDub wrote: (Originally, I didn't know about the 2-argument version of range, so I was using map and an anonymous inline function to add 1 to each result from range, like: (map #(sum-up-to (inc %)) (range 12)) Then I thought This can't be right, there has to

Re: Non-numeric characters clarification

2008-12-24 Thread Stephen C. Gilardi
Numeric characters are the digits 0 through 9. Are you seeing some behavior that suggests otherwise? Symbols can begin with + or - . --Steve On Dec 24, 2008, at 7:23 PM, Abhishek Reddy arbs...@gmail.com wrote: Hi, http://clojure.org/reader says symbols begin with a non-numeric

Re: Simple question using Agents.

2008-12-23 Thread Stephen C. Gilardi
On Dec 23, 2008, at 1:03 PM, CuppoJava wrote: (send-off my_agent #( ... )) But I need the agent's state to be updated within send-off. How do I go about doing that? The new value for the agent will be the return value from the update function. Something like: user= (def my-agent (agent

Re: Simple question using Agents.

2008-12-23 Thread Stephen C. Gilardi
On Dec 23, 2008, at 3:40 PM, CuppoJava wrote: I'm a little confused about the (send-off *agent* update) line though. So as I understand it, *agent* is identical to my-agent, while running inside update. Is that correct? That is correct. Only one agent can be running on a thread at a given

Re: Proxying in clojure

2008-12-23 Thread Stephen C. Gilardi
On Dec 23, 2008, at 5:19 PM, MattyDub wrote: On the Java Interop page (http://clojure.org/java_interop), the proxy macro is described as creating ...a instance of a proxy class that implements the named class/interface(s) Is this done using Java Dynamic Proxy Classes

Re: Proxying in clojure

2008-12-23 Thread Stephen C. Gilardi
Based on Chouser's version, but using atoms, a splash of color, a little more destructuring and more separation of model and view. Very cool demo, Abhishek, thanks. --Steve (import '(java.awt Color) '(javax.swing JPanel JFrame Timer) '(java.awt.event KeyEvent ActionListener

Re: ns references clarification

2008-12-22 Thread Stephen C. Gilardi
On Dec 22, 2008, at 1:42 PM, Brian Doyle wrote: It would appear that using (:import ...) and (import ...) with the ns function work the same (svn rev 1172.) 1:1 user= (ns blah (import (java.net URL))) nil 1:2 blah= (URL. http://www.clojure.org;) #URL http://www.clojure.org and 1:1 user=

Re: Newbie: Creating a character from a Unicode sequence

2008-12-22 Thread Stephen C. Gilardi
On Dec 23, 2008, at 1:03 AM, samppi wrote: Is there a way to turn this: [\3 \5 \A \3] ...into this? \u35A3 Here's one way: user= (#(char (Integer/parseInt (apply str %) 16)) [\3 \5 \A \3]) \㖣 user= --Steve smime.p7s Description: S/MIME cryptographic signature

Re: Newbie: Creating a character from a Unicode sequence

2008-12-22 Thread Stephen C. Gilardi
On Dec 23, 2008, at 1:53 AM, Emeka wrote: What is '16' doing there? Emeka It the optional radix argument to parseInt, specifying that the characters being parsed should be interpreted as hexadecimal digits.

(Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Stephen C. Gilardi
The enclosed updated patch: unified-main-2.patch addresses all defects I am aware of in its predecessor. On Dec 17, 2008, at 6:10 PM, Stephen C. Gilardi wrote: On Dec 17, 2008, at 2:27 PM, Rich Hickey wrote: In what way is that the right thing to do? The idea was that the sequence

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Stephen C. Gilardi
...@gmail.com wrote: Steve, Your version of repl_ln.clj works for me: 1:1 user= (+ 1 2) 3 1:2 user= (throw (Exception. test)) java.lang.Exception: test (repl-1:2) Thanks again, - Mark On Sun, Dec 21, 2008 at 3:47 PM, Stephen C. Gilardi squee...@mac.com wrote: Hi Mark, Thanks for your work

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Stephen C. Gilardi
On Dec 21, 2008, at 4:40 PM, Rich Hickey wrote: If main doesn't match the behavior of Repl and Script in this area when run in repl or script modes respectively, it needs to. Repl calls exit, Script does not. OK, I'll fix that. --Steve smime.p7s Description: S/MIME cryptographic

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Stephen C. Gilardi
On Dec 21, 2008, at 4:43 PM, Stephen C. Gilardi wrote: On Dec 21, 2008, at 4:40 PM, Rich Hickey wrote: If main doesn't match the behavior of Repl and Script in this area when run in repl or script modes respectively, it needs to. Repl calls exit, Script does not. OK, I'll fix

Re: Curiosity: why doesn't (count (doall (range 1000000000))) exhaust memory?

2008-12-21 Thread Stephen C. Gilardi
On Dec 21, 2008, at 6:44 PM, Jason wrote: Why doesn't (count (doall (range 100))) cause an out-of memory error? doall says it causes the entire seq to reside in memory at one time, yet: (range n) produces an object that is a seq, not just one that's seq- able. Its rest operation is

Re: How to encapsulate local state in closures

2008-12-21 Thread Stephen C. Gilardi
On Dec 21, 2008, at 7:24 PM, Brian Doyle wrote: I haven't been following the new atom stuff, so I was wondering why atom would be best in this situation, vs a ref? Thanks. The implementation of atoms is supported by the JVM typically using a processor hardware instruction that

Re: Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-17 Thread Stephen C. Gilardi
On Dec 17, 2008, at 2:27 PM, Rich Hickey wrote: Thanks! You're welcome! Wow, that's a lot of changes. I'm not sure about this one: - Exceptions caught by the repl now cause the rest of the input line to be skipped. In what way is that the right thing to do? The idea was that the

Re: code golf

2008-12-17 Thread Stephen C. Gilardi
On Dec 17, 2008, at 8:09 PM, Chouser wrote: But I can't deny that golfing is fun! Yes it is! (defn enc[s e](apply str(map(into{}(for[[o _ n](partition 3 4 e)][o n]))s))) Nice job as usual, Chouser! Here's my stroke--now shown to have landed well into the rough: (defn enc[p t](let[a

Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-16 Thread Stephen C. Gilardi
The enclosed patch updates clojure.main to fix a bug and implement changes discussed here recently. Details below. Feedback welcome. --Steve [1] clojure.main no longer calls gen-class. Instead there is now a stub clojure.main class written in Java so it is always available with Clojure's

Re: creating new sequences

2008-12-16 Thread Stephen C. Gilardi
On Dec 16, 2008, at 6:29 PM, Mark Volkmann wrote: If I create a new sequence by adding data to an existing one, does Clojure allow the two sequences to share data as opposed to copying the original sequence? For example, (def coll1 [1 2]) (def coll2 (cons 3 coll1)) Does coll2 share the data

Re: creating new sequences

2008-12-16 Thread Stephen C. Gilardi
On Dec 16, 2008, at 6:35 PM, Stephen C. Gilardi wrote: It shares the data--which is safe because of immutability and efficient because Rich designed and implemented Clojure's persistent data structures carefully and well. But Mark was talking about sequences, not persistent data

Re: Best Choice of Java Class For *out*

2008-12-15 Thread Stephen C. Gilardi
On Dec 15, 2008, at 6:08 PM, Randall R Schulz wrote: user= (class *err*) java.io.PrintWriter PrintWriter is (as far as I can determine) the more modern of the two classes that are accepted as an argument to Throwable.printStackTrace which is used frequently in Clojure's implementation.

Re: Bug in read-line?

2008-12-13 Thread Stephen C. Gilardi
I'm looking at the terminal case. It's the difference between running clojure.lang.Repl and clojure.main (which runs a repl by default). The reading done by the latter is intended to be identical to the reading done by the former but isn't in the case of read-line. If anyone sees the fix

Re: why can't I set! stuff in user.clj?

2008-12-12 Thread Stephen C. Gilardi
I think clojure.lang.Repl should translate its args to the new format and call clojure.main/-main: old: clojure.lang.Repl file1 file2 -- a b c new: clojure.main -i file1 -i file2 -r a b c Similarly for clojure.lang.Script: old: clojure.lang.Script file1 file2 file3 -- a b c new:

Re: why can't I set! stuff in user.clj?

2008-12-12 Thread Stephen C. Gilardi
On Dec 12, 2008, at 11:08 AM, Rich Hickey richhic...@gmail.com wrote: On Fri, Dec 12, 2008 at 11:03 AM, Stephen C. Gilardi squee...@mac.com wrote: I think clojure.lang.Repl should translate its args to the new format and call clojure.main/-main: old: clojure.lang.Repl file1 file2

Retired: clojure.contrib.pred and clojure.contrib.memoize

2008-12-11 Thread Stephen C. Gilardi
I removed the pred and memoize libs from clojure.contrib today. The most useful functions formerly in pred and the only function in memoize are now defined in clojure.core. --Steve smime.p7s Description: S/MIME cryptographic signature

Re: why can't I set! stuff in user.clj?

2008-12-11 Thread Stephen C. Gilardi
On Dec 11, 2008, at 7:24 PM, Rich Hickey wrote: I am interested in the issues you are trying to address, and thanks for volunteering! Excellent. You're welcome. I'd like to try to focus our efforts on release 1.0. Sounds good. Towards that end, it would be nice if your repl code got

Re: re-seq and other functions

2008-12-11 Thread Stephen C. Gilardi
In the latter case the result is a seq containing a single element: the vector. There is nothing to sort/it us sorted. --Steve On Dec 12, 2008, at 12:14 AM, Oscar Picasso oscarpica...@gmail.com wrote: user (sort (re-seq #\w+ the quick brown fox)) (brown fox quick the) but user (sort

Re: why can't I set! stuff in user.clj?

2008-12-10 Thread Stephen C. Gilardi
On Dec 10, 2008, at 8:51 AM, Stuart Halloway wrote: Thanks for the info. Is this limitation of user.clj arbitrary, or motivated by some concern that the average Clojure user should know about? Is the a reason not to load the bindings first? Does user.clj (in current form) do more harm than

Re: why can't I set! stuff in user.clj?

2008-12-10 Thread Stephen C. Gilardi
On Dec 10, 2008, at 1:50 PM, Stephen C. Gilardi wrote: - I think init.clj and repl-init.clj would be good additions to what we have now. I'll be happy to write the code if it's welcome. Alternatively, we could make those hooks be functions that one can (optionally) define in user.clj

Re: Not understanding the proper use of map

2008-12-10 Thread Stephen C. Gilardi
On Dec 10, 2008, at 3:00 PM, Michael Wood wrote: The problem seems to be that you are quoting the +. Not sure why this is, but: user= ('+ 1 4) 4 ('+ 1 4) is effectively (get 1 '+ 4) (doc get) - clojure.core/get ([map key] [map key not-found]) Returns the value

Re: Learning Clojure

2008-12-10 Thread Stephen C. Gilardi
On Dec 10, 2008, at 9:03 PM, Brian Will wrote: btw, you'll see a few notes I left in the text in square brackets where I wasn't sure on some point. If someone could address those questions, I'd appreciate it. [hmm, what are the chances of a false positive due to hash collision? are the

Re: throw-if with no exception class

2008-12-10 Thread Stephen C. Gilardi
On Dec 10, 2008, at 4:38 AM, Ralf Bensmann wrote: Being a Java trainer for a long time, we talk with students about the handle-or-declare rule in Java and the two types of exceptions: checked (declared) and unchecked (runtime). So I prefer using a RuntimeException because no exception was

Re: java built in HTTP server, proxy and HttpHandler interface

2008-12-09 Thread Stephen C. Gilardi
On Dec 9, 2008, at 7:30 AM, prhlava wrote: The (. java.lang.System/err println something) works from in handler (it looks that *out* gets re-directed)... It may be that *out* gets redirected. Another difference between out and err is that System/err is often associated with an autoflush

Re: why can't I set! stuff in user.clj?

2008-12-09 Thread Stephen C. Gilardi
user.clj is loaded before thread-local bindings are established. I see you're using Repl.java. You can see the call to pushThreadBindings there to see how it works. user.clj allows you to set up the user namespace, but not set! most vars. With the repl in clojure.main, you can include an

Re: why can't I set! stuff in user.clj?

2008-12-09 Thread Stephen C. Gilardi
On Dec 9, 2008, at 6:13 PM, Brian Doyle wrote: Could you post your bash shell script that starts Clojure? I would like to see what you have concerning the new options that can be passed to the updated clojure.jar. Thanks. Here it is: #!/bin/bash set -o errexit

Re: why can't I set! stuff in user.clj?

2008-12-09 Thread Stephen C. Gilardi
On Dec 9, 2008, at 6:13 PM, Brian Doyle wrote: Could you post your bash shell script that starts Clojure? I would like to see what you have concerning the new options that can be passed to the updated clojure.jar. Thanks. [Reposting with a change and a correction:

Re: Java vararg functions called from Clojure

2008-12-08 Thread Stephen C. Gilardi
On Dec 8, 2008, at 1:34 PM, Tom Emerson wrote: I just wanted to make sure I wasn't missing something. Perhaps something along the lines of (defn format-string [fmt args] (String/format fmt (to-array args))) Hi Tom, Good call on it being a convenient function to have around. It's

Re: Java vararg functions called from Clojure

2008-12-08 Thread Stephen C. Gilardi
On Dec 8, 2008, at 2:05 PM, Randall R Schulz wrote: Correct me if I'm wrong or insufficiently aware of the relevant issues, but is it not the case that such a helper function has an easier job for Format since it wants an array of Object. In other contexts, you have to know what the type of

Re: Running out of memory when using filter?

2008-12-08 Thread Stephen C. Gilardi
On Dec 8, 2008, at 7:45 PM, Mark Engelberg wrote: I have an idea to try, but I'm not set up to build the java sources on my computer, so maybe someone else can run with it: This looked very promising to me. For one thing, I remembered that the root of the big chain of LazyCons objects in

Re: Running out of memory when using filter?

2008-12-08 Thread Stephen C. Gilardi
On Dec 8, 2008, at 8:40 PM, Stephen C. Gilardi wrote: This looked very promising to me. For one thing, I remembered that the root of the big chain of LazyCons objects in memory (as displayed by the YourKit profiler) was f. Now it's r and is listed as a stack local. --Steve smime.p7s

Re: Running out of memory when using filter?

2008-12-08 Thread Stephen C. Gilardi
I think I finally see the problem. The rest expression in filter's call to lazy-cons has a reference to coll in it. That's all it takes for coll to be retained during the entire calculation of the rest. (defn filter Returns a lazy seq of the items in coll for which (pred item) returns

Re: Elegant but very slow

2008-12-07 Thread Stephen C. Gilardi
On Dec 7, 2008, at 10:11 AM, Peter Wolf wrote: Shouldn't the number of processors on the test machine make a big difference to how fast it runs? Whereas, the Java version is only dependent on the clock rate of the individual processors. Replacing the map call with pmap on a 2 core machine

Patch available: correction to line numbers in some exceptions thrown when loading

2008-12-07 Thread Stephen C. Gilardi
Clojure sometimes throws exceptions that report a line number of 0 when loading a file. This patch changes Compiler.java so the exceptions report the correct line number. Here's an example: A test directory containing two libs: % ls test a.clj b.clj test.a requires

Re: Patch available: correction to line numbers in some exceptions thrown when loading

2008-12-07 Thread Stephen C. Gilardi
On Dec 7, 2008, at 3:13 PM, Michael Wood wrote: With or without your patch I still get no line numbers for some things at the REPL. e.g. if I try to evaluate a non-existent symbol: $ java -cp clojure.jar clojure.main Clojure user= blah java.lang.Exception: Unable to resolve symbol: blah in

Re: Running out of memory when using filter?

2008-12-06 Thread Stephen C. Gilardi
On Dec 6, 2008, at 6:21 PM, Paul Mooser wrote: (defn splode [index-path] (with-local-vars [doc-count 0] (doseq [document (filter my-filter-pred (document-seq index- path))] (var-set doc-count (inc @doc-count))) 'done)) The fn in question is likely the one in the macro expansion

Re: Running out of memory when using filter?

2008-12-06 Thread Stephen C. Gilardi
On Dec 6, 2008, at 8:28 PM, Paul Mooser wrote: That's a good idea, Steve - I didn't totally understand the code you included, but I do always forget that clojure has destructuring in its binding forms, so I rewrote it like this, which I believe should be fine (correct me if I am wrong):

Re: Running out of memory when using filter?

2008-12-06 Thread Stephen C. Gilardi
This also fails: (defn splode [n] (doseq [document (filter #(= % 20) (map inc (range n)))])) Looking at the heap dump, I see that the first item for which the filter returns true is the root of the chain of lazy cons's that's being kept. The filter is constructing a lazy-cons from the

Re: Running out of memory when using filter?

2008-12-06 Thread Stephen C. Gilardi
On Dec 6, 2008, at 9:48 PM, Paul Mooser wrote: I also saw your subsequent example which uses a different anonymous function which does NOT blow up, and that's very interesting. I'm not sure why this would be, but it seems that filter ends up holding on to the collection its filtering

Re: Running out of memory when using filter?

2008-12-06 Thread Stephen C. Gilardi
On Dec 6, 2008, at 10:27 PM, Paul Mooser wrote: I think I understand. The lazy-cons that filter is constructing maintains a reference to the whole coll in its tail so that it can evaluate (rest coll) when it is forced. Hmmm! In the current implementation of filter, coll is held the entire

Re: Running out of memory when using filter?

2008-12-06 Thread Stephen C. Gilardi
On Dec 6, 2008, at 10:43 PM, Stephen C. Gilardi wrote: The following separation into two functions appears to solve it. I'll be looking at simplifying it. Well it doesn't run out of memory, but it's not an implementation of filter either... ah well. --Steve smime.p7s Description: S

Re: Running out of memory when using filter?

2008-12-06 Thread Stephen C. Gilardi
On Dec 6, 2008, at 10:52 PM, Mark Engelberg wrote: Except your version of filter doesn't do any filtering on the rest in the case where the first satisfies the predicate. Right. It's looking to me now like this may have to be solved in Java. I don't see how to write this in Clojure without

Re: Test wether something is an atom (as it is known in Scheme)

2008-12-05 Thread Stephen C. Gilardi
On Dec 5, 2008, at 8:50 AM, Mark McGranaghan wrote: This is indeed the definition used in the clojure.contrib.pred library: http://github.com/kevinoneill/clojure-contrib/tree/master/src/clojure/contrib/pred.clj#L45 That's true. However, with Clojure now having a specific meaning for

Re: unsupported binding form for cond-let

2008-12-05 Thread Stephen C. Gilardi
On Dec 5, 2008, at 1:33 PM, Brian Doyle wrote: I started to play with cond-let in the contrib.cond package and got an unexpected error: user= (cond-let [x (zero? 0)] (println hello world)) java.lang.Exception: Unsupported binding form: (zero? 0) (NO_SOURCE_FILE:11) I updated cond-let

Re: PATCH: fixed issue in doPrepared

2008-12-04 Thread Stephen C. Gilardi
Hi Tom, Thanks for the report. I had made an accidental checkin at svn258. I've reverted to code identical to svn257 which I believe is correct. Please give it a try. --Steve On Dec 4, 2008, at 2:08 PM, Tom Emerson [EMAIL PROTECTED] wrote: Here is a patch that appears to fix the issue I

clojure.contrib.repl-ln available

2008-12-03 Thread Stephen C. Gilardi
I was just about to do that, Randall. :-) clojure.contrib.repl-ln is a repl that supports lines and line numbers. Here's a session that demonstrates it. --Steve % java -cp clojure.jar:clojure-contrib.jar clojure.main -e (use 'clojure.contrib.repl-ln) -e (repl) 1:1 user= ;

Re: clojure.contrib.repl-ln available

2008-12-03 Thread Stephen C. Gilardi
On Dec 3, 2008, at 10:06 AM, Randall R Schulz wrote: Thanks. That looks pretty cool. Do I understand from your example that if I just hit return I get another prompt? I've been meaning to ask for that. Thanks and yes, that's right. I'm curious how it interacts with rlwrap in general? I

Re: Classpath issue using new main method from jar?

2008-12-03 Thread Stephen C. Gilardi
On Dec 3, 2008, at 10:14 AM, Craig McDaniel wrote: Hmm... I must have missed that. The comment in build.xml regarding how to start Clojure should probably be changed to use clojure.main instead of -jar clojure.jar. Yes it should be changed. This command: java -cp clojure.jar

Re: Classpath issue using new main method from jar?

2008-12-03 Thread Stephen C. Gilardi
On Dec 3, 2008, at 10:48 AM, Stephen C. Gilardi wrote: but java -jar is almost never the right way to launch Clojure. More correctly put: java -jar is almost never the right way to launch clojure.jar --Steve --~--~-~--~~~---~--~~ You received this message

Re: clojure.contrib.repl-ln available

2008-12-03 Thread Stephen C. Gilardi
On Dec 3, 2008, at 9:32 AM, Drew Olson wrote: Would it make sense to add a :gen-class declaration and have the - main function automatically call the repl function? This would make launching the repl less painful for new-comers. - Drew It is a good idea and I'll work on it. What I do at

Re: clojure.contrib.repl-ln available

2008-12-03 Thread Stephen C. Gilardi
On Dec 3, 2008, at 1:12 PM, Meikel Brandmeyer wrote: I tried to trace down, what happens before we enter the Repl. The only points I noticed were setting the namespace to user and setting the command-line-args. I wrote a simple main to do this. Patch attached. To be started with

Re: For Comprehension and println (Noob Question)

2008-12-03 Thread Stephen C. Gilardi
On Dec 3, 2008, at 7:19 PM, aria42 wrote: Hi all, When I run the following from the REPL, I see the result of the println (defn read-docs [duc-dir] (for [file (.listFiles (java.io.File. duc-dir)) :when (.isFile file)] (do (println file) (.getName

Re: Unary Application of (= ...)

2008-12-03 Thread Stephen C. Gilardi
On Dec 3, 2008, at 9:15 PM, Randall R Schulz wrote: By the way, I do understand while (or) is false and (and) is true, but I don't see why = allows a single argument. I don't know the answer, but I do see it making sense as the final value in this sequence: (= 1 1 1 ...) (= 1 1 1) (= 1

Re: Unary Application of (= ...)

2008-12-03 Thread Stephen C. Gilardi
On Dec 3, 2008, at 9:39 PM, Randall R Schulz wrote: OK, so it's consistent with the null-ary (and) (no argument is false) and (or) (there is a true argument). But from that perspective, shouldn't the definition extend to the null-ary case, too? I think not. How would you decide the values

Re: Unary Application of (= ...)

2008-12-03 Thread Stephen C. Gilardi
On Dec 3, 2008, at 9:58 PM, Randall R Schulz wrote: But it is also the case that subtraction and division _do_ have identity elements. They follow directly from the application of the inverse operation to the corresponding operator's identity element. In other words, the identity element

Re: (doc)strings after param in defn

2008-12-03 Thread Stephen C. Gilardi
On Dec 4, 2008, at 12:57 AM, Mon Key wrote: I'm sure I'm missing something Maybe I should re address the issue in a different way; outside of `meta' what other way is there to do a *visual* check/comparison to test if two otherwise identical and/or nearly identical symbols contain

Re: Reader Anomaly?

2008-11-29 Thread Stephen C. Gilardi
On Nov 29, 2008, at 9:30 AM, Randall R Schulz wrote: Is it a reader bug? (That the second apostrophe appeared to be ignored.) It wasn't ignored. It quoted the string. I've been interested in a way to see what the reader returns for things like this in the past. It turns out we can get

Re: Reader Anomaly?

2008-11-29 Thread Stephen C. Gilardi
On Nov 29, 2008, at 9:55 AM, Randall R Schulz wrote: In this case, it's no different than just printing the list you passed to macroexpand: user= '(interpose '.' The quick brown fox) (interpose (quote .) (quote The quick brown fox)) It's a good technique, though, to see what the compiler

Re: Macroexpand As A Tool For Understanding [was: Re: Reader Anomaly?]

2008-11-29 Thread Stephen C. Gilardi
On Nov 29, 2008, at 10:29 AM, Randall R Schulz wrote: I'm somewhat confused by this, but I gather it has something to do with take being lazy? The last note in the doc for macroexpand explains it: user= (doc macroexpand) - clojure.core/macroexpand ([form])

Re: Exception on the formatted print method calls

2008-11-29 Thread Stephen C. Gilardi
On Nov 29, 2008, at 10:48 AM, ppierre wrote: But I can't compile core.clj when I put get-locale and with-locale inside it. What error do you get? - *locale* (should be set!-able as well), A set-locale function ? No, I meant that if *locale* becomes part of Clojure at some

Re: Exception on the formatted print method calls

2008-11-28 Thread Stephen C. Gilardi
On Nov 28, 2008, at 7:22 PM, ppierre wrote: More complete : (def *locale* nil) (binding [clojure.core/format (fn [fmt args] (String/format (or *locale* (java.util.Locale/getDefault)) [...] (with-out *err* (with-locale fr

Re: trampoline for mutual recursion

2008-11-27 Thread Stephen C. Gilardi
On Nov 27, 2008, at 5:21 AM, Robert Pfeiffer wrote: If you want to return sets, keywords, maps, or everything that implements the fn interface this is also an issue. Does trampolining on keywords make sense? The svn revision that introduced trampoline also introduced a marker interface fn

Re: trampoline for mutual recursion

2008-11-27 Thread Stephen C. Gilardi
On Nov 27, 2008, at 7:13 AM, Stephen C. Gilardi wrote: interface fn that distinguishes The interface is clojure.lang.Fn. --Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post

Re: ANT script/task for AOT compiling of clojure files?

2008-11-27 Thread Stephen C. Gilardi
On Nov 27, 2008, at 7:41 AM, Stefan Bodewig wrote: Looks pretty easy and it would probably take me longer to sign and send the CA than to put together an antlib.xml file 8-) If anybody is interested, let me know. I'm interested in making common developer tasks as easy as possible to

Re: ANT script/task for AOT compiling of clojure files?

2008-11-27 Thread Stephen C. Gilardi
Very cool Stefan, thanks! I'm planning to write a clojure.compile/main in Clojure along the lines of what you came up with. I think the current Compile.java is sufficient for bootstrapping clojure.jar--with the finally fix you recommend. Thanks, --Steve On Nov 27, 2008, at 11:29 AM,

Re: Newbie: Why does .length work on strings but not .isEmpty ?

2008-11-27 Thread Stephen C. Gilardi
On Nov 27, 2008, at 11:37 PM, samppi wrote: user= (.length ) 0 user= (.isEmpty ) java.lang.IllegalArgumentException: No matching field found: isEmpty for class java.lang.String (NO_SOURCE_FILE:0) Why does .length, but not .isEmpty, work on Strings? You're making method calls in the

Re: trampoline for mutual recursion

2008-11-26 Thread Stephen C. Gilardi
On Nov 26, 2008, at 3:22 PM, Mark Volkmann wrote: I entered this in a REPL. (def myClosure #(prn Hello)) How can I execute the closure in myClosure now? Clojure user= (def myClosure #(prn Hello)) #'user/myClosure user= (myClosure) Hello nil user= --Steve

Re: trampoline for mutual recursion

2008-11-26 Thread Stephen C. Gilardi
On Nov 26, 2008, at 4:32 PM, lpetit wrote: I've maybe missed something, but will this work if one wants to make the final return value of the tail call a closure ? Along the same lines of this being a manual way to do TCO, that issue will need to be handled manually as well. Here's what

Re: Patch: universal main() with repl/script/compile

2008-11-26 Thread Stephen C. Gilardi
On Nov 24, 2008, at 11:57 AM, Stephen C. Gilardi wrote: I've uploaded a patch along those lines: ant-compile-main.patch, http://tinyurl.com/5azp3u based on our recent work on this. This includes Compile.java, main.clj, and modifies build.xml. I've updated this to reflect several

Trouble compiling clojure.contrib libs

2008-11-25 Thread Stephen C. Gilardi
I'm having trouble compiling code from clojure-contrib. Here's a reproducible example based on the current svn heads of each (1121, 257). % cd /tmp % svn co https://clojure.svn.sourceforge.net/svnroot/clojure/trunk clojure /dev/null % svn co

Re: Monads in Clojure

2008-11-25 Thread Stephen C. Gilardi
On Nov 25, 2008, at 9:06 AM, Konrad Hinsen wrote: But it would be fairly easy to implement symbol- macrolet on top of my replace-syms. Would that be something of interest to the Clojure community? I have no experience with it myself, but I've seen it discussed as something that would be a

Re: trampoline for mutual recursion

2008-11-25 Thread Stephen C. Gilardi
On Nov 25, 2008, at 9:05 AM, Rich Hickey wrote: I've added trampoline to ease the conversion/creation of mutually recursive algorithms in Clojure. Very cool! Thanks for enabling that. In looking over the implementation, I found a small problem: the arg vector precedes the doc string

Re: Trouble compiling clojure.contrib libs

2008-11-25 Thread Stephen C. Gilardi
On Nov 25, 2008, at 11:38 AM, Chouser wrote: On Tue, Nov 25, 2008 at 9:02 AM, Stephen C. Gilardi [EMAIL PROTECTED] wrote: % java -cp clojure.jar:/tmp/clojure-contrib/src:/tmp/myclasses clojure.lang.Repl The classes directory (/tmp/myclasses in this case) must exist before you start

Re: Patch: universal main() with repl/script/compile

2008-11-24 Thread Stephen C. Gilardi
On Nov 23, 2008, at 2:30 PM, Stuart Sierra wrote: Hmm, you mean write the REPL in Clojure? I hadn't though of that. Intriguing idea. It would be neat if the REPL were just a function, so you could start it from within a program using arbitrary input/ output streams. Something to think

Re: Patch: universal main() with repl/script/compile

2008-11-24 Thread Stephen C. Gilardi
On Nov 24, 2008, at 2:17 PM, J. McConnell wrote: On Mon, Nov 24, 2008 at 1:49 PM, Michael Wood [EMAIL PROTECTED] wrote: This looks great :) Yes, it does! :-) I was going to suggest something similar: Usage: java -jar clojure.jar [option*] [file-arg*] [-- [arg*]] That looks

Re: Patch: universal main() with repl/script/compile

2008-11-24 Thread Stephen C. Gilardi
On Nov 24, 2008, at 2:28 PM, Stephen C. Gilardi wrote: Usage: java -jar clojure.jar [option*] [file-arg*] [-- [arg*]] That looks exactly right to me. I'll be adopting that. On further review, I think this is better: Usage: java -jar clojure.jar [option*] [file-arg*] [-- arg

Re: assert with message [patch]

2008-11-23 Thread Stephen C. Gilardi
On Nov 23, 2008, at 7:52 PM, Bradbev wrote: Here is a small change to assert that allows it to take an optional message that will part of the exception that is thrown. I like that. In case folks haven't seen them, there are some more functions that make throwing an exception with a message

Re: Patch: universal main() with repl/script/compile

2008-11-22 Thread Stephen C. Gilardi
On Nov 21, 2008, at 10:33 PM, Stuart Sierra wrote: Thanks, Stephen -- good feedback! I fixed [2] and [3]. Not sure about [1], maybe it's a line-ending thing. Anyway, this new patch (attached) was written on OSX, so it had better work! -S Thanks Stuart! They all worked. But... what are

Re: Suggest allowing java property to specify *compile-path*

2008-11-21 Thread Stephen C. Gilardi
On Nov 20, 2008, at 2:04 PM, Rich Hickey wrote: I'm in favor. I'd like to get a single story together incorporating Stuart's build.xml, his file compiler: http://groups.google.com/group/clojure/msg/4f0aa3be9a2dc79d and this path suggestion. I've uploaded a patch that works like

Re: odd behavior for use/ ns :use

2008-11-21 Thread Stephen C. Gilardi
On Nov 21, 2008, at 8:39 AM, Stuart Halloway wrote: The right way to use, most of the time, is inside an ns: (ns foo (:use [clojure.contrib.str-utils :only (str-join re-split)])) However, for the interactive examples in the book, it is nice to just switch namespaces at the REPL, where

Re: [PATCH] Add build/run instructions to the readme.

2008-11-21 Thread Stephen C. Gilardi
On Nov 21, 2008, at 2:50 PM, Phil Hagelberg wrote: For Java people this is probably obvious, but I didn't really have a clue how to compile the project after checking out the source. Here is a patch that makes the readme a little more helpful. Does java -jar clojure.jar work to launch a

Re: Patch: universal main() with repl/script/compile

2008-11-21 Thread Stephen C. Gilardi
On Nov 21, 2008, at 12:34 PM, Stuart Sierra wrote: The attached patch combines Repl, Script, and the lib compiler that Stephen G. and I have worked on. Hi Stuart, I like the concept very much. I had a couple of problems in working with the patch: [1] patch on Mac OS X Leopard rejected the

Suggest allowing java property to specify *compile-path*

2008-11-20 Thread Stephen C. Gilardi
Currently the compiler writes classes to the hierarchy under the value of *compile-path* whose root binding is classes. As we see in Stuart's build.xml patch, it can convenient to be able to specify such a path as part of the JVM's environment. To support that, I suggest the following:

Re: with-gensyms

2008-11-20 Thread Stephen C. Gilardi
On Nov 20, 2008, at 4:18 PM, Rock wrote: Another question: I was wondering why there seem to be no macrolet or symbol-macrolet macros in the language. Is it part of the language design or will they be added in future releases? Rich misses symbol-macrolet too:

Re: Suggest allowing java property to specify *compile-path*

2008-11-20 Thread Stephen C. Gilardi
On Nov 20, 2008, at 4:33 PM, Stuart Sierra wrote: Yes! All we need is a file compiler that works. :) There's something missing, in both my attempts, which causes the root class file for the namespace not to be generated. Rich, any idea what's missing? It looks to me like compiling libs

Re: Newbie: Creating a MapEntry

2008-11-20 Thread Stephen C. Gilardi
On Nov 21, 2008, at 12:03 AM, samppi wrote: Is it possible to create a MapEntry from scratch? user= (def a (clojure.lang.MapEntry. 3 4)) #'user/a user= (key a) 3 user= (val a) 4 user= You can also make it a little shorter by importing clojure.lang.MapEntry . --Steve

Re: Test Coerced-BigDecimal in clojure.contrib.test-clojure throws an Exception

2008-11-18 Thread Stephen C. Gilardi
I think Clojure should change to allow (bigdec 3) to succeed. BigDecimal has a valueOf method that accepts a long. It has a constructor that accepts an int. I haven't made a bug report on this yet, but here it is. Here are another thing that came up during testing of numbers: I think the

Re: clojure slime

2008-11-18 Thread Stephen C. Gilardi
SVN version 1110 of Clojure made a breaking change to a feature that swank-clojure is using. For now, I recommend moving back one rev by using: svn up -r 1109 from within your checkout of clojure/trunk. In the past, Jeff has updated swank-clojure very quickly on those rare occasions where

Re: Patch: standalone compiler (almost)

2008-11-17 Thread Stephen C. Gilardi
On Nov 16, 2008, at 10:34 PM, Rich Hickey wrote: Since it only requires main, might I suggest you write this in Clojure instead? I gave that a try. Here's a simple version of a driver for the compiler, stored in src/ clj/clojure/compile.clj: (ns clojure.compile) (defn

<    1   2   3   4   5   6   >