Metadata on defmulti

2008-10-10 Thread Jeff V

Do multimethods support doc strings or other metadata?

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Formatted printing?

2008-10-10 Thread Michel Salim



On Oct 10, 4:37 pm, "Paul Stadig" <[EMAIL PROTECTED]> wrote:
> I have a "database" that I'm working with that I'm loading using
>
> (def *db* (load-file "path-to-file/db.clj"))
>
> and saving using by basically opening a PrintWriter and using (pr-str *db*).
> The output to the file is a clojure data structure, but it is all on one
> line. Is there any existing code for printing out in a formatted way with
> new lines and indents and such?
>
Porting an existing CLisp / Scheme pretty printing tool probably won't
be hard. Is this for printing, or just for better readability?

Regards,

--
Michel Salim
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: GUIs in Clojure

2008-10-10 Thread Martin DeMello

On Oct 10, 9:08 pm, "Michael Beauregard" <[EMAIL PROTECTED]>
wrote:
> I still don't really see why a multi-threaded UI framework is
> important. You can have a multiple threads use Swing's
> invokeLater(Runnable r) api to submit UI work. And since Clojure fns
> implement Runnable, you can just post fns into Swing to do your UI
> updates. I don't think you even *want* a multi-threaded UI framework
> considering the threading bugs and performance problems it probably
> has (inherent to implementing complex concurrency with old school
> locking semantics).

At the extremely simple end of that scale is gtk-server:
http://www.gtk-server.org/index.html

martin
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: GUIs in Clojure

2008-10-10 Thread Michael Beauregard

I still don't really see why a multi-threaded UI framework is
important. You can have a multiple threads use Swing's
invokeLater(Runnable r) api to submit UI work. And since Clojure fns
implement Runnable, you can just post fns into Swing to do your UI
updates. I don't think you even *want* a multi-threaded UI framework
considering the threading bugs and performance problems it probably
has (inherent to implementing complex concurrency with old school
locking semantics).

On Fri, Oct 10, 2008 at 3:20 PM, Ande Turner <[EMAIL PROTECTED]> wrote:
> Apologies Colin...  I'll just say I was a victim of Trolltech marketing,
> that wasn't the impression I got.
>
> 2008/10/11 Colin Walters <[EMAIL PROTECTED]>
>>
>> On Oct 10, 4:42 pm, "Ande Turner" <[EMAIL PROTECTED]> wrote:
>> > David,
>> > Thank you very much for such an expansive response.  Currently a
>> > thread-safe
>> > Swing alternative is using the Jambi bindings for Qt. I neglected to
>> > provide
>>
>> Hmm?  Qt isn't really any more threadsafe than Swing is, or than GTK+
>> is:
>>
>> http://doc.trolltech.com/4.0/threads.html :
>> "Although QObject is reentrant, the GUI classes, notably QWidget and
>> all its subclasses, are not reentrant. They can only be used from the
>> main thread."
>>
>> GUI programs by their very nature have a large amount of state, and
>> the object-oriented paradigm makes a lot of sense.  So back to the
>> original question - probably what makes the most sense with Clojure is
>> to write nontrivial GUI components in Java, and the interact with your
>> GUI code via Clojure's Java integration.
>>
>>
>
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: GUIs in Clojure

2008-10-10 Thread Michael Beauregard

Part of why I didn't really follow through with this yet is that I'm
actually not very interested in swing. After doing a 2 year contract
using it I'm not sure I could use or recommend swing for anything
substantial with a straight face. I find it clumsy and over
complicated. Even still, it seems that it could be fun to use it for
small stuff from Clojure.

I've been using Flex a lot lately and it is a very nice way to do GUI
programming. Not perfect, but better than other things I've used by
quite a margin. I'll be sure to check out Shoes. Thanks for the tip.

Michael

On Fri, Oct 10, 2008 at 9:18 PM, Stuart Sierra
<[EMAIL PROTECTED]> wrote:
>
> On Oct 8, 6:19 pm, "Michael Beauregard" <[EMAIL PROTECTED]>
> wrote:
>> This doesn't address the functional/stateless impedance mismatch, but
>> would make defining guis simpler. However, the basic idea is to
>> represent the containment hierarchy inherent in a gui with the nesting
>> of lisp expressions.
>
> That's a cool idea.  Reminds me of Shoes: http://shoooes.net/
> It's a clever little Ruby GUI that uses nested containers and
> anonymous callback functions.
> -Stuart Sierra
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: GUIs in Clojure

2008-10-10 Thread Stuart Sierra

On Oct 8, 6:19 pm, "Michael Beauregard" <[EMAIL PROTECTED]>
wrote:
> This doesn't address the functional/stateless impedance mismatch, but
> would make defining guis simpler. However, the basic idea is to
> represent the containment hierarchy inherent in a gui with the nesting
> of lisp expressions.

That's a cool idea.  Reminds me of Shoes: http://shoooes.net/
It's a clever little Ruby GUI that uses nested containers and
anonymous callback functions.
-Stuart Sierra
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Event Listeners in Functional Programming

2008-10-10 Thread Chouser

On Fri, Oct 10, 2008 at 8:14 PM, CuppoJava <[EMAIL PROTECTED]> wrote:
>
> The Java "idiom" for eg. a button, is to create a button object which
> contains a list of "event listeners (closures/callback functions)"
> that get called when the button is clicked.

So what is it you want the button to do?  Mutability is no sin, and
Clojure gives you tools to manage it.

For example the click listener could dispatch an action to an agent,
which would allow the GUI to continue promptly while the action works
in another thread.  Would that be sufficient for what you want to
accomplish?

--Chouser

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Bug in r1057? Var reader macros in syntax quotes

2008-10-10 Thread Rich Hickey



