Re: Is it possible to implement break or return in Lisp?

2009-11-02 Thread Jarkko Oranen
On Nov 3, 2:03 am, CuppoJava wrote: > Thanks Brian. > > For my own purposes, yes I have no need for a break or return > statement. > > But I'm writing a DSL for others to use. People that don't have > experience with functional programming, and for them it's easier to > have a break/return. And

Re: Running out of memory when using loop/recur and destructuring

2009-11-02 Thread Alex Osborne
Paul Mooser wrote: > Good job tracking down that diff -- upon looking at it, unfortunately, > I obviously don't understand the underlying issue being fixed (the > inter-binding dependencies) because the "old code" basically matches > what I would think would be the way to avoid introducing this in

Re: Syntax highlighting clojure code

2009-11-02 Thread Miron Brezuleanu
Hello, On Tue, Nov 3, 2009 at 1:41 AM, Stefan Arentz wrote: > > I want to post some Clojure code to my blog. Does anyone know of a > simple, preferably online, code highlighter for Clojure or Lisp that > turns code into simple html with either a stylesheet or just color=""> tags? Try putting t

Re: Compiling latest ClojureCLR

2009-11-02 Thread dmiller
As promised, the new native BigDecimal has been completed. ClojureCLR no longer has a dependency on the Visual J# Redistributable (vjslib). I think this removes the last barrier to those wanting to play with ClojureCLR on Mono. (All two of you.) :) --David On Oct 31, 8:57 pm, dmiller wrote:

Re: Running out of memory when using loop/recur and destructuring

2009-11-02 Thread Paul Mooser
Good job tracking down that diff -- upon looking at it, unfortunately, I obviously don't understand the underlying issue being fixed (the inter-binding dependencies) because the "old code" basically matches what I would think would be the way to avoid introducing this in an outer let form -- clear

Re: Syntax highlighting clojure code

2009-11-02 Thread Tassilo Horn
Timothy Pratley writes: > VIM makes this very easy > :TOhtml And for emacs, there's htmlize.el. Bye, Tassilo > On Nov 3, 10:41 am, Stefan Arentz wrote: >> I want to post some Clojure code to my blog. Does anyone know of a   >> simple, preferably online, code highlighter for Clojure or Lisp t

Re: Generalizing -> & ->>

2009-11-02 Thread Alex Osborne
Sean Devlin wrote: > This is slightly unrealted, but how does one pronounce ->, ->> and the > like? Is this documented? The doc-strings usually give you a nice hint. I usually use "thread" for -> and "thread last" for ->>. The actual symbols I think of as "arrow" and "double arrow". Then -?

Re: Is it possible to implement break or return in Lisp?

2009-11-02 Thread CuppoJava
Thanks Brian. For my own purposes, yes I have no need for a break or return statement. But I'm writing a DSL for others to use. People that don't have experience with functional programming, and for them it's easier to have a break/return. And for me, it's easier to implement break/return using

Re: Syntax highlighting clojure code

2009-11-02 Thread Timothy Pratley
VIM makes this very easy :TOhtml On Nov 3, 10:41 am, Stefan Arentz wrote: > I want to post some Clojure code to my blog. Does anyone know of a   > simple, preferably online, code highlighter for Clojure or Lisp that   > turns code into simple html with either a stylesheet or just color=""> tag

Syntax highlighting clojure code

2009-11-02 Thread Stefan Arentz
I want to post some Clojure code to my blog. Does anyone know of a simple, preferably online, code highlighter for Clojure or Lisp that turns code into simple html with either a stylesheet or just tags? S. --~--~-~--~~~---~--~~ You received this message be

Re: Running out of memory when using loop/recur and destructuring

2009-11-02 Thread Paul Mooser
This is great advice, of course. On the other hand, I feel it's important to be explicitly clear about which forms will hold on to (seemingly) transient data. Certain things are explicitly clear about this (such as the docstring for doseq), and this particular case is unfortunate because in the co

Re: Running out of memory when using loop/recur and destructuring

2009-11-02 Thread John Harrop
On Mon, Nov 2, 2009 at 2:39 PM, Christophe Grand wrote: > Right now I can't see how loop can be made to support both cases. > Hopefully someone else will. In the meantime, remember that it's always worth trying to implement seq-processing in terms of map, reduce, filter, for, and friends if poss

Re: Is it possible to implement break or return in Lisp?

2009-11-02 Thread Brian Hurt
On Sun, Nov 1, 2009 at 8:04 PM, CuppoJava wrote: > > Hi, > For the purposes of a DSL that I'm writing, it would be very > convenient to have a break/return statement that early exits from a > subroutine. > > I'm not sure why you need this. The body of a function in clojure isn't a series of state

Re: ClojureCLR: out parameters

2009-11-02 Thread Miron Brezuleanu
Hello, On Mon, Nov 2, 2009 at 8:03 PM, dmiller wrote: > > > One thing to keep in mind in any proposed solution:  CLR allows > overloading a ref/out param against a non-ref/out param. > > class Test > { >   static void m(int x) { ... } >   static void m(ref int x) { ... } > } > > So not just resu

Re: Applying static java method to seq

2009-11-02 Thread ataggart
Good point about type-hinting. On Nov 2, 11:42 am, Chouser wrote: > On Mon, Nov 2, 2009 at 3:32 PM, ataggart wrote: > > > If (Integer/parseInt "5") works, then not all functions need be an > > implementation of IFn; or perhaps more precisely, clojure knows when a > > call is being made to an IF

Re: Applying static java method to seq

2009-11-02 Thread Richard Newman
> If (Integer/parseInt "5") works, then not all functions need be an > implementation of IFn; or perhaps more precisely, clojure knows when a > call is being made to an IFn vs a static java method. That's not a first-class function call. All first-class functions need to be callable, but not al

Re: Applying static java method to seq

2009-11-02 Thread Kevin Downey
(Integer/parseInt "5") is actually (. Integer parseInt "5") which works fine because "." is the operator position, and "." is a special form On Mon, Nov 2, 2009 at 11:32 AM, ataggart wrote: > > If (Integer/parseInt "5") works, then not all functions need be an > implementation of IFn; or perhaps

Re: Applying static java method to seq

2009-11-02 Thread Chouser
On Mon, Nov 2, 2009 at 3:32 PM, ataggart wrote: > > If (Integer/parseInt "5") works, then not all functions need be an > implementation of IFn; or perhaps more precisely, clojure knows when a > call is being made to an IFn vs a static java method.  It would be > nice for consistency if whatever m

Re: Applying static java method to seq

2009-11-02 Thread ataggart
If (Integer/parseInt "5") works, then not all functions need be an implementation of IFn; or perhaps more precisely, clojure knows when a call is being made to an IFn vs a static java method. It would be nice for consistency if whatever makes that work also treated Integer/ parseInt as a function

Re: On defvar's order of arguments

2009-11-02 Thread Stuart Halloway
This change will break a bunch of my code, and nevertheless gets a big +1. Stu > I use clojure.contrib.def/defvar a lot. It's really useful for adding > docstrings to non-function vars. But I've been tripped up by the same > mistake a lot now—I keep expecting the docstring to go after the > in

On defvar's order of arguments

2009-11-02 Thread samppi
I use clojure.contrib.def/defvar a lot. It's really useful for adding docstrings to non-function vars. But I've been tripped up by the same mistake a lot now—I keep expecting the docstring to go after the initial value, because that would be consistent with defn, defmacro, and defmulti. Here are

Re: Applying static java method to seq

2009-11-02 Thread Richard Newman
> Direct references to methods don't work in higher-order functions > for some reason. The reason is simply that Java methods are not first-class objects in Clojure. Clojure functions are classes that implement IFn, and thus can be passed around as objects. That's all higher-order function

Re: Running out of memory when using loop/recur and destructuring

2009-11-02 Thread Christophe Grand
Hi Paul, It's indeed surprising and at first glance, it looks like a bug but after researching the logs, this let form was introduced in the following commit http://github.com/richhickey/clojure/commit/288f34dbba4a9e643dd7a7f77642d0f0088f95ad with comment "fixed loop with destructuring and inter-

Clojure spotted in "the wild"

2009-11-02 Thread klang
While installing the wave-client-for-emacs to try out google wave, I noticed something that I had not expected in the README file: __This package has one binary executable, and one emacs library. The executable uses Clojure to implement an API on top of Wave-protocol's FedOne client.__ (http://

Re: ClojureCLR: out parameters

2009-11-02 Thread dmiller
One thing to keep in mind in any proposed solution: CLR allows overloading a ref/out param against a non-ref/out param. class Test { static void m(int x) { ... } static void m(ref int x) { ... } } So not just result handling is needed, but also interop calls themselves sometimes need a h

Re: ClojureCLR: out parameters

2009-11-02 Thread dmiller
It might be a nice idea if atoms/vars/refs could be passed and modified appropriately in these calls. However, there is an efficiency to local variable bindings that could not be attained with these other mechanisms. On Nov 2, 11:22 am, John Harrop wrote: > Wouldn't it be cleaner to just requir

Re: Running out of memory when using loop/recur and destructuring

2009-11-02 Thread Paul Mooser
I'm a little surprised I haven't seen more response on this topic, since this class of bug (inadvertently holding onto the head of sequences) is pretty nasty to run into, and is sort of awful to debug. I'm wondering if there's a different way to write the loop macro so that it doesn't expand into

Re: Creating custom exceptions in clojure & gen--class use?

2009-11-02 Thread Teemu Antti-Poika
On Nov 2, 7:12 pm, John Harrop wrote: > On Mon, Nov 2, 2009 at 10:00 AM, Teemu Antti-Poika wrote: > > > I expressed myself poorly: what I meant was simply that I want to use > > exceptions to handle some error situations but leave some exceptions > > for the servlet container to handle.  I did no

Re: ClojureCLR: out parameters

2009-11-02 Thread John Harrop
Wouldn't it be cleaner to just require that the ref/out parameters be passed an atom, a var with a thread-local binding, or a ref, and treat the CLR method as performing a swap!, set!, or alter as appropriate? (Complete with passing it a ref failing outside of a dosync block.) In other words, just

Re: Applying static java method to seq

2009-11-02 Thread John Harrop
On Mon, Nov 2, 2009 at 12:29 PM, Thomas wrote: > How come I can do this > > user=> (map #(Integer/parseInt %) ["42" "100"]) > (42 100) > > but not this > > user=> (map Integer/parseInt ["42" "100"]) > java.lang.Exception: Unable to find static field: parseInt in class > java.lang.Integer (NO_SOURC

Re: Write big numbers with thousands grouping.

2009-11-02 Thread John Harrop
On Mon, Nov 2, 2009 at 12:34 PM, Stuart Sierra wrote: > On Oct 31, 12:37 pm, John Harrop wrote: > > For some reason though changing "defmacro" here to "definline" doesn't > work. > > It says > > > > # this > > context (NO_SOURCE_FILE:129)> > > definline doesn't support variable arities. As in,

Re: Creating custom exceptions in clojure & gen--class use?

2009-11-02 Thread John Harrop
On Mon, Nov 2, 2009 at 10:00 AM, Teemu Antti-Poika wrote: > > On Nov 1, 11:18 pm, John Harrop wrote: > > On Sun, Nov 1, 2009 at 3:47 PM, Teemu Antti-Poika >wrote: > > > > > I want to use my own exceptions to control program flow. > > > > That's usually not a very good idea. What exactly are you

Re: ClojureCLR: out parameters

2009-11-02 Thread Daniel Werner
On Nov 2, 4:07 pm, Miron Brezuleanu wrote: > On Mon, Nov 2, 2009 at 4:30 PM, dmiller wrote: > > For ref & out parameters, the problem is that let bindings and fn > > parameters are not variables.  You can't change the values they are > > bound to.  ref and out change the values bound to the vari

Re: Clojure contrib http-agent hangs when making a POST request

2009-11-02 Thread Stuart Sierra
I've pushed a slightly different fix; (string...) now waits for the HTTP request to finish. -SS On Oct 31, 6:00 am, Alex wrote: > Rob, that's perfect. Thanks very much for looking into that and > supplying the patch. Hopefully we can get that applied to the source > in git. > > On Oct 30, 9:58

Applying static java method to seq

2009-11-02 Thread Thomas
How come I can do this user=> (map #(Integer/parseInt %) ["42" "100"]) (42 100) but not this user=> (map Integer/parseInt ["42" "100"]) java.lang.Exception: Unable to find static field: parseInt in class java.lang.Integer (NO_SOURCE_FILE:2) I understand that Clojure is trying to look up Intege

Re: Write big numbers with thousands grouping.

2009-11-02 Thread Stuart Sierra
On Oct 31, 12:37 pm, John Harrop wrote: > For some reason though changing "defmacro" here to "definline" doesn't work. > It says > > # context (NO_SOURCE_FILE:129)> definline doesn't support variable arities. -SS --~--~-~--~~~---~--~~ You received this message be

Re: Generalizing -> & ->>

2009-11-02 Thread Sean Devlin
This is slightly unrealted, but how does one pronounce ->, ->> and the like? Is this documented? On Oct 31, 8:37 am, John Harrop wrote: > On Sat, Oct 31, 2009 at 9:13 AM, Daniel Werner < > > daniel.d.wer...@googlemail.com> wrote: > > > On Oct 29, 9:35 pm, "AndrewC." wrote: > > > Here's a macro

Re: throw-if

2009-11-02 Thread Sean Devlin
+1 Name collision w/ core should be resolved when possible, especially if they do similar things. On Nov 1, 10:40 am, John Harrop wrote: > There seems to be a bit of wasteful duplication in clojure: there's a > private clojure.core/throw-if and there's clojure.contrib.except/throw-if. > Making

Constructor Errors in gen-class

2009-11-02 Thread Gorsal
I have a question. When you do a gen-class and specify incorrect constructor arguments, is an error supposed to be produced? Currently, in the eclipse clojure plugin, clojure silently doesn't create the class. (gen-class :name "NAME" :init init :post-init post-init :construct

Re: ClojureCLR: out parameters

2009-11-02 Thread Miron Brezuleanu
Hello, On Mon, Nov 2, 2009 at 4:30 PM, dmiller wrote: > For ref & out parameters, the problem is that let bindings and fn > parameters are not variables.  You can't change the values they are > bound to.  ref and out change the values bound to the variables passed > as parameters. > > So if we i

Re: Is it possible to implement break or return in Lisp?

2009-11-02 Thread Sean Devlin
Could you do this w/ a lazy seq & cond? The seq terminates early if cond x is met. On Nov 1, 8:04 pm, CuppoJava wrote: > Hi, > For the purposes of a DSL that I'm writing, it would be very > convenient to have a break/return statement that early exits from a > subroutine. > > Is it possible to i

Re: ClojureCLR: out parameters

2009-11-02 Thread dmiller
ref & out parameters are not handled yet. This is one of four CLR interop problems waiting for solutions. See the CLR Interop page on the wiki for the others. Three of the four, including this one, have fairly simple solutions at the interop interface, but require some extension to Clojure to c

Re: Creating custom exceptions in clojure & gen--class use?

2009-11-02 Thread Teemu Antti-Poika
On Nov 1, 11:18 pm, John Harrop wrote: > On Sun, Nov 1, 2009 at 3:47 PM, Teemu Antti-Poika wrote: > > > I want to use my own exceptions to control program flow. > > That's usually not a very good idea. What exactly are you trying to do, for > which this would be useful? I expressed myself poorly

Re: Creating custom exceptions in clojure & gen--class use?

2009-11-02 Thread Meikel Brandmeyer
Hi, Am 02.11.2009 um 03:05 schrieb Kevin Downey: > it'd be nice if clojure came with an Exception class that extended > IMeta so you could use (catch MetaException e (if (= :my-exception > (type e)) do-stuff (throw e))) Isn't that, what c.c.condidtion does? >> gen-class is what you are looking