Patch available: *print-length*, *print-level*

2008-10-23 Thread Stephen C. Gilardi
Rich mentioned on #clojure that a patch to implement *print-length* would be welcome. I've uploaded a patch that implements Common Lisp's *print-length* and *print-level* for Clojure: http://clojure.googlegroups.com/web/print-length-level.patch The CL docs are at: http://www

Re: Reader + Macros on untrusted S Expressions: Security considerations?

2008-10-23 Thread Adam Jones
On Oct 22, 6:17 am, Chouser <[EMAIL PROTECTED]> wrote: > On Wed, Oct 22, 2008 at 4:30 AM, Brett Morgan <[EMAIL PROTECTED]> wrote: > > > I understand the lisp way is to use the reader plus macros to interpret the > > incoming data stream. This is hella cool in that it seriously cuts down on > > t

Re: Clojure and introspection/reflection analysis?

2008-10-23 Thread mb
Hi, On 24 Okt., 00:42, BerlinBrown <[EMAIL PROTECTED]> wrote: > And then I have a utility to load hello_world.lisp and execute > the hello-world call. > > At the command line: > #Inspect: hello-world function was called > #Hello World > #Inspect: hello-world has finished executing. There is

Re: Clojure and introspection/reflection analysis?

2008-10-23 Thread Parth Malwankar
On Oct 24, 3:42 am, BerlinBrown <[EMAIL PROTECTED]> wrote: > I asked this on common lisp thread but I want to work with clojure as > well: > > With clojure and I am assuming the introspection properties.  How > can I add code to clojure code that will tell me when a function > is called and when

Weird exception behavior

2008-10-23 Thread jim
Rich, When I do the following: (gen-and-load-class 'user.UserException :extends Exception) (defn th [arg] (throw (new user.UserException "thrown exception"))) (defn test-fn [] (try (dorun (map th '(1 2 3))) (catch user.UserException e

Re: Clojure and introspection/reflection analysis?

2008-10-23 Thread Chouser
On Thu, Oct 23, 2008 at 6:42 PM, BerlinBrown <[EMAIL PROTECTED]> wrote: > > For example, pseudo code in common lisp, hello_world.lisp: > > (defun hello-world () > (format t "Hello World")) > > (hello-world) > > And then I have a utility to load hello_world.lisp and execute > the hello-world

Re: BUG? Can't bind a macro

2008-10-23 Thread Mike Hinchey
Binding isn't suppose to work for macros. Macros expand during compile-time, and binding only affects vars at runtime. (and) expands into let* and if, neither of which you can bind because they are special rather than being vars/functions -- see (macroexpand `(and 1 2)). Similary, fn expands to

Re: Clojure and introspection/reflection analysis?

2008-10-23 Thread BerlinBrown
On Oct 23, 6:42 pm, BerlinBrown <[EMAIL PROTECTED]> wrote: > I asked this on common lisp thread but I want to work with clojure as > well: > > With clojure and I am assuming the introspection properties.  How > can I add code to clojure code that will tell me when a function > is called and when

Clojure and introspection/reflection analysis?

2008-10-23 Thread BerlinBrown
I asked this on common lisp thread but I want to work with clojure as well: With clojure and I am assuming the introspection properties. How can I add code to clojure code that will tell me when a function is called and when has finished executing. I want to take any lisp code and this particul

Re: Currying for Clojure

2008-10-23 Thread André Thieme
On 23 Okt., 15:12, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Oct 22, 6:45 pm, André Thieme <[EMAIL PROTECTED]> wrote: > I think, in general, this proposal, while interesting, has the > difficulty that it reduces the power of #() to not much more than > currying, and has some presumptions that n

BUG? Can't bind a macro

2008-10-23 Thread MikeM
In SVN 1075, binding doesn't seem to work for macros: ;defined as fn to avoid "can't take value of a macro" exception (defn bind-test [& args] `(println "bind-test" [EMAIL PROTECTED])) (binding [and bind-test] (and 1)) I recall this used to work (from some experiments I ran in May of this ye

Re: Strange behavior of the #() macro

2008-10-23 Thread Chouser
On Thu, Oct 23, 2008 at 11:55 AM, R. P. Dillon <[EMAIL PROTECTED]> wrote: > > Very clear explanation - I guess I thought that it would be possible > to to do the equivalent of (constantly 3) using the macro. I was just > overlooking the arity issue with the reduce call. It's possible, but ugly.

Re: Modified doto

2008-10-23 Thread Stephen C. Gilardi
On Oct 23, 2008, at 10:53 AM, Rich Hickey wrote: > Any thoughts on this as part of the upcoming bit of breaking changes? I think it would be a very useful change. I'm in favor. --Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed t

Re: Strange behavior of the #() macro

2008-10-23 Thread R. P. Dillon
Very clear explanation - I guess I thought that it would be possible to to do the equivalent of (constantly 3) using the macro. I was just overlooking the arity issue with the reduce call. Thanks for taking the time to explain! Cheers, Rick --~--~-~--~~~---~--~~

Re: Modified doto

2008-10-23 Thread Chouser
On Thu, Oct 23, 2008 at 10:53 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > I'd rather enhance doto to do this and not add another variant. The > break would be that current (doto x (foo 42)) would have to become > (doto x (.foo 42)). > > Any thoughts on this as part of the upcoming bit of breaki

Re: Modified doto

2008-10-23 Thread Rich Hickey
On Oct 21, 10:30 am, mb <[EMAIL PROTECTED]> wrote: > Hi, > > On 21 Okt., 14:41, mb <[EMAIL PROTECTED]> wrote:> (defmacro doto-> > > The name is actually also up to discussion. doto is already > in use and this change is incompatible to "legacy" code. > I couldn't come up with a good alternative.

Re: Placement of metadata in defn

2008-10-23 Thread Paul Drummond
Thanks guys, I get it now. I was forgetting that #^ attaches to the next thing read, it makes sense now! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Re: Data types in Clojure

2008-10-23 Thread Chouser
On Thu, Oct 23, 2008 at 8:38 AM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote: > > Clojure could validate all the arguments to use/require and I think it > should since this appears to be frequent tripping point for folks. > > Opinions on the value of that are welcome. I think we'd get more milea

Re: Placement of metadata in defn

2008-10-23 Thread mb
Hi Paul, On 23 Okt., 15:11, Paul Drummond <[EMAIL PROTECTED]> wrote: > I am a bit puzzled by how metadata seems to behave differently > depeding on where it's used and whether #^ is included or not: AFAIU, #^ attaches the given map to the thing read. > (defn #^{:doc "doc"}  my-fn ([x] x)) > ;;W

Re: Placement of metadata in defn

2008-10-23 Thread Rich Hickey
On Oct 23, 9:11 am, Paul Drummond <[EMAIL PROTECTED]> wrote: > I am a bit puzzled by how metadata seems to behave differently > depeding on where it's used and whether #^ is included or not: > > (defn #^{:doc "doc"} my-fn ([x] x)) ;;Works > (defn {:doc "doc"} my-fn ([x] x)) ;;Error: Second a

Re: Currying for Clojure

2008-10-23 Thread Rich Hickey
On Oct 22, 6:45 pm, André Thieme <[EMAIL PROTECTED]> wrote: > On 23 Okt., 00:28, wwmorgan <[EMAIL PROTECTED]> wrote: > > > You can get most of the functionality you're looking for with partial > > Yes sure. The thing is that currying is nothing but syntactical sugar. > It's not the functionality I

Placement of metadata in defn

2008-10-23 Thread Paul Drummond
I am a bit puzzled by how metadata seems to behave differently depeding on where it's used and whether #^ is included or not: (defn #^{:doc "doc"} my-fn ([x] x)) ;;Works (defn {:doc "doc"} my-fn ([x] x)) ;;Error: Second argument to def must be a Symbol (defn my-fn [x] x #^{:doc "doc"});;E

Re: Vim syntax support for BigDecimal literals

2008-10-23 Thread J. McConnell
> Just a technical note: please consider diff -u or > diff -c for patches. It provides more context and > also helps in case the hunk moved in the meantime. Ahhh ... the -u is what I was looking for ... couldn't think of it. I'll remember that from now on, thanks! - J. --~--~-~--~~-

Re: Vim syntax support for BigDecimal literals

2008-10-23 Thread mb
Hi, On 23 Okt., 14:48, "J. McConnell" <[EMAIL PROTECTED]> wrote: > Here's a tiny patch against the VimClojure syntax file to allow Vim to > recognize BigDecimal literals (numbers suffixed with "M"): > > kant[~/.vim/syntax]$ diff clojure.vim.orig clojure.vim > 162c162 > < syn match   clojureNumber

Vim syntax support for BigDecimal literals

2008-10-23 Thread J. McConnell
Here's a tiny patch against the VimClojure syntax file to allow Vim to recognize BigDecimal literals (numbers suffixed with "M"): kant[~/.vim/syntax]$ diff clojure.vim.orig clojure.vim 162c162 < syn match clojureNumber "\<-\?[0-9]\+\>" --- > syn match clojureNumber "\<-\?[0-9]\+M\?\>" Hope s

Re: Data types in Clojure

2008-10-23 Thread Stephen C. Gilardi
On Oct 23, 2008, at 2:50 AM, [EMAIL PROTECTED] wrote: > Who is casting which Boolean to what there? And, more importantly, > what do I need to fix in my code line? Hi Konrad, Here is the correct syntax for 'use' in this case (with the current SVN Clojure which now defines clojure/remove):

Re: Strange behavior of the #() macro

2008-10-23 Thread mb
Hi Rick, First of all: #(x) is equivalent with (fn [] (x)). So as an example with reduce: user=> (reduce #(+ %1 %2) (range 1 101)) 5050 user=> (reduce (fn [x y] (+ x y)) (range 1 101)) 5050 So it should be obvious, that #(3) throws exception as soon as it is called, since it is equivalent to (fn

Strange behavior of the #() macro

2008-10-23 Thread R. P. Dillon
Using #() for "one off" functions, you get some odd behavior: (reduce #(3) (range 1 100)) throws an exception: java.lang.IllegalArgumentException: Wrong number of args passed to: eval--2365$fn as does: (reduce (fn [] 3) (range 1 100) but: (reduce (constantly 3) (range 1 100)) performs as one would

Re: Data types in Clojure

2008-10-23 Thread Konrad Hinsen
On 22.10.2008, at 19:41, Matthias Benkard wrote: > Personally, I'd define multimethods as the “interface“, in a single > namespace, and implement them for any set of data structures that I > wanted to support. Multimethods were my first idea as well, but I couldn't think of a good way to defin

Re: Data types in Clojure

2008-10-23 Thread mb
Hi, On 23 Okt., 08:50, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > This leads me to a more down-to-earth question: what is the right way > to use clojure/zip in a program? First I tried > > (use 'clojure.zip) I normally use an alias: (require '[clojure.zip :as zip]) user=> (-> (zip/ve

Re: Find lines matching regexp in large text file - performance suggestions welcome

2008-10-23 Thread Mathias Dahl
> I don't see any way to significantly improve your speed, but I can > save you some lines of code: Thanks! I ended up calling out to grep instead :) Here is the code if someone else wants to do similar things: (defn real-grep [pattern] (debug (str "pattern: " pattern)) (let [cmd-arr