On Oct 10, 12:34 pm, Perry <[EMAIL PROTECTED]> wrote:
> Not sure exactly how this is related, but r1058 still gives me the
> following error that popped up after r1057. Compojure defines this
> macro:
>
> (defmacro redef
>   "Redefine an existing value, keeping the metadata intact."
>   [name value]
>   `(let [m# (meta #'~name)
>  v# (def ~name ~value)]
>  (.setMeta v# (merge m# (meta #'~name)))
>  v#))
>
> & when it's read it produces this exception:
>
>  java.lang.ClassCastException: clojure.lang.LispReader$Unquote
> cannot be cast to clojure.lang.Symbol
>
> As the messages says, the nut seems to be that the ~name in `(#'~name)
> evaluates to an unquote, instead of a symbol (as it must've before).
>

Should be fixed in rev 1059, although the use of reader syntax in
macro expansions is suspect - it should use (var ~name) instead.

Rich

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Event Listeners in Functional Programming

2008-10-10 Thread CuppoJava

Hi guys,
I'm getting started with Clojure, and I'm programming a small gui.

The Java "idiom" for eg. a button, is to create a button object which
contains a list of "event listeners (closures/callback functions)"
that get called when the button is clicked.

This sort of structure relies upon the side-effects of the call-back
function.

What would be the functional programming equivalent for handling GUI
events?

Thanks a lot
 -Patrick
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: help a journalist: why Clojure?

2008-10-10 Thread Michel Salim

Coming from Scheme, at first my impression was "whoa, they removed a
*lot* of parentheses!". So I guess it depends on where one's coming
from.

--
Michel

On Oct 10, 1:22 pm, ".Bill Smith" <[EMAIL PROTECTED]> wrote:

> I think the biggest initial complaint about Clojure will be "too many
> parentheses". Once you get used to the Lisp syntax, though, you'll
> find Clojure is a delight to work with.
>
> Bill
>
> On Oct 10, 7:32 am, estherschindler <[EMAIL PROTECTED]> wrote:
>
> > I'm doing an article for CIO.com on "5 [or whatever] languages that
> > ought to be on your [IT Manager's] radar," and I'd like to include
> > Clojure. I'm looking for a short statement on why it's useful, and why
> > the boss ought to let you use it for enterprise work. Any takers?
>
> > This is meant to be a short-and-sweet article: just its name, URL, a
> > quick formal definition, and then one or two quotes from developers
> > about why they think it's valuable. Imagine that you're trying to
> > convince someone's boss to let you use it. What would you say?
>
> > (This is a follow-up 
> > tohttp://www.cio.com/article/446829/PHP_JavaScript_Ruby_Perl_Python_and...
> > in case you care. Some folks pointed out that a few "obvious"
> > languages should have been included. I'm happy to comply.)
>
> > --Esther Schindler
> >   senior online editor, CIO.com

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Macro expansion

2008-10-10 Thread JumpingJupiter

Like some other posters to this group, I thought it would be cool to
have Clojure create a GUI based on a declarative definition. My plan
was to use a recursive macro to handle the creation of nested swing
objects and I found myself wanting to view the macro expansions.
Unfortunately macroexpand and macroexpand won't do this for nested
macros:

  Note neither macroexpand-1 nor macroexpand expand macros in subforms
  (http://clojure.org/macros#toc12)

For example:

  user=> (macroexpand
  '(cond
(and (= a b) (= c d)) true
(or (= e f) (= g h)) false))

  -> (if (and (= a b) (= c d)) true (cond (or (= e f) (= g h)) false))

The initial 'cond' has been expanded into an 'if', but cond is a
recursive macro and the expansion produces another 'cond'. Furthermore
the 'and' & 'or' macros are unexpanded.

So, I wrote a function to produce a full macro expansion. I guess this
has been done a million times for other lisps, but since I'm a lisp
novice I had some fun doing it myself. After several ugly attempts
(which were educational in their own right) I came up with the
following set of functions.

(defn mapr
  "recursively maps a function to a sequence and
  subsequences within the map results."
  [f & sequence]
  (defn maprec [form]
(if (seq? form)
  (map maprec (f form))
  form))
  (first (maprec sequence)))

mapr maps a supplied function over a sequence and then maps the same
function over nested subsequences in the resulting collection. The
inner function maprec is interesting because it recurses by passing
itself to map. This is probably heavy on the stack, but that shouldn't
be a problem for my purposes.

Now, with mapr, it's trivial to expand all the macros within a form.
Simply call mapr passing the macroexpand function and the form to be
expanded.

(defn macroexpand-r
  "Expands all macros in a form and its subforms."
  [forms]
  (mapr macroexpand forms))

Repeating the above example with macroexpand-r:

  user=> (macroexpand-r
  '(cond
(and (= a b) (= c d)) true
(or (= e f) (= g h)) false))

  ->  (let* [and__196 (= a b)] (if and__196 (= c d) and__196)) true
  (if (let* [or__202 (= e f)] (if or__202 or__202 (= g h)))
false nil))

All the 'cond's 'and's & 'or's have been replaced with the 'if' and
'let' special forms. Pretty ugly isn't it?

That's useful, but too much since I will usually only be interested in
a single macro. I will want to expand instances of that macro and
leave others unexpanded. I can do that by passing mapr a function
which conditionally expands macros:

  user=> (mapr (fn [f] (if (= 'cond (first f)) (macroexpand f) f))
  '(cond
(and (= a b) (= c d)) true
(or (= e f) (= g h)) false))

  -> (if (and (= a b) (= c d)) true (if (or (= e f) (= g h)) false
nil))

Now the cond has been expanded (twice) but the 'and' & 'or' remain.
Just what I want, except I can't be bothered writing the fn everytime
so:

  (defn macroexpand-only
"Expands all macros in a form and its subforms that match a given
symbol."
[macro forms]
(mapr
 (fn [f] (if (= macro (first f)) (macroexpand f) f))
 forms))


user=> (macroexpand-only 'and '(cond (and (= a b) (= c d)) true (or (=
e f) (= g h)) false))

-> (cond (and (= a b) (= c d)) true (let* [or__202 (= e f)] (if
or__202 or__202 (clojure/or (= g h false)


user=> (macroexpand-only 'or '(cond (and (= a b) (= c d)) true (or (=
e f) (= g h)) false))

-> (cond (let* [and__196 (= a b)] (if and__196 (clojure/and (= c d))
and__196)) true (or (= e f) (= g h)) false)


user=> (macroexpand-only 'cond '(cond (and (= a b) (= c d)) true (or
(= e f) (= g h)) false))

-> (if (and (= a b) (= c d)) true (if (or (= e f) (= g h)) false nil))

Oops, looks like I've a got a problem. macroexpand sometimes produces
qualified names in the expansions and sometimes doesn't:

user=> (macroexpand '(cond (= a b) true (= c d) false))

-> (if (= a b) true (cond (= c d) false))

user=> (macroexpand '(or (= a b) (= c d)))

-> (let* [or__202 (= a b)] (if or__202 or__202 (clojure/or (= c d

There is an unadulterated recursive cond in the expansion of the cond
form. But the expansion of the 'or' form contains the 'closure/or'
symbol. This is because the definition of cond quotes its recursive
call while the 'or' (and 'and') definitions don't. Is this a bug? or
if not can someone explain the different usage? And while I'm asking
questions, why don't macroexpand and macroexpand-1 expand macros in
subforms?

The macroexpand-only function could be modified to accommodate the
different representations of macros, but I'll leave that for another
day.

And that's it.

If you're going to use these macros, be warned, they're only minimally
tested and I don't know what I'm doing. I wouldn't be at all surprised
if there's a good reason why Rich hasn't made something like this part
of Clojure. (or maybe he has and I just didn't notice)


Now, where was I ...



--~--~-~--~~~---~--~~
You received this message bec

Re: GUIs in Clojure

2008-10-10 Thread John

Allegedly gnome-java is threadsafe, but it only works on Linux,
unfortunately.

http://research.operationaldynamics.com/blogs/andrew/software/java-gnome/

On Oct 10, 5:20 pm, "Ande Turner" <[EMAIL PROTECTED]> wrote:
> Apologies Colin...  I'll just say I was a victim of Trolltech marketing,
> that wasn't the impression I got.
>
> 2008/10/11 Colin Walters <[EMAIL PROTECTED]>
>
>
>
> > On Oct 10, 4:42 pm, "Ande Turner" <[EMAIL PROTECTED]> wrote:
> > > David,
> > > Thank you very much for such an expansive response.  Currently a
> > thread-safe
> > > Swing alternative is using the Jambi bindings for Qt. I neglected to
> > provide
>
> > Hmm?  Qt isn't really any more threadsafe than Swing is, or than GTK+
> > is:
>
> >http://doc.trolltech.com/4.0/threads.html:
> > "Although QObject is reentrant, the GUI classes, notably QWidget and
> > all its subclasses, are not reentrant. They can only be used from the
> > main thread."
>
> > GUI programs by their very nature have a large amount of state, and
> > the object-oriented paradigm makes a lot of sense.  So back to the
> > original question - probably what makes the most sense with Clojure is
> > to write nontrivial GUI components in Java, and the interact with your
> > GUI code via Clojure's Java integration.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure, emacs, slime, swank tutorial for Ubuntu

2008-10-10 Thread solkis

I haven't tried configuring the REPL scripts to use rlwrap. I'm mostly
learning within emacs where it may be a moot point anyway (not sure.)
I know in emacs I use Alt-p get get past forms. I'm definitely open to
modifying this config tutorial to use rlwrap if it's more stable when
needed (like directly in a shell-based REPL.) I not sure in what
situations that JLine is iffy as you mentioned. Can you give any quick
suggestions on what sections I would need to modify to switch in
rlwrap? As you can see I'm using the scripts as closely as possible
from clojure-extra so that the tutorial stays basic.

Thanks for the feedback,

-Tim

On Oct 10, 5:09 pm, James Reeves <[EMAIL PROTECTED]> wrote:
> On Oct 10, 10:22 pm, solkis <[EMAIL PROTECTED]> wrote:
>
> > I just created a basic clojure, emacs, slime, swank configuration
> > tutorial for Ubuntu users
>
> I notice your tutorial uses JLine, which I've found to be rather iffy
> under Linux. Have you tried the REPL with rlwrap? Or haven't you had
> any problems with JLine?
>
> - James
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure, emacs, slime, swank tutorial for Ubuntu

2008-10-10 Thread James Reeves

On Oct 10, 10:22 pm, solkis <[EMAIL PROTECTED]> wrote:
> I just created a basic clojure, emacs, slime, swank configuration
> tutorial for Ubuntu users

I notice your tutorial uses JLine, which I've found to be rather iffy
under Linux. Have you tried the REPL with rlwrap? Or haven't you had
any problems with JLine?

- James
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Clojure, emacs, slime, swank tutorial for Ubuntu

2008-10-10 Thread solkis

I just created a basic clojure, emacs, slime, swank configuration
tutorial for Ubuntu users (although hopefully it could be helpful to
others as well.) This assumes a new Ubuntu installation (with no Java
even) It's at a newb level since that's where I've been myself (with
clojure, lisp) for the past few weeks. I hope someone finds it
helpful. I wanted to give something back to the community since I
won't be giving much code advice for a while :-)

Tutorial is here >> http://riddell.us/clojure

Thanks,

-Tim

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: GUIs in Clojure

2008-10-10 Thread Colin Walters

On Oct 10, 4:42 pm, "Ande Turner" <[EMAIL PROTECTED]> wrote:
> David,
> Thank you very much for such an expansive response.  Currently a thread-safe
> Swing alternative is using the Jambi bindings for Qt. I neglected to provide

Hmm?  Qt isn't really any more threadsafe than Swing is, or than GTK+
is:

http://doc.trolltech.com/4.0/threads.html :
"Although QObject is reentrant, the GUI classes, notably QWidget and
all its subclasses, are not reentrant. They can only be used from the
main thread."

GUI programs by their very nature have a large amount of state, and
the object-oriented paradigm makes a lot of sense.  So back to the
original question - probably what makes the most sense with Clojure is
to write nontrivial GUI components in Java, and the interact with your
GUI code via Clojure's Java integration.

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: GUIs in Clojure

2008-10-10 Thread Ande Turner
Apologies Colin...  I'll just say I was a victim of Trolltech marketing,
that wasn't the impression I got.

2008/10/11 Colin Walters <[EMAIL PROTECTED]>

>
> On Oct 10, 4:42 pm, "Ande Turner" <[EMAIL PROTECTED]> wrote:
> > David,
> > Thank you very much for such an expansive response.  Currently a
> thread-safe
> > Swing alternative is using the Jambi bindings for Qt. I neglected to
> provide
>
> Hmm?  Qt isn't really any more threadsafe than Swing is, or than GTK+
> is:
>
> http://doc.trolltech.com/4.0/threads.html :
> "Although QObject is reentrant, the GUI classes, notably QWidget and
> all its subclasses, are not reentrant. They can only be used from the
> main thread."
>
> GUI programs by their very nature have a large amount of state, and
> the object-oriented paradigm makes a lot of sense.  So back to the
> original question - probably what makes the most sense with Clojure is
> to write nontrivial GUI components in Java, and the interact with your
> GUI code via Clojure's Java integration.
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: regex literal syntax

2008-10-10 Thread Chouser
On Fri, Oct 10, 2008 at 7:48 AM, Chouser <[EMAIL PROTECTED]> wrote:
>
> Of course that means I need to do this for you when printing...

I've attached an updated patch with a new print method, against the
latest SVN 1058.

If you really want to dig into the ugliness, here's a test I've been
using.  Apply the attached patch, rebuild clojure, and then load up
this code:

(import '(java.util.regex Pattern)
'(java.io PushbackReader StringReader))
(defn test-re [s & [ts]]
  (let [p1 (Pattern/compile s)
p2 (read (PushbackReader. (StringReader. (prn-str p1]
(println (str "raw str: " s))
(print   (str "prn1:  " (prn-str p1)))
(print   (str "prn2:  " (prn-str p2)))
(println (if (= (prn-str p1) (prn-str p2)) "PASS" "FAIL"))
(when ts
  (println (str "match1: " (re-find p1 ts)))
  (println (str "match2: " (re-find p2 ts)))
  (println (if (= (re-find p1 ts) (re-find p2 ts)) "PASS" "FAIL")))
(println)))

You run it by passing in a string to be compiled by Pattern.  This is
essentially the "old format" without the leading # char:

user=> (test-re "foo")
raw str: foo
prn1:  #"foo"
prn2:  #"foo"
PASS

If my print method is correct, prn1 and prn2 should always be the
same, and thus PASS.  Also what you're seeing there is the "new
format".  In this case, both the old and new formats are the same.

If you pass in an optional second string, test-re will try to match it
with both patterns:

user=> (test-re "a \\\"\\w*\\\" please" "a \"word\" please")
raw str: a \"\w*\" please
prn1:  #"a \"\w*\" please"
prn2:  #"a \"\w*\" please"
PASS
match1: a "word" please
match2: a "word" please
PASS

Again, if my patch if my patch is correct, match1 and match2 should be
the same, and thus another PASS.  Here you can see how the new format
(prn1 and prn2) are simpler than the old format, as well as being
identical to what Pattern actually operates on (raw str).

Here's a truly nasty example prompted by Christophe Grand's comment:

user=> (test-re "a\"\\Qb\"c\\d\\Ee\"f" "a\"b\"c\\de\"f")
raw str: a"\Qb"c\d\Ee"f
prn1:  #"a\"\Qb\E\"\Qc\d\Ee\"f"
prn2:  #"a\"\Qb\E\"\Qc\d\Ee\"f"
PASS
match1: a"b"c\de"f
match2: a"b"c\de"f
PASS

If you can find *any* input that produces FAIL, please let me know.

--Chouser

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---

diff --git a/src/clj/clojure/boot.clj b/src/clj/clojure/boot.clj
index 7fd1a22..2f95fc4 100644
--- a/src/clj/clojure/boot.clj
+++ b/src/clj/clojure/boot.clj
@@ -3536,6 +3536,24 @@
   (.write w "M"))
 
 (defmethod print-method java.util.regex.Pattern [p #^Writer w]
-  (.append w \#)
-  (print-method (str p) w))
+  (.write w "#\"")
+  (loop [[#^Character c & r :as s] (seq (.pattern #^java.util.regex.Pattern p))
+ qmode false]
+(when s
+  (cond
+(= c \\) (let [[#^Character c2 & r2] r]
+   (.append w \\)
+   (.append w c2)
+   (if qmode
+  (recur r2 (not= c2 \E))
+  (recur r2 (= c2 \Q
+(= c \") (do
+   (if qmode
+ (.write w "\\E\\\"\\Q")
+ (.write w "\\\""))
+   (recur r qmode))
+:else(do
+   (.append w c)
+   (recur r qmode)
+  (.append w \"))
 
diff --git a/src/jvm/clojure/lang/LispReader.java b/src/jvm/clojure/lang/LispReader.java
index d4d03f8..b0caf38 100644
--- a/src/jvm/clojure/lang/LispReader.java
+++ b/src/jvm/clojure/lang/LispReader.java
@@ -359,8 +359,22 @@ static class RegexReader extends AFn{
 	static StringReader stringrdr = new StringReader();
 
 	public Object invoke(Object reader, Object doublequote) throws Exception{
-		String str = (String) stringrdr.invoke(reader, doublequote);
-		return Pattern.compile(str);
+		StringBuilder sb = new StringBuilder();
+		Reader r = (Reader) reader;
+		for(int ch = r.read(); ch != '"'; ch = r.read())
+			{
+			if(ch == -1)
+throw new Exception("EOF while reading regex");
+			sb.append( (char) ch );
+			if(ch == '\\')	//escape
+{
+ch = r.read();
+if(ch == -1)
+	throw new Exception("EOF while reading regex");
+sb.append( (char) ch ) ;
+}
+			}
+		return Pattern.compile(sb.toString());
 	}
 }
 


Re: GUIs in Clojure

2008-10-10 Thread Ande Turner
David,
Thank you very much for such an expansive response.  Currently a thread-safe
Swing alternative is using the Jambi bindings for Qt. I neglected to provide
a link to details before so here it is:

http://doc.trolltech.com/qtjambi-4.4/html/com/trolltech/qt/qtjambi-index.html
Although this solution does add a layer of uncertainty, and may not warrant
the installation hassles.  Personally, I rarely do GUI work, but I intend to
do alot very soon.  Since my last post I communicated with a guy at Sun
specifically about AWT, and now, for purely academic purposes, I will be
writing an AWT & Swing replacement utilising XToolkit bound to a modified
Xlib with Solaris being the target system.  (phew, try and say that ten
times fast)  Perhaps its needless to say, but the project it will have a
rather esoteric approach.  Anyways, I hope to have the design finished by
New Years.  Thanks again David for your response.

Cheers,
Ande

2008/10/11 David Powell <[EMAIL PROTECTED]>

>
>
> > I'm just delving into the details of how Swing is implemented at
> > the moment, can't say I agree with half of the "design" decisions
> > myself.  Swing isn't thread safe, although AWT is to my knowledge,
>
> Actually, AWT isn't thread-safe either. Documentation about the fact
> seems pretty hard to find. From what I can gather, in Java 1.1, AWT
> claimed to be thread-safe, but there were problems with races and
> deadlocks, therefore in Java 1.2 and above AWT doesn't claim to be
> thread-safe. AWT does seem to mostly work if you call it from multiple
> threads.
>
> Some discussion here:
>
>
> http://www.elharo.com/blog/software-development/java/2006/11/10/awt-on-the-event-dispatch-thread/
>
> A brief official reference here:
>
>
> http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/applet-compatibility.html
>
> Also here:
>
>
> http://web.archive.org/web/20060816013814/http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
>
>
>
> There's some more info here about why multi-threaded GUI toolkits
> aren't such a good idea:
>
> http://weblogs.java.net/blog/kgh/archive/2004/10/multithreaded_t.html
>
> Restricting GUI objects to only work from one thread is done so that
> they don't need to use locking, which makes them faster and less prone
> to bugs. Lots of GUI toolkits do this, eg: Win32, .NET, SWT. Allowing
> objects to be accessed from multiple threads makes things slightly
> easier for clients, but isn't really going to improve performance.
>
> Swing does have some annoying aspects of its design (its fake platform
> UI isn't all that convincing), but I don't think that the
> single-threaded access model is that bad a thing.
>
> --
> Dave
>
>
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Formatted printing?

2008-10-10 Thread Paul Stadig
I have a "database" that I'm working with that I'm loading using

(def *db* (load-file "path-to-file/db.clj"))

and saving using by basically opening a PrintWriter and using (pr-str *db*).
The output to the file is a clojure data structure, but it is all on one
line. Is there any existing code for printing out in a formatted way with
new lines and indents and such?


Paul

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: help a journalist: why Clojure?

2008-10-10 Thread estherschindler

Actually, you guys gave me just what I needed. I don't think I have to
ask for more!

On Oct 10, 10:37 am, "John Hodge" <[EMAIL PROTECTED]> wrote:
> It would be best to ask Rich Hickey.  I could try to distill what Rich says
> in the Rationale, but it would be better coming from him.
>
> On Fri, Oct 10, 2008 at 8:32 AM, estherschindler
> <[EMAIL PROTECTED]>wrote:
>
>
>
> > I'm doing an article for CIO.com on "5 [or whatever] languages that
> > ought to be on your [IT Manager's] radar," and I'd like to include
> > Clojure. I'm looking for a short statement on why it's useful, and why
> > the boss ought to let you use it for enterprise work. Any takers?
>
> > This is meant to be a short-and-sweet article: just its name, URL, a
> > quick formal definition, and then one or two quotes from developers
> > about why they think it's valuable. Imagine that you're trying to
> > convince someone's boss to let you use it. What would you say?
>
> > (This is a follow-up to
>
> >http://www.cio.com/article/446829/PHP_JavaScript_Ruby_Perl_Python_and...
> > in case you care. Some folks pointed out that a few "obvious"
> > languages should have been included. I'm happy to comply.)
>
> > --Esther Schindler
> >  senior online editor, CIO.com
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Get thread local bindings

2008-10-10 Thread Mike Hinchey

swank-clojure has a similar issue, but solved by choosing explicitly
which bindings to keep.  It's usually advised to avoid eval.  Of
course, this only works for threads created by the specific macro.  I
suppose the vec of bindings to keep could be keep in a var to avoid
repetition.

  (dothread-keeping [*out* *ns* *current-connection* *warn-on-
reflection*]
 ...)

See dothread-keeping in 
http://github.com/jochu/swank-clojure/tree/master/swank/util/concurrent/thread/thread.clj
And keep-bindings in 
http://github.com/jochu/swank-clojure/tree/master/swank/util/util.clj

-Mike

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Trying to run Clojure with Slime...

2008-10-10 Thread Mike Hinchey

Get the clojure from today.  That error happened yesterday.

-Mike

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Get thread local bindings

2008-10-10 Thread ntupel

I still try to find a way to make threads inherit thread-local
bindings established via binding in the parent thread. I searched for
a function to get the thread bindings but couldn't find one. Did I
miss anything? So I added getThreadBindings() to Var.java:

diff --git a/trunk/src/jvm/clojure/lang/Var.java
b/trunk/src/jvm/clojure/lang/Var.java
index fcbd746..59825a5 100644
--- a/trunk/src/jvm/clojure/lang/Var.java
+++ b/trunk/src/jvm/clojure/lang/Var.java
@@ -282,6 +282,18 @@ public static void releaseThreadBindings(){
dvals.set(null);
 }

+public static Associative getThreadBindings(){
+   Frame f = dvals.get();
+Associative vars = PersistentHashMap.EMPTY;
+   for(ISeq bs = RT.keys(f.frameBindings); bs != null; bs = bs.rest())
+   {
+   Var v = (Var) bs.first();
+if (v.sym != null)
+   vars = vars.assoc(v.sym, v);
+   }
+   return vars;
+}
+
 final Box getThreadBinding(){
if(count.get() > 0)
{

and with the following two functions I can finally inherit thread
local bindings.

(defn bindings []
  "Return key-value list of thread-local bindings."
  (reduce
(fn [env [n v]] (conj env n (var-get v)))
[]
(clojure.lang.Var/getThreadBindings)))

(defmacro on-thread
  "Apply the given function on another thread,
  optionally with the given bindings."
  ([f]
`(let [env# (bindings)]
   (eval `(on-thread ~env# ~~f
  ([env f]
`(doto (new Thread #(binding ~env (~f))) (start



user=> (def x)
#'user/x
user=> (doto (new Thread #(prn (bindings))) (start))
Thread[Thread-0,5,main]
user=> []
user=> (binding [x 12] (on-thread #(prn x)))
12
Thread[Thread-2,5,]
user=>


Not sure if the on-thread macro is kosher. Anyway, would it be
possible to add something like getThreadBindings to Var.java or point
out the right way to get the thread-local bindings?

Thanks,
nt

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Trying to run Clojure with Slime...

2008-10-10 Thread Tayssir John Gabbour

Hi!

When I attempt to run Slime, this error pops up in *inferior-lisp*:

user=> java.lang.UnsupportedOperationException: Vars are not values
(basic.clj:12)
user=> java.lang.Exception: No such var: swank/ignore-protocol-version
(NO_SOURCE_FILE:5)
user=> java.lang.Exception: No such var: swank/start-server
(NO_SOURCE_FILE:7)


Here's my .emacs changes:

(pushnew "/Users/blah/Apps/emacs/jochu-clojure-mode" load-path)
(require 'clojure-auto)
(require 'clojure-paredit)
(pushnew "/Users/blah/Apps/emacs/temp/slime/" load-path)
(pushnew  "/Users/blah/Apps/emacs/jochu-swank-clojure" load-path)
(setq swank-clojure-jar-path "/Users/blah/Apps/clojure/target/clojure-
lang-1.0-SNAPSHOT.jar")
(require 'swank-clojure-autoload)


Any clue? I have the newest cvs Slime and downloaded Clojure a couple
days ago. I'm running on MacOS X.


Thanks!
Tayssir

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Casting java arguments...

2008-10-10 Thread Michael Wood

On Fri, Oct 10, 2008 at 11:45 AM, mritun <[EMAIL PROTECTED]> wrote:
>
> On Oct 10, 1:46 am, Luc Prefontaine <[EMAIL PROTECTED]>
> wrote:
[...]
>> The mysql jdbc driver code says that it registers itself (static block)
>> but something is wrong.
>> Eventually I will find why but now I have other pressing needs to full
>> fill than debugging that code.
>
> Static blocks don't execute until the class is loaded, so just
> specifying a class in classpath is not enough.
>
> In Java the idiomatic way to let the driver initialize itself, is to
> add the following line somewhere in your initialization code before
> requesting connection:
>
> Class.forName("com.mysql.jdbc.Driver");
>
> This loads the class, and its static block registers the driver. You'd
> have to do an equivalent in clojure too.

How about this then (as hinted at by Stuart Halloway):

user=> (enumeration-seq (. java.sql.DriverManager getDrivers))
nil
user=> (java.sql.DriverManager/registerDriver
  (.newInstance (clojure.lang.RT/classForName "com.mysql.jdbc.Driver")))
nil
user=> (enumeration-seq (. java.sql.DriverManager getDrivers))
([EMAIL PROTECTED] [EMAIL PROTECTED])

-- 
Michael Wood <[EMAIL PROTECTED]>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: two dimensional arrays

2008-10-10 Thread Martin DeMello

On Oct 9, 12:29 pm, "Mark H." <[EMAIL PROTECTED]> wrote:
> a mapping.  However, if you find yourself doing this a lot, you might
> want to think about a more Clojure-like idiom that doesn't require
> destructive updates and minimizes consing for local changes (e.g., a
> quadtree).

Interesting idea, but typical operations will be iterating along the
cells in a given row or column, so a 2d doubly-linked list would
probably work better than any sort of space-partitioning tree. But
then I lose easy random access to a cell. Vector(-of-vectors) and {[x
y] => cell} do seem like my best bets here.

martin
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: help a journalist: why Clojure?

2008-10-10 Thread John Hodge
It would be best to ask Rich Hickey.  I could try to distill what Rich says
in the Rationale, but it would be better coming from him.

On Fri, Oct 10, 2008 at 8:32 AM, estherschindler
<[EMAIL PROTECTED]>wrote:

>
> I'm doing an article for CIO.com on "5 [or whatever] languages that
> ought to be on your [IT Manager's] radar," and I'd like to include
> Clojure. I'm looking for a short statement on why it's useful, and why
> the boss ought to let you use it for enterprise work. Any takers?
>
> This is meant to be a short-and-sweet article: just its name, URL, a
> quick formal definition, and then one or two quotes from developers
> about why they think it's valuable. Imagine that you're trying to
> convince someone's boss to let you use it. What would you say?
>
> (This is a follow-up to
>
> http://www.cio.com/article/446829/PHP_JavaScript_Ruby_Perl_Python_and_Tcl_Today_The_State_of_the_Scripting_Universe
> in case you care. Some folks pointed out that a few "obvious"
> languages should have been included. I'm happy to comply.)
>
> --Esther Schindler
>  senior online editor, CIO.com
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: help a journalist: why Clojure?

2008-10-10 Thread .Bill Smith

Java is a great language but the programming community has matured
beyond what Java provides.  At the same time, the Java community has a
huge collection of mature class libraries.  Clojure interoperates with
those class libraries in a seamless way, much better than other JVM-
based languages I've worked with.  At the same time, it is much more
expressive than Java.  I can describe what I want to do in Clojure
more succinctly than in Java without losing flexibility.

I think the biggest initial complaint about Clojure will be "too many
parentheses". Once you get used to the Lisp syntax, though, you'll
find Clojure is a delight to work with.

Bill

On Oct 10, 7:32 am, estherschindler <[EMAIL PROTECTED]> wrote:
> I'm doing an article for CIO.com on "5 [or whatever] languages that
> ought to be on your [IT Manager's] radar," and I'd like to include
> Clojure. I'm looking for a short statement on why it's useful, and why
> the boss ought to let you use it for enterprise work. Any takers?
>
> This is meant to be a short-and-sweet article: just its name, URL, a
> quick formal definition, and then one or two quotes from developers
> about why they think it's valuable. Imagine that you're trying to
> convince someone's boss to let you use it. What would you say?
>
> (This is a follow-up 
> tohttp://www.cio.com/article/446829/PHP_JavaScript_Ruby_Perl_Python_and...
> in case you care. Some folks pointed out that a few "obvious"
> languages should have been included. I'm happy to comply.)
>
> --Esther Schindler
>   senior online editor, CIO.com
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: ANN: Clojure book

2008-10-10 Thread Raoul Duke

hi Stuart,

A book sounds great! Thank you for taking on such a project for the community :)

I'd be very interested in reviewing. Even more usefully for you, I
would suggest hooking up with the Silicon Valley Patterns group which
Russ and Tracy lead (although I haven't been attending recently due to
a new kid in the family). SVP is a pretty star-studded group of people
as far as I can tell, all experienced and smart, and they've already
been involved in reviewing several other pretty high-profile books
(Scala, C++, etc.) so they know what they are doing.

sincerely.

On Fri, Oct 10, 2008 at 8:53 AM, Stuart Halloway
<[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I am working on what I hope will become the first Clojure book in print:
>
> http://www.pragprog.com/titles/shcloj/programming-clojure
>
> If you are interested in being a reviewer please let me know off-list.
>
> Regards,
> Stuart
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: error in slime with svn 1057

2008-10-10 Thread Mike Hinchey

fixed in svn 1058. Thanks.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Bug in r1057? Var reader macros in syntax quotes

2008-10-10 Thread Perry

Not sure exactly how this is related, but r1058 still gives me the
following error that popped up after r1057. Compojure defines this
macro:

(defmacro redef
  "Redefine an existing value, keeping the metadata intact."
  [name value]
  `(let [m# (meta #'~name)
 v# (def ~name ~value)]
 (.setMeta v# (merge m# (meta #'~name)))
 v#))

& when it's read it produces this exception:

 java.lang.ClassCastException: clojure.lang.LispReader$Unquote
cannot be cast to clojure.lang.Symbol

As the messages says, the nut seems to be that the ~name in `(#'~name)
evaluates to an unquote, instead of a symbol (as it must've before).

Best,
Perry


On Oct 10, 9:50 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
> On Oct 10, 6:03 am, Achim Passen <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi!
>
> > There seems to be a problem with the new LispReader$VarReader:
>
> > ; r1057
> > user=> `#'clojure/doc
> > java.lang.UnsupportedOperationException: Vars are not values
> > (NO_SOURCE_FILE:0)
>
> > ; r1056
> > user=> `#'clojure/doc
> > (var clojure/doc)
>
> > This only happens for bound Vars, which are no longer wrapped when
> > read.
>
> Fixed - thanks for the report,
>
> Rich

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



ANN: Clojure book

2008-10-10 Thread Stuart Halloway

Hi all,

I am working on what I hope will become the first Clojure book in print:

http://www.pragprog.com/titles/shcloj/programming-clojure

If you are interested in being a reviewer please let me know off-list.

Regards,
Stuart

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Bug in r1057? Var reader macros in syntax quotes

2008-10-10 Thread Rich Hickey



On Oct 10, 6:03 am, Achim Passen <[EMAIL PROTECTED]> wrote:
> Hi!
>
> There seems to be a problem with the new LispReader$VarReader:
>
> ; r1057
> user=> `#'clojure/doc
> java.lang.UnsupportedOperationException: Vars are not values
> (NO_SOURCE_FILE:0)
>
> ; r1056
> user=> `#'clojure/doc
> (var clojure/doc)
>
> This only happens for bound Vars, which are no longer wrapped when
> read.
>

Fixed - thanks for the report,

Rich

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: help a journalist: why Clojure?

2008-10-10 Thread estherschindler

That's *perfectly* pithy!

On Oct 10, 6:41 am, Chouser <[EMAIL PROTECTED]> wrote:
> On Fri, Oct 10, 2008 at 8:32 AM, estherschindler
>
> <[EMAIL PROTECTED]> wrote:
>
> > This is meant to be a short-and-sweet article: just its name, URL, a
> > quick formal definition, and then one or two quotes from developers
> > about why they think it's valuable. Imagine that you're trying to
> > convince someone's boss to let you use it. What would you say?
>
> So, not reasons why a developer who doesn't know Clojure should try
> it, but rather what a developer who already wants to use Clojure might
> say to convince management?  Interesting.
>
> How about: Clojure is a small, powerful language that compiles and
> runs on the JVM, so no new infrastructure.  Plus is lets you get more
> done with less code, which is good for development schedules and
> maintenance.  It's particularly good at taking advantage of multicore
> hardware without as much programmer overhead as Java.
>
> Maybe not quite a pithy as you want, but you're the journalist -- you
> can edit it down, right? :-)
>
> --Chouser
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: help a journalist: why Clojure?

2008-10-10 Thread Stuart Halloway

Clojure:

- Reach and performance of Java
- Elegance of Ruby*
- Scales like nothing else**

*Lisp would be more accurate than Ruby, but managers have probably  
been hearing more about Ruby than Lisp.
** (Functional Programming + Software Transactional Memory) =  
Multicore applications programmed by real humans.

I am nominally a pointy-headed boss and I am already convinced.

Stuart Halloway
CEO
Relevance, Inc.

> I'm doing an article for CIO.com on "5 [or whatever] languages that
> ought to be on your [IT Manager's] radar," and I'd like to include
> Clojure. I'm looking for a short statement on why it's useful, and why
> the boss ought to let you use it for enterprise work. Any takers?
>
> This is meant to be a short-and-sweet article: just its name, URL, a
> quick formal definition, and then one or two quotes from developers
> about why they think it's valuable. Imagine that you're trying to
> convince someone's boss to let you use it. What would you say?
>
> (This is a follow-up to
> http://www.cio.com/article/446829/PHP_JavaScript_Ruby_Perl_Python_and_Tcl_Today_The_State_of_the_Scripting_Universe
> in case you care. Some folks pointed out that a few "obvious"
> languages should have been included. I'm happy to comply.)
>
> --Esther Schindler
>  senior online editor, CIO.com
>
> >


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: help a journalist: why Clojure?

2008-10-10 Thread Chouser

On Fri, Oct 10, 2008 at 8:32 AM, estherschindler
<[EMAIL PROTECTED]> wrote:
>
> This is meant to be a short-and-sweet article: just its name, URL, a
> quick formal definition, and then one or two quotes from developers
> about why they think it's valuable. Imagine that you're trying to
> convince someone's boss to let you use it. What would you say?

So, not reasons why a developer who doesn't know Clojure should try
it, but rather what a developer who already wants to use Clojure might
say to convince management?  Interesting.

How about: Clojure is a small, powerful language that compiles and
runs on the JVM, so no new infrastructure.  Plus is lets you get more
done with less code, which is good for development schedules and
maintenance.  It's particularly good at taking advantage of multicore
hardware without as much programmer overhead as Java.

Maybe not quite a pithy as you want, but you're the journalist -- you
can edit it down, right? :-)

--Chouser

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: help a journalist: why Clojure?

2008-10-10 Thread J. McConnell

My "try to sell it to someone's boss approach":

The most pressing issue in software development today is how to better
take advantage of multi-core CPU's to increase performance and reduce
energy costs. Clojure provides a fundamentally better approach (in
terms of ease and safety) to concurrency than other languages out
there. Its Lisp heritage gives it the power to greatly increase
programmer productivity in a way that grows over time and to enable
easy DSL creation to allow business owners to verify the correctness
of programs. The fact that it runs on the JVM and can smoothly
integrate with the millions of lines of legacy Java code are just
icing on a very tall cake.

Like Chouser, I'm going to avoid trying to shorten it much, but hope
you find it helpful.

- J.

On Fri, Oct 10, 2008 at 8:32 AM, estherschindler
<[EMAIL PROTECTED]> wrote:
>
> I'm doing an article for CIO.com on "5 [or whatever] languages that
> ought to be on your [IT Manager's] radar," and I'd like to include
> Clojure. I'm looking for a short statement on why it's useful, and why
> the boss ought to let you use it for enterprise work. Any takers?
>
> This is meant to be a short-and-sweet article: just its name, URL, a
> quick formal definition, and then one or two quotes from developers
> about why they think it's valuable. Imagine that you're trying to
> convince someone's boss to let you use it. What would you say?
>
> (This is a follow-up to
> http://www.cio.com/article/446829/PHP_JavaScript_Ruby_Perl_Python_and_Tcl_Today_The_State_of_the_Scripting_Universe
> in case you care. Some folks pointed out that a few "obvious"
> languages should have been included. I'm happy to comply.)
>
> --Esther Schindler
>  senior online editor, CIO.com
>
> >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: help a journalist: why Clojure?

2008-10-10 Thread Rastislav Kassak

I guess you should emphasize it's Lisp thus it has unbelievable long
term compressibility of code thanks to macros and metaprogramming.
However, it's still 1st class JVM citizen so seamlessly integrable
with Java EE technologies and that other java stuff running today.

It's exactly the reason I like Clojure.


On 10/10/08, estherschindler <[EMAIL PROTECTED]> wrote:
>
>  I'm doing an article for CIO.com on "5 [or whatever] languages that
>  ought to be on your [IT Manager's] radar," and I'd like to include
>  Clojure. I'm looking for a short statement on why it's useful, and why
>  the boss ought to let you use it for enterprise work. Any takers?
>
>  This is meant to be a short-and-sweet article: just its name, URL, a
>  quick formal definition, and then one or two quotes from developers
>  about why they think it's valuable. Imagine that you're trying to
>  convince someone's boss to let you use it. What would you say?
>
>  (This is a follow-up to
>  
> http://www.cio.com/article/446829/PHP_JavaScript_Ruby_Perl_Python_and_Tcl_Today_The_State_of_the_Scripting_Universe
>  in case you care. Some folks pointed out that a few "obvious"
>  languages should have been included. I'm happy to comply.)
>
>  --Esther Schindler
>   senior online editor, CIO.com
>
>  >
>

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: GUIs in Clojure

2008-10-10 Thread David Powell


> I'm just delving into the details of how Swing is implemented at
> the moment, can't say I agree with half of the "design" decisions
> myself.  Swing isn't thread safe, although AWT is to my knowledge,

Actually, AWT isn't thread-safe either. Documentation about the fact
seems pretty hard to find. From what I can gather, in Java 1.1, AWT
claimed to be thread-safe, but there were problems with races and
deadlocks, therefore in Java 1.2 and above AWT doesn't claim to be
thread-safe. AWT does seem to mostly work if you call it from multiple
threads.

Some discussion here:

http://www.elharo.com/blog/software-development/java/2006/11/10/awt-on-the-event-dispatch-thread/

A brief official reference here:

http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/applet-compatibility.html

Also here:

http://web.archive.org/web/20060816013814/http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html



There's some more info here about why multi-threaded GUI toolkits
aren't such a good idea:

http://weblogs.java.net/blog/kgh/archive/2004/10/multithreaded_t.html

Restricting GUI objects to only work from one thread is done so that
they don't need to use locking, which makes them faster and less prone
to bugs. Lots of GUI toolkits do this, eg: Win32, .NET, SWT. Allowing
objects to be accessed from multiple threads makes things slightly
easier for clients, but isn't really going to improve performance.

Swing does have some annoying aspects of its design (its fake platform
UI isn't all that convincing), but I don't think that the
single-threaded access model is that bad a thing.

-- 
Dave



--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



help a journalist: why Clojure?

2008-10-10 Thread estherschindler

I'm doing an article for CIO.com on "5 [or whatever] languages that
ought to be on your [IT Manager's] radar," and I'd like to include
Clojure. I'm looking for a short statement on why it's useful, and why
the boss ought to let you use it for enterprise work. Any takers?

This is meant to be a short-and-sweet article: just its name, URL, a
quick formal definition, and then one or two quotes from developers
about why they think it's valuable. Imagine that you're trying to
convince someone's boss to let you use it. What would you say?

(This is a follow-up to
http://www.cio.com/article/446829/PHP_JavaScript_Ruby_Perl_Python_and_Tcl_Today_The_State_of_the_Scripting_Universe
in case you care. Some folks pointed out that a few "obvious"
languages should have been included. I'm happy to comply.)

--Esther Schindler
  senior online editor, CIO.com

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: regex literal syntax

2008-10-10 Thread Chouser

On Fri, Oct 10, 2008 at 4:07 AM, Christophe Grand <[EMAIL PROTECTED]> wrote:
>
> Hello Chouser, (btw, nice work you are doing with ClojureScript)

Thanks -- good to see you around again!

> Do you plan to support printing of all Pattern instances or only those
> created using the new literal syntax? In the first case, the story gets
> more complex with \Q, \E and flags. In the second case, that's fine.

I think I need to support all Patterns, and you're right I haven't
thought sufficiently about \Q and \E.

Interestingly, I don't think there's any way to get a plain
double-quote into a regex after a \Q under the proposal.  I don't
*think* that's a problem, as you're most likely to use \Q when
building a pattern programmatically, and if you're not you can drop
out of \Q mode to get your " in there.

If anyone disagrees with this conclusion, speak up!

Of course that means I need to do this for you when printing...

--Chouser

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Bug in r1057? Var reader macros in syntax quotes

2008-10-10 Thread Achim Passen

Hi!

There seems to be a problem with the new LispReader$VarReader:

; r1057
user=> `#'clojure/doc
java.lang.UnsupportedOperationException: Vars are not values
(NO_SOURCE_FILE:0)

; r1056
user=> `#'clojure/doc
(var clojure/doc)

This only happens for bound Vars, which are no longer wrapped when
read.

This is related to: 
http://groups.google.com/group/clojure/browse_thread/thread/1b25bc3181a54054?pli=1

Kind regards,
achim
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: "if" small syntax change proposal

2008-10-10 Thread Jeff V

The current cond does allow "else" behavior. It's done using a final test that 
evaluates to something non-false and non-nil, such as the keyword :else.

That said, the proposed arc/newlisp style if macro would be more tidy.

Jeff

- Original Message -
From: James Reeves <[EMAIL PROTECTED]>
Sent: Friday 10 October 2008 03:59
To: Clojure 
Cc: 
Subject: Re: "if" small syntax change proposal

> 
> On Oct 9, 10:29 pm, Dmitri P <[EMAIL PROTECTED]> wrote:
> > Allow cond-like specification of expression pairs and allow odd number
> > of expressions. Let odd expressions in last position serve as default
> > return value. There will be no impact on previous reading/writing of
> > "if". Stolen from Paul Graham's Arc.
> >
> > (defmacro myif
> > ([x] x)
> > ([x] (if x y))
> > ([x y & z] (if x y `(myif [EMAIL PROTECTED]
> 
> This seems like a sound idea. It eliminates the need to have a
> separate cond macro, and supports an ending "else" statement, which I
> believe is something cond lacks.
> 
> - James
> > 
> 




--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Casting java arguments...

2008-10-10 Thread mritun



On Oct 10, 1:46 am, Luc Prefontaine <[EMAIL PROTECTED]>
wrote:
> I found a workaround...
>
> I was able to register the driver using
> -Djdbc.drivers=com.mysql.jdbc.Driver on the java command line.
> Looks like loading the class is not enough, adding the above does work:
>
> user=> (enumeration-seq (. java.sql.DriverManager getDrivers))
> ([EMAIL PROTECTED] [EMAIL PROTECTED])
>
> The mysql jdbc driver code says that it registers itself (static block)
> but something is wrong.
> Eventually I will find why but now I have other pressing needs to full
> fill than debugging that code.

Static blocks don't execute until the class is loaded, so just
specifying a class in classpath is not enough.

In Java the idiomatic way to let the driver initialize itself, is to
add the following line somewhere in your initialization code before
requesting connection:

Class.forName("com.mysql.jdbc.Driver");

This loads the class, and its static block registers the driver. You'd
have to do an equivalent in clojure too.

- Akhilesh
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: "if" small syntax change proposal

2008-10-10 Thread James Reeves

On Oct 9, 10:29 pm, Dmitri P <[EMAIL PROTECTED]> wrote:
> Allow cond-like specification of expression pairs and allow odd number
> of expressions. Let odd expressions in last position serve as default
> return value. There will be no impact on previous reading/writing of
> "if". Stolen from Paul Graham's Arc.
>
> (defmacro myif
>         ([x] x)
>         ([x] (if x y))
>         ([x y & z] (if x y `(myif [EMAIL PROTECTED]

This seems like a sound idea. It eliminates the need to have a
separate cond macro, and supports an ending "else" statement, which I
believe is something cond lacks.

- James
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: regex literal syntax

2008-10-10 Thread Christophe Grand

Chouser a écrit :
> On Thu, Oct 9, 2008 at 4:57 PM, Rich Hickey <[EMAIL PROTECTED]> wrote:
>   
>> Go for it.
>> 
>
> (defmethod print-method java.util.regex.Pattern [p #^Writer w]
>   (.write w "#\"")
>   (loop [[#^Character c & r :as s] (seq (.pattern #^java.util.regex.Pattern 
> p))]
> (when s
>   (cond
> (= c \\) (do (.append w \\)
>  (.append w #^Character (first r))
>  (recur (rest r)))
> (= c \") (do (.write w "\\\"")
>  (recur r))
> :else(do (.append w c)
>  (recur r)
>   (.append w \"))
>
> --Chouser
>   
Hello Chouser, (btw, nice work you are doing with ClojureScript)

Do you plan to support printing of all Pattern instances or only those 
created using the new literal syntax? In the first case, the story gets 
more complex with \Q, \E and flags. In the second case, that's fine.

Christophe


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---