Re: eval in macro: No method for dispatch value

2008-12-03 Thread Michiel de Mare

This has nothing to do with eval. The following fails too:

(defmacro foo [] (new StringBuffer))
(foo)


On Dec 3, 3:22 am, Stuart Halloway <[EMAIL PROTECTED]> wrote:
> Hi Michiel,
>
> eval is for form data, so I am more surprised that it works for  
> ArrayList than that it fails for StringBuffer.

>
> Stu
>
> > After playing around with macros, I ran into this problem with Clojure
> > (the latest version from github). The following code throws an
> > IllegalArgumentException: "No method for dispatch value: class
> > java.lang.StringBuffer"
>
> > (defmacro wrap [h] (eval h))
> > (wrap (new StringBuffer))
>
> > But this works fine:
>
> > (eval (new StringBuffer))
>
> > Apparently this fails for StringBuffers, but not for Strings or
> > ArrayLists. I'm not sure if this is a bug, or what the underlying
> > rules here are. At the very least the error message is ... unhelpful.
> > I hope that somebody can shine a light on this.
>
> > Cheers,
>
> > Michiel
--~--~-~--~~~---~--~~
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: eval in macro: No method for dispatch value

2008-12-03 Thread Meikel Brandmeyer

Hi,

On 3 Dez., 12:04, Michiel de Mare <[EMAIL PROTECTED]> wrote:
> This has nothing to do with eval. The following fails too:
>
> (defmacro foo [] (new StringBuffer))
> (foo)

The results at the Repl are printed via pr-on and
obviously print-dup doesn't know how to print a
StringBuffer.

Sincerely
Meikel


--~--~-~--~~~---~--~~
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: eval in macro: No method for dispatch value

2008-12-03 Thread Michiel de Mare

Indeed, (print-dup (new StringBuffer) (new java.io.StringWriter))
throws the same exception.
But (new StringBuffer) in the REPL prints the stringbuffer just fine.

Why does the exception only get triggered in macros?

And doesn't print-dup need a default for unknown classes?

On Dec 3, 12:23 pm, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On 3 Dez., 12:04, Michiel de Mare <[EMAIL PROTECTED]> wrote:
>
> > This has nothing to do with eval. The following fails too:
>
> > (defmacro foo [] (new StringBuffer))
> > (foo)
>
> The results at the Repl are printed via pr-on and
> obviously print-dup doesn't know how to print a
> StringBuffer.
>
> Sincerely
> Meikel
--~--~-~--~~~---~--~~
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: Serializing Clojure objects

2008-12-03 Thread Rich Hickey
On Tue, Dec 2, 2008 at 6:38 PM, Chouser <[EMAIL PROTECTED]> wrote:

>
> On Tue, Dec 2, 2008 at 3:52 PM, Mark Volkmann <[EMAIL PROTECTED]>
> wrote:
> >
> > (def my-string (print-dup [1 2 3]))
> > (def my-data (read my-string))
> >
> > Can you give a simple example of serializing and deserializing a
> > Clojure collection?
>
> For "serializing" you have a couple options:
> (def my-string (binding [*print-dup* true] (pr-str [1 2 3])))
> (def my-string (with-out-str (print-dup [1 2 3] *out*)))
>
> I don't know which is "better".


The former (binding *print-dup*) is better and the only way to ensure things
work correctly in aggregates.

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
-~--~~~~--~~--~--~---



Bug + Post: load failure (depending on file URL)

2008-12-03 Thread ninix

Since SVN rev 1094:

RT.lastModified fails when the file is not a jar: or file: URL (for
example when it is a bundleresource: URL in an eclipse plugin).
With the patch the fallback in this case is to load the source file.

http://groups.google.com/group/clojure/web/load_lastModified.patch

--~--~-~--~~~---~--~~
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: Supporting protected fields in genclass

2008-12-03 Thread Rich Hickey
On Tue, Dec 2, 2008 at 10:40 PM, Matt Revelle <[EMAIL PROTECTED]> wrote:

> Updated patch attached, the extra let for readability looked ugly to
> me after some sleep.
>
>
> >
>
>
>
>
> On Dec 1, 2008, at 3:44 PM, Rich Hickey wrote:
>
> >
> >
> >
> > On Dec 1, 2:57 pm, Matt Revelle <[EMAIL PROTECTED]> wrote:
> >> Yes, this again.  Now that we have AOT, I wanted to revisit
> >> supporting
> >> the exposing of inherited protected fields that originate from
> >> farther
> >> up the hierarchy chain than the super class.
> >>
> >> Attached is a patch against SVN revision 1133.
> >>
> >> I promise to never bring this up again.  =)
> >>
> >> -Matt
> >>
> >
> > I'm glad you did. There were a couple of enhancements that got delayed
> > in the AOT process.
> >
> > As far as the patch, I'd prefer not to have any logic that uses
> > exceptions as part of normal flow control (i.e. calling
> > getDeclaredField and eating the exception), so could you please define
> > in terms of getDeclaredFields instead?
> >
> > Thanks,
> >
> > 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]<[EMAIL PROTECTED]>
> > For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> > -~--~~~~--~~--~--~---
> >
>

Patch applied (svn 1141) - thanks!

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: slime+clojure problem

2008-12-03 Thread Dimitre Liotev

Peter Eddy wrote:
>> How are you attempting to start slime? Are you doing:
>>
>> 1. C-u M-x slime RET clojure RET
>>
>> OR
>>
>> 2. M-- M-x slime RET clojure RET
>> 
>
> Well, either method caused this error for me. I deleted all my slime
> and clojure-related source trees and re-checked everything out again
> (taking advantage to organize everything a little better this time
> around), but same problem.
>
> So I backed up my .emacs and then got rid of all configuration for the
> other lisps I was using (clisp, openmcl and sbcl) and now I can
> successfully start slime for clojure.
>
> I'll eventually re-add the config I removed and try to find what it
> was that broke clojure/slime.
>
> thanks everyone.
>
> - Peter
>   


If you have set "slime-lisp-implementations", make sure the entry for 
clojure looks like this:

(clojure ("clojure") :init swank-clojure-init)

For example, my slime-lisp-implementations is:

   (setq slime-lisp-implementations
 `(
   (sbcl ("sbcl"))
   (ccl ("ccl"))
   (clojure ("clojure") :init swank-clojure-init)
   (clisp ("clisp"))
   (abcl ("abcl"))
   (cmucl ("lisp"))
   (s48 ("scheme48") :init slime48-init-command)



If I specify (clojure ("clojure")) instead of (clojure (clojure") :init 
swank-clojure-init), I get the same error as you.

--
dl


--~--~-~--~~~---~--~~
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: [PATCH] Improved Maven Build

2008-12-03 Thread Rich Hickey
On Wed, Dec 3, 2008 at 1:05 AM, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:

> I've created a patch for the clojure source that does the following:
>
> - Adds a minimal site build, with links to the main Clojure web site
> (http://clojure.org)
> - Generates a source JAR to go with the binary JAR
> - Generates JavaDoc for the project site  (if profile "javadoc" is enabled)
> - Adds a Maven profile, "ci", for a nightly continuous integration
> build, to deploy Maven artifacts to a local Maven repository
>
> This is based on icky Maven stuff I wrote for Tapestry a year or so ago.
>
> I'm also in the process of revamping tapestry.apache.org to make it
> more of a project hosting site; it will (soon) have Bamboo (continuous
> integration server),
> Confluence (Wiki), JIRA (Issue Tracking) and SVN.  I could set up a
> post-commit and nightly build for Clojure at any time.  This has
> served the Tapestry community quite well, giving people easy access to
> latest-and-greatest snapshots and (JavaDoc) documentation.
>
>
> Note that the clojure-logo.png file must be stored in
> src/site/resources/images.
>
>
Interesting, thanks. I'm left wondering about Maven support.

Maven is not the build system for Clojure, Ant is. Early on, someone who
wanted to use maven contributed a pom.xml, but it can get stale.

Recently, some enhancements made it into build.xml. Are they reflected in
this patch?

Personally, I think the best thing would be to get rid of pom.xml - it just
confuses people as to how to build Clojure, which is:

ant clean
ant

I know people get religious about these build systems, but I just don't have
time for it. Clojure is a tiny, simple thing.

That said, I'd like to hear people's thoughts on how best to have a single
build system of record (Ant) and satisfy Maven users?

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: eval in macro: No method for dispatch value

2008-12-03 Thread Rich Hickey

On Dec 3, 6:58 am, Michiel de Mare <[EMAIL PROTECTED]> wrote:
> Indeed, (print-dup (new StringBuffer) (new java.io.StringWriter))
> throws the same exception.
> But (new StringBuffer) in the REPL prints the stringbuffer just fine.
>
> Why does the exception only get triggered in macros?
>
> And doesn't print-dup need a default for unknown classes?
>
> On Dec 3, 12:23 pm, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > On 3 Dez., 12:04, Michiel de Mare <[EMAIL PROTECTED]> wrote:
>
> > > This has nothing to do with eval. The following fails too:
>
> > > (defmacro foo [] (new StringBuffer))
> > > (foo)
>
> > The results at the Repl are printed via pr-on and
> > obviously print-dup doesn't know how to print a
> > StringBuffer.
>
> > Sincerely
> > Meikel

The purpose of a macro is to transform a form into another form on
behalf of the compiler.

If you want a call to (foo), to become a call to create a new
StringBuilder, you need to return a piece of data that is a call to
new, i.e. a list:

i.e. you want to write this form:

(foo)

you want it to expand into this form, i.e. the list of the symbols
'new and 'StringBuilder:

(new StringBuilder)

And the way to do that is this:

(defmacro foo []
  `(new StringBuilder))

(macroexpand '(foo))
-> (new java.lang.StringBuilder)

But that's not what this does:

(defmacro foo []
  (new StringBuilder))

That turns the list (foo) into a StringBuilder object, and asks the
compiler to compile that StringBuilder object:

(macroexpand '(foo))
-> #

As it says at:

http://clojure.org/evaluation

"Any object other than those discussed above will evaluate to itself."

So what you are asking the compiler to do when asking it to compile a
literal object like that, is to put that object into the compiled
bytecode. It ends up that very few objects can be represented in
bytecode - basically the primitives and Strings. So a language that
allows for literal objects other than those (as does Clojure) needs to
find a way to put them into the bytecode and restore them later.
Clojure does this by representing them as Strings, specifically by
print-duping them and reading them later. Therefor the only objects
that can be literals in code are those that support print-dup.

This has nothing to do with printing objects at the repl - that does
not use print-dup, just print-method.

Unfortunately there is no universally valid default definition for
print-dup. (a default I tried, printing a call to the ctor with the
toString value, works often, but not always). And were the default to
print something that failed at read time, those failures occur during
class static initialization time, where you really want to avoid
errors.

print-dup supports the vast majority of things one would like to treat
as constants in code, with some notable pseudo-value classes like Date
still to come, but embedding a literal StringBuffer in code is most
certainly a mistake.

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: Improved Maven Build

2008-12-03 Thread ivant

On Dec 3, 3:05 pm, "Rich Hickey" <[EMAIL PROTECTED]> wrote:
> On Wed, Dec 3, 2008 at 1:05 AM, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:
>
>
>
> > I've created a patch for the clojure source that does the following:
>
> > - Adds a minimal site build, with links to the main Clojure web site
> > (http://clojure.org)
> > - Generates a source JAR to go with the binary JAR
> > - Generates JavaDoc for the project site  (if profile "javadoc" is enabled)
> > - Adds a Maven profile, "ci", for a nightly continuous integration
> > build, to deploy Maven artifacts to a local Maven repository
>
> > This is based on icky Maven stuff I wrote for Tapestry a year or so ago.
>
> > I'm also in the process of revamping tapestry.apache.org to make it
> > more of a project hosting site; it will (soon) have Bamboo (continuous
> > integration server),
> > Confluence (Wiki), JIRA (Issue Tracking) and SVN.  I could set up a
> > post-commit and nightly build for Clojure at any time.  This has
> > served the Tapestry community quite well, giving people easy access to
> > latest-and-greatest snapshots and (JavaDoc) documentation.
>
> > Note that the clojure-logo.png file must be stored in
> > src/site/resources/images.
>
> Interesting, thanks. I'm left wondering about Maven support.
>
> Maven is not the build system for Clojure, Ant is. Early on, someone who
> wanted to use maven contributed a pom.xml, but it can get stale.
>
> Recently, some enhancements made it into build.xml. Are they reflected in
> this patch?
>
> Personally, I think the best thing would be to get rid of pom.xml - it just
> confuses people as to how to build Clojure, which is:
>
> ant clean
> ant
>
> I know people get religious about these build systems, but I just don't have
> time for it. Clojure is a tiny, simple thing.
>
> That said, I'd like to hear people's thoughts on how best to have a single
> build system of record (Ant) and satisfy Maven users?
>
> Rich

I'm a Maven fan, and I think it'll be good if clojure supports it.
But "support" here can mean different things.  And the minimal
"support" for maven could be to just drop the clojure.jar in public
maven repository.

I see just one possible problem with this scenario: ASM, which clojure
bundles.  If somebody adds clojure and a different version of ASM
things can get hairy.  But that's orthogonal to maven/ant decision.
--~--~-~--~~~---~--~~
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: DISCUSS: replace (rand)

2008-12-03 Thread Christian Vest Hansen

For what it is worth, I implemented (for another project) George
Marsaglias XorShift algorithm (as recommended in Java Concurrency in
Practice) in a thread-safe contention free maner, by making the
thread-id part of the source entropy. This way, two threads will
generate different random numbers from the same seed. And when a
thread see a seed written by another thread, then that is just another
source of entropy.

The implementation has two drawbacks compared java.util.Random:
 * It's a "medium quality" algorithm, whatever that means, and I
_presume_ that whatever is in java.util.Random is high quality. But I
have not had any problems with lack of randomness by the
implementation.
 * If you want to share an instance between threads, then it's _your_
responsibility to guarantee safe publication.

Link: 
http://github.com/karmazilla/nanopool/tree/master/src/main/java/net/nanopool/CheapRandom.java

On Tue, Dec 2, 2008 at 4:25 PM, Lauri Pesonen <[EMAIL PROTECTED]> wrote:
>
> 2008/12/2 Stuart Halloway <[EMAIL PROTECTED]>:
>>
>> Cool, that's much better. Can we establish that all (or all important)
>> Java 5+ VMs use AtomicLong in next?
>
> While compare-and-swap is a lot better than a mutex, it's still not
> free. IIRC a CAS is one (or maybe two) order(s) of magnitude more
> expensive than a normal store. So a non-threadsafe PRNG should still
> give you a performance boost compared to the CAS-version. But, as you said,
> this is all speculation until someone writes some tests...
>
> --
>  ! Lauri
>
> >
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~-~--~~~---~--~~
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: Improved Maven Build

2008-12-03 Thread Rich Hickey



On Dec 3, 9:01 am, ivant <[EMAIL PROTECTED]> wrote:
> On Dec 3, 3:05 pm, "Rich Hickey" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Wed, Dec 3, 2008 at 1:05 AM, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:
>
> > > I've created a patch for the clojure source that does the following:
>
> > > - Adds a minimal site build, with links to the main Clojure web site
> > > (http://clojure.org)
> > > - Generates a source JAR to go with the binary JAR
> > > - Generates JavaDoc for the project site  (if profile "javadoc" is 
> > > enabled)
> > > - Adds a Maven profile, "ci", for a nightly continuous integration
> > > build, to deploy Maven artifacts to a local Maven repository
>
> > > This is based on icky Maven stuff I wrote for Tapestry a year or so ago.
>
> > > I'm also in the process of revamping tapestry.apache.org to make it
> > > more of a project hosting site; it will (soon) have Bamboo (continuous
> > > integration server),
> > > Confluence (Wiki), JIRA (Issue Tracking) and SVN.  I could set up a
> > > post-commit and nightly build for Clojure at any time.  This has
> > > served the Tapestry community quite well, giving people easy access to
> > > latest-and-greatest snapshots and (JavaDoc) documentation.
>
> > > Note that the clojure-logo.png file must be stored in
> > > src/site/resources/images.
>
> > Interesting, thanks. I'm left wondering about Maven support.
>
> > Maven is not the build system for Clojure, Ant is. Early on, someone who
> > wanted to use maven contributed a pom.xml, but it can get stale.
>
> > Recently, some enhancements made it into build.xml. Are they reflected in
> > this patch?
>
> > Personally, I think the best thing would be to get rid of pom.xml - it just
> > confuses people as to how to build Clojure, which is:
>
> > ant clean
> > ant
>
> > I know people get religious about these build systems, but I just don't have
> > time for it. Clojure is a tiny, simple thing.
>
> > That said, I'd like to hear people's thoughts on how best to have a single
> > build system of record (Ant) and satisfy Maven users?
>
> > Rich
>
> I'm a Maven fan, and I think it'll be good if clojure supports it.
> But "support" here can mean different things.  And the minimal
> "support" for maven could be to just drop the clojure.jar in public
> maven repository.
>
> I see just one possible problem with this scenario: ASM, which clojure
> bundles.  If somebody adds clojure and a different version of ASM
> things can get hairy.  But that's orthogonal to maven/ant decision.

The way Clojure bundles ASM (re-rooting it under clojure) should
preclude conflicts.

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
-~--~~~~--~~--~--~---



New: clojure.contrib.repl-ln ?

2008-12-03 Thread Randall R Schulz

Hi,

This morning I noticed a new module in Clojure 
Contrib, "clojure.contrib.repl-ln". But I don't think I've seen any 
notice of it here or on #clojure.

Maybe Stephen Gilardi (the author) would say a little about it?


Randall Schulz

--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Stephen C. Gilardi

I was just about to do that, Randall. :-)

clojure.contrib.repl-ln is a repl that supports lines and line  
numbers. Here's a session that demonstrates it.

--Steve

% java -cp clojure.jar:clojure-contrib.jar clojure.main -e "(use  
'clojure.contrib.repl-ln)" -e "(repl)"
1:1 user=> ; clojure.contrib.repl-ln provides a repl that supports  
lines and line numbers in the input stream
1:2 user=> ; every input line is counted. Every input line that's not  
within a clojure object generates a prompt
1:3 user=>
1:4 user=>
1:5 user=> ; even blank lines
1:6 user=> 1 2 3 ; multiple objects on one line are all printed, but  
only produce one prompt
1
2
3
1:7 user=> jkl ; exceptions show the repl name and line number where  
they happened
java.lang.Exception: Unable to resolve symbol: jkl in this context  
(repl-1:7)
1:8 user=> (/ 1 0)
java.lang.ArithmeticException: Divide by zero (repl-1:8)
1:9 user=> (defn greet [] "
hello"
)
#'user/greet
1:12 user=> (meta (var greet)) ; metadata for definitions include repl  
name and line number
{:file "repl-1", :line 9, :ns #, :name  
greet, :arglists ([])}
1:13 user=> ; the repl name is configurable. It defaults to: "repl-%S"  
where %S is the repl serial number
1:14 user=> (repl) ; creating a new repl produces a nested repl with a  
new serial number
2:1 user=> ; and a fresh set of line numbers
2:2 user=> ; the default prompt is "%S:%L %N=> ", serial number, line  
number, and namespace name
2:3 user=> (in-ns 'cool)
#
2:4 cool=> ; quitting a repl pops namespace as well
2:5 cool=> ^D
nil
1:15 user=> (repl) ; creating a new repl produces a nested repl with a  
new serial number
3:1 user=> ; if the prompt is too busy for your taste, you can set it  
to something more familar:
3:2 user=> (set-repl-prompt "%N=> ")
nil
user=> (repl) ; nested repls inherit their name format and prompt  
format from their parent
user=> ; this one is serial number 4, but if it's not in the prompt,  
how can we know?
user=> (repl-info) ; repls have properties accessible this way
{:name "repl-4", :started #, :name- 
fmt "repl-%S", :prompt-fmt "%N=> ", :serial 4, :thread 1, :depth  
3, :line 2}
user=> (print-repl-info) ; or this way
Name:   repl-4
Started:Wed Dec 03 09:02:59 EST 2008
Name-fmt:   "repl-%S"
Prompt-fmt: "%N=> "
Serial: 4
Thread: 1
Depth:  3
Line:   3
nil
user=> ; thread id and nesting level are also available for use in the  
prompt and repl name.
user=> ; a long running clojure could create many of them, say, over  
sockets.
user=> (set-repl-prompt "%S:%T:%D:%L %N=> ") ; a big ol' prompt
nil
4:1:3:7 user=>
4:1:3:8 user=>
4:1:3:9 user=>
4:1:3:10 user=> (set-repl-name "clojure-%S:%T:%D")
nil
4:1:3:11 user=> kjd
java.lang.Exception: Unable to resolve symbol: kjd in this context  
(clojure-4:1:3:11)
4:1:3:12 user=> ; end-of-stream (^D at the beginning of the line on  
Unix/Mac OS X) quits the repl
4:1:3:13 user=> ^D
nil
user=> ^D
nil
1:16 user=> ^D
%


--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread J. McConnell

This looks awesome, great work Stephen!

On Wed, Dec 3, 2008 at 9:27 AM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote:
>
> I was just about to do that, Randall. :-)
>
> clojure.contrib.repl-ln is a repl that supports lines and line
> numbers. Here's a session that demonstrates it.
>
> --Steve
>
> % java -cp clojure.jar:clojure-contrib.jar clojure.main -e "(use
> 'clojure.contrib.repl-ln)" -e "(repl)"
> 1:1 user=> ; clojure.contrib.repl-ln provides a repl that supports
> lines and line numbers in the input stream
> 1:2 user=> ; every input line is counted. Every input line that's not
> within a clojure object generates a prompt
> 1:3 user=>
> 1:4 user=>
> 1:5 user=> ; even blank lines
> 1:6 user=> 1 2 3 ; multiple objects on one line are all printed, but
> only produce one prompt
> 1
> 2
> 3
> 1:7 user=> jkl ; exceptions show the repl name and line number where
> they happened
> java.lang.Exception: Unable to resolve symbol: jkl in this context
> (repl-1:7)
> 1:8 user=> (/ 1 0)
> java.lang.ArithmeticException: Divide by zero (repl-1:8)
> 1:9 user=> (defn greet [] "
> hello"
> )
> #'user/greet
> 1:12 user=> (meta (var greet)) ; metadata for definitions include repl
> name and line number
> {:file "repl-1", :line 9, :ns #, :name
> greet, :arglists ([])}
> 1:13 user=> ; the repl name is configurable. It defaults to: "repl-%S"
> where %S is the repl serial number
> 1:14 user=> (repl) ; creating a new repl produces a nested repl with a
> new serial number
> 2:1 user=> ; and a fresh set of line numbers
> 2:2 user=> ; the default prompt is "%S:%L %N=> ", serial number, line
> number, and namespace name
> 2:3 user=> (in-ns 'cool)
> #
> 2:4 cool=> ; quitting a repl pops namespace as well
> 2:5 cool=> ^D
> nil
> 1:15 user=> (repl) ; creating a new repl produces a nested repl with a
> new serial number
> 3:1 user=> ; if the prompt is too busy for your taste, you can set it
> to something more familar:
> 3:2 user=> (set-repl-prompt "%N=> ")
> nil
> user=> (repl) ; nested repls inherit their name format and prompt
> format from their parent
> user=> ; this one is serial number 4, but if it's not in the prompt,
> how can we know?
> user=> (repl-info) ; repls have properties accessible this way
> {:name "repl-4", :started #, :name-
> fmt "repl-%S", :prompt-fmt "%N=> ", :serial 4, :thread 1, :depth
> 3, :line 2}
> user=> (print-repl-info) ; or this way
> Name:   repl-4
> Started:Wed Dec 03 09:02:59 EST 2008
> Name-fmt:   "repl-%S"
> Prompt-fmt: "%N=> "
> Serial: 4
> Thread: 1
> Depth:  3
> Line:   3
> nil
> user=> ; thread id and nesting level are also available for use in the
> prompt and repl name.
> user=> ; a long running clojure could create many of them, say, over
> sockets.
> user=> (set-repl-prompt "%S:%T:%D:%L %N=> ") ; a big ol' prompt
> nil
> 4:1:3:7 user=>
> 4:1:3:8 user=>
> 4:1:3:9 user=>
> 4:1:3:10 user=> (set-repl-name "clojure-%S:%T:%D")
> nil
> 4:1:3:11 user=> kjd
> java.lang.Exception: Unable to resolve symbol: kjd in this context
> (clojure-4:1:3:11)
> 4:1:3:12 user=> ; end-of-stream (^D at the beginning of the line on
> Unix/Mac OS X) quits the repl
> 4:1:3:13 user=> ^D
> nil
> user=> ^D
> nil
> 1:16 user=> ^D
> %
>
>
> >
>

--~--~-~--~~~---~--~~
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: Improved Maven Build

2008-12-03 Thread Christian Vest Hansen

On Wed, Dec 3, 2008 at 3:01 PM, ivant <[EMAIL PROTECTED]> wrote:
> I'm a Maven fan, and I think it'll be good if clojure supports it.
> But "support" here can mean different things.  And the minimal
> "support" for maven could be to just drop the clojure.jar in public
> maven repository.

And a pom with groupId, artifactId and version, so the jar can be
refered from other poms.

-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Classpath issue using new main method from jar?

2008-12-03 Thread Craig McDaniel

The classpath specified on the command line seems to be ignored for
case #3 (using SVN Rev 1142):

1. Using clojure.lang.Repl

java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
clojure.lang.Repl

Clojure
user=> (.getProperty System "java.class.path")
"/home/kreg/src/clojure/trunk/clojure.jar:/another/class/path"
user=>

2. Using clojure.main explicitly

java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
clojure.main -e '(.getProperty System
"java.class.path")'

/home/kreg/src/clojure/trunk/clojure.jar:/another/class/path

3. Using clojure.main via Main-Class in jar file...ignores classpath
on command line

java -cp /another/class/path -jar /home/kreg/src/clojure/trunk/
clojure.jar -e '(.getProperty System
"java.class.path")'

/home/kreg/src/clojure/trunk/clojure.jar


--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Randall R Schulz

On Wednesday 03 December 2008 06:27, Stephen C. Gilardi wrote:
> I was just about to do that, Randall. :-)

Yeah, I'm both nosey and impatient...


> clojure.contrib.repl-ln is a repl that supports lines and line
> numbers. Here's a session that demonstrates it.

Thanks. That looks pretty cool. Do I understand from your example that
if I just hit return I get another prompt? I've been meaning to ask for
that.

I'm curious how it interacts with rlwrap in general?

Also, does anybody know how gain any degree or kind of control over
signal handling in Java? Preferably pure Java, but since everything I do
is on Linux, a native-code solution for that platform would be
acceptable.

Rlwrap is quite nice, but aside from handling, say SIGINT (CTRL-C) for
its own purposes, it then passes that on to the wrapped program, and
that ends up just killing the JVM.


Anyway, this happened:

user=> (use 'clojure.contrib.repl-ln)
java.lang.IllegalArgumentException: No matching method: repl (repl_ln.clj:213)


The Clojure invocation I used was:

% java -cp 
/repo/JT/clojure-svn/clojure/clojure.jar:/repo/JT/clojure-svn/clojure-contrib/trunk/src:...
 \
clojure.lang.Repl


I'm running Clojure SVN 1141 on java version "1.6.0_10-rc2".


> --Steve


Randall Schulz

--~--~-~--~~~---~--~~
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: Classpath issue using new main method from jar?

2008-12-03 Thread Mark Volkmann

Right. Rich pointed out a week or so ago that you can't use -jar
together with -cp. That means you can't get around specifying the name
of the main class you want to run.

On Wed, Dec 3, 2008 at 9:05 AM, Craig McDaniel <[EMAIL PROTECTED]> wrote:
>
> The classpath specified on the command line seems to be ignored for
> case #3 (using SVN Rev 1142):
>
> 1. Using clojure.lang.Repl
>
> java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
> clojure.lang.Repl
>
> Clojure
> user=> (.getProperty System "java.class.path")
> "/home/kreg/src/clojure/trunk/clojure.jar:/another/class/path"
> user=>
>
> 2. Using clojure.main explicitly
>
> java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
> clojure.main -e '(.getProperty System
> "java.class.path")'
>
> /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
>
> 3. Using clojure.main via Main-Class in jar file...ignores classpath
> on command line
>
> java -cp /another/class/path -jar /home/kreg/src/clojure/trunk/
> clojure.jar -e '(.getProperty System
> "java.class.path")'
>
> /home/kreg/src/clojure/trunk/clojure.jar

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: Classpath issue using new main method from jar?

2008-12-03 Thread Craig McDaniel

Hmm... I must have missed that. The comment in build.xml regarding how
to start Clojure should probably be changed to use clojure.main
instead of "-jar clojure.jar".

On Dec 3, 10:09 am, "Mark Volkmann" <[EMAIL PROTECTED]> wrote:
> Right. Rich pointed out a week or so ago that you can't use -jar
> together with -cp. That means you can't get around specifying the name
> of the main class you want to run.
>
>
>
> On Wed, Dec 3, 2008 at 9:05 AM, Craig McDaniel <[EMAIL PROTECTED]> wrote:
>
> > The classpath specified on the command line seems to be ignored for
> > case #3 (using SVN Rev 1142):
>
> > 1. Using clojure.lang.Repl
>
> > java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
> > clojure.lang.Repl
>
> > Clojure
> > user=> (.getProperty System "java.class.path")
> > "/home/kreg/src/clojure/trunk/clojure.jar:/another/class/path"
> > user=>
>
> > 2. Using clojure.main explicitly
>
> > java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
> > clojure.main -e '(.getProperty System
> > "java.class.path")'
>
> > /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
>
> > 3. Using clojure.main via Main-Class in jar file...ignores classpath
> > on command line
>
> > java -cp /another/class/path -jar /home/kreg/src/clojure/trunk/
> > clojure.jar -e '(.getProperty System
> > "java.class.path")'
>
> > /home/kreg/src/clojure/trunk/clojure.jar
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 10:06 AM, Randall R Schulz wrote:

> Thanks. That looks pretty cool. Do I understand from your example that
> if I just hit return I get another prompt? I've been meaning to ask  
> for
> that.

Thanks and yes, that's right.

> I'm curious how it interacts with rlwrap in general?

I haven't tried it.

> Anyway, this happened:
>
> user=> (use 'clojure.contrib.repl-ln)
> java.lang.IllegalArgumentException: No matching method: repl  
> (repl_ln.clj:213)
>
>
> The Clojure invocation I used was:
>
> % java -cp /repo/JT/clojure-svn/clojure/clojure.jar:/repo/JT/clojure- 
> svn/clojure-contrib/trunk/src:... \
>clojure.lang.Repl

clojure.contrib.repl-ln was missing a ":require" of clojure.main. It  
never showed up for me because I always launch with that as the main  
class these days.

Fixed. Thanks for the detailed report!

--Steve


--~--~-~--~~~---~--~~
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: eval in macro: No method for dispatch value

2008-12-03 Thread Michiel de Mare

Thank you very much for this detailed explanation!

Michiel de Mare

On Dec 3, 2:47 pm, Rich Hickey <[EMAIL PROTECTED]> wrote:
> On Dec 3, 6:58 am, Michiel de Mare <[EMAIL PROTECTED]> wrote:
>
>
>
> > Indeed, (print-dup (new StringBuffer) (new java.io.StringWriter))
> > throws the same exception.
> > But (new StringBuffer) in the REPL prints the stringbuffer just fine.
>
> > Why does the exception only get triggered in macros?
>
> > And doesn't print-dup need a default for unknown classes?
>
> > On Dec 3, 12:23 pm, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > On 3 Dez., 12:04, Michiel de Mare <[EMAIL PROTECTED]> wrote:
>
> > > > This has nothing to do with eval. The following fails too:
>
> > > > (defmacro foo [] (new StringBuffer))
> > > > (foo)
>
> > > The results at the Repl are printed via pr-on and
> > > obviously print-dup doesn't know how to print a
> > > StringBuffer.
>
> > > Sincerely
> > > Meikel
>
> The purpose of a macro is to transform a form into another form on
> behalf of the compiler.
>
> If you want a call to (foo), to become a call to create a new
> StringBuilder, you need to return a piece of data that is a call to
> new, i.e. a list:
>
> i.e. you want to write this form:
>
> (foo)
>
> you want it to expand into this form, i.e. the list of the symbols
> 'new and 'StringBuilder:
>
> (new StringBuilder)
>
> And the way to do that is this:
>
> (defmacro foo []
>   `(new StringBuilder))
>
> (macroexpand '(foo))
> -> (new java.lang.StringBuilder)
>
> But that's not what this does:
>
> (defmacro foo []
>   (new StringBuilder))
>
> That turns the list (foo) into a StringBuilder object, and asks the
> compiler to compile that StringBuilder object:
>
> (macroexpand '(foo))
> -> #
>
> As it says at:
>
> http://clojure.org/evaluation
>
> "Any object other than those discussed above will evaluate to itself."
>
> So what you are asking the compiler to do when asking it to compile a
> literal object like that, is to put that object into the compiled
> bytecode. It ends up that very few objects can be represented in
> bytecode - basically the primitives and Strings. So a language that
> allows for literal objects other than those (as does Clojure) needs to
> find a way to put them into the bytecode and restore them later.
> Clojure does this by representing them as Strings, specifically by
> print-duping them and reading them later. Therefor the only objects
> that can be literals in code are those that support print-dup.
>
> This has nothing to do with printing objects at the repl - that does
> not use print-dup, just print-method.
>
> Unfortunately there is no universally valid default definition for
> print-dup. (a default I tried, printing a call to the ctor with the
> toString value, works often, but not always). And were the default to
> print something that failed at read time, those failures occur during
> class static initialization time, where you really want to avoid
> errors.
>
> print-dup supports the vast majority of things one would like to treat
> as constants in code, with some notable pseudo-value classes like Date
> still to come, but embedding a literal StringBuffer in code is most
> certainly a mistake.
>
> 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: clojure.contrib.repl-ln available

2008-12-03 Thread Drew Olson
Would it make sense to add a :gen-class declaration and have the -main
function automatically call the repl function? This would make launching the
repl less painful for new-comers.
- Drew

On Wed, Dec 3, 2008 at 9:27 AM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote:

>
> I was just about to do that, Randall. :-)
>
> clojure.contrib.repl-ln is a repl that supports lines and line
> numbers. Here's a session that demonstrates it.
>
> --Steve
>
> % java -cp clojure.jar:clojure-contrib.jar clojure.main -e "(use
> 'clojure.contrib.repl-ln)" -e "(repl)"
> 1:1 user=> ; clojure.contrib.repl-ln provides a repl that supports
> lines and line numbers in the input stream
> 1:2 user=> ; every input line is counted. Every input line that's not
> within a clojure object generates a prompt
> 1:3 user=>
> 1:4 user=>
> 1:5 user=> ; even blank lines
> 1:6 user=> 1 2 3 ; multiple objects on one line are all printed, but
> only produce one prompt
> 1
> 2
> 3
> 1:7 user=> jkl ; exceptions show the repl name and line number where
> they happened
> java.lang.Exception: Unable to resolve symbol: jkl in this context
> (repl-1:7)
> 1:8 user=> (/ 1 0)
> java.lang.ArithmeticException: Divide by zero (repl-1:8)
> 1:9 user=> (defn greet [] "
> hello"
> )
> #'user/greet
> 1:12 user=> (meta (var greet)) ; metadata for definitions include repl
> name and line number
> {:file "repl-1", :line 9, :ns #, :name
> greet, :arglists ([])}
> 1:13 user=> ; the repl name is configurable. It defaults to: "repl-%S"
> where %S is the repl serial number
> 1:14 user=> (repl) ; creating a new repl produces a nested repl with a
> new serial number
> 2:1 user=> ; and a fresh set of line numbers
> 2:2 user=> ; the default prompt is "%S:%L %N=> ", serial number, line
> number, and namespace name
> 2:3 user=> (in-ns 'cool)
> #
> 2:4 cool=> ; quitting a repl pops namespace as well
> 2:5 cool=> ^D
> nil
> 1:15 user=> (repl) ; creating a new repl produces a nested repl with a
> new serial number
> 3:1 user=> ; if the prompt is too busy for your taste, you can set it
> to something more familar:
> 3:2 user=> (set-repl-prompt "%N=> ")
> nil
> user=> (repl) ; nested repls inherit their name format and prompt
> format from their parent
> user=> ; this one is serial number 4, but if it's not in the prompt,
> how can we know?
> user=> (repl-info) ; repls have properties accessible this way
> {:name "repl-4", :started #, :name-
> fmt "repl-%S", :prompt-fmt "%N=> ", :serial 4, :thread 1, :depth
> 3, :line 2}
> user=> (print-repl-info) ; or this way
> Name:   repl-4
> Started:Wed Dec 03 09:02:59 EST 2008
> Name-fmt:   "repl-%S"
> Prompt-fmt: "%N=> "
> Serial: 4
> Thread: 1
> Depth:  3
> Line:   3
> nil
> user=> ; thread id and nesting level are also available for use in the
> prompt and repl name.
> user=> ; a long running clojure could create many of them, say, over
> sockets.
> user=> (set-repl-prompt "%S:%T:%D:%L %N=> ") ; a big ol' prompt
> nil
> 4:1:3:7 user=>
> 4:1:3:8 user=>
> 4:1:3:9 user=>
> 4:1:3:10 user=> (set-repl-name "clojure-%S:%T:%D")
> nil
> 4:1:3:11 user=> kjd
> java.lang.Exception: Unable to resolve symbol: kjd in this context
> (clojure-4:1:3:11)
> 4:1:3:12 user=> ; end-of-stream (^D at the beginning of the line on
> Unix/Mac OS X) quits the repl
> 4:1:3:13 user=> ^D
> nil
> user=> ^D
> nil
> 1:16 user=> ^D
> %
>
>
> >
>

--~--~-~--~~~---~--~~
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: Classpath issue using new main method from jar?

2008-12-03 Thread Mark Volkmann

Using "-jar clojure.jar" is fine if you only need the core. I suspect
though that most people are going to want the contrib JAR file and
other things, so the -jar option won't be used often.

On Wed, Dec 3, 2008 at 9:14 AM, Craig McDaniel <[EMAIL PROTECTED]> wrote:
>
> Hmm... I must have missed that. The comment in build.xml regarding how
> to start Clojure should probably be changed to use clojure.main
> instead of "-jar clojure.jar".
>
> On Dec 3, 10:09 am, "Mark Volkmann" <[EMAIL PROTECTED]> wrote:
>> Right. Rich pointed out a week or so ago that you can't use -jar
>> together with -cp. That means you can't get around specifying the name
>> of the main class you want to run.
>>
>>
>>
>> On Wed, Dec 3, 2008 at 9:05 AM, Craig McDaniel <[EMAIL PROTECTED]> wrote:
>>
>> > The classpath specified on the command line seems to be ignored for
>> > case #3 (using SVN Rev 1142):
>>
>> > 1. Using clojure.lang.Repl
>>
>> > java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
>> > clojure.lang.Repl
>>
>> > Clojure
>> > user=> (.getProperty System "java.class.path")
>> > "/home/kreg/src/clojure/trunk/clojure.jar:/another/class/path"
>> > user=>
>>
>> > 2. Using clojure.main explicitly
>>
>> > java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
>> > clojure.main -e '(.getProperty System
>> > "java.class.path")'
>>
>> > /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
>>
>> > 3. Using clojure.main via Main-Class in jar file...ignores classpath
>> > on command line
>>
>> > java -cp /another/class/path -jar /home/kreg/src/clojure/trunk/
>> > clojure.jar -e '(.getProperty System
>> > "java.class.path")'
>>
>> > /home/kreg/src/clojure/trunk/clojure.jar
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
> >
>



-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: Classpath issue using new main method from jar?

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 10:14 AM, Craig McDaniel wrote:

> Hmm... I must have missed that. The comment in build.xml regarding how
> to start Clojure should probably be changed to use clojure.main
> instead of "-jar clojure.jar".

Yes it should be changed. This command:

java -cp clojure.jar clojure.main

will give the same result as

java -jar clojure.jar

but supports including more items in classpath--somethat that Rich  
correctly pointed out is essential for most uses of Clojure.

We should also consider forcing the issue by removing the "Main-Class"  
attribute from the jar's manifest. I was a proponent of including it  
early on for ease of typing, but "java -jar" is almost never the right  
way to launch Clojure.

--Steve


--~--~-~--~~~---~--~~
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: Classpath issue using new main method from jar?

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 10:48 AM, Stephen C. Gilardi wrote:

>  but "java -jar" is almost never the right way to launch Clojure.

More correctly put:

"java -jar" is almost never the right way to launch clojure.jar

--Steve


--~--~-~--~~~---~--~~
You received this message 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: Improved Maven Build

2008-12-03 Thread Howard Lewis Ship

+1 (avoid Maven, keep POM)

I'm moving Tapestry away from Maven as soon as I get chance, but I'll
still have a POM for each module, and I'll still distribute it to the
Maven central repository ... that part is the one thing that Maven
gets really right.

In some ways, avoiding Maven for the build is better, since it'll be
easier to do a couple of things.  I feel strongly that the Java API
should be generated as Javadocs, and linked to from the real clojure
home page, as should test reports when tests are ready.



On Wed, Dec 3, 2008 at 6:55 AM, Christian Vest Hansen
<[EMAIL PROTECTED]> wrote:
>
> On Wed, Dec 3, 2008 at 3:01 PM, ivant <[EMAIL PROTECTED]> wrote:
>> I'm a Maven fan, and I think it'll be good if clojure supports it.
>> But "support" here can mean different things.  And the minimal
>> "support" for maven could be to just drop the clojure.jar in public
>> maven repository.
>
> And a pom with groupId, artifactId and version, so the jar can be
> refered from other poms.
>
> --
> Venlig hilsen / Kind regards,
> Christian Vest Hansen.
>
> >
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Randall R Schulz

On Wednesday 03 December 2008 07:37, Stephen C. Gilardi wrote:
> ...
>
> Fixed. Thanks for the detailed report!

Detailed, eh?

Anyway, that did it and I gotta' say, very cool. And so far it seems 
there's no adverse interaction with rlwrap. I've modified my Clojure 
launcher script to have an option for easy launching with this REPL.

Thanks again.


> --Steve


Randall Schulz

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



doc patch: gensym default prefix is G__, not G

2008-12-03 Thread Stuart Halloway


gensym-docs-default-to-match-impl.diff
Description: Binary data


--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Dudley Flanders


On Dec 3, 2008, at 9:06 AM, Randall R Schulz wrote:
>
> Also, does anybody know how gain any degree or kind of control over
> signal handling in Java? Preferably pure Java, but since everything  
> I do
> is on Linux, a native-code solution for that platform would be
> acceptable.

Not in a portable way, but if you're running a Sun JDK, there's  
sun.misc.Signal and sun.misc.SignalHandler.

:dudley

--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Randall R Schulz

On Wednesday 03 December 2008 08:27, Dudley Flanders wrote:
> On Dec 3, 2008, at 9:06 AM, Randall R Schulz wrote:
> > Also, does anybody know how gain any degree or kind of control over
> > signal handling in Java? Preferably pure Java, but since everything
> > I do is on Linux, a native-code solution for that platform would be
> > acceptable.
>
> Not in a portable way, but if you're running a Sun JDK, there's
> sun.misc.Signal and sun.misc.SignalHandler.

Good information. Thanks.

Perhaps Steve would consider applying them to making his fancy REPL more 
robust for terminal users?


> :dudley


Randall Schulz

--~--~-~--~~~---~--~~
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: DISCUSS: replace (rand)

2008-12-03 Thread Mark H.

On Dec 2, 5:42 am, Stuart Halloway <[EMAIL PROTECTED]> wrote:
> Is it big enough to matter? My intuition says "yes".  That's worth  
> nothing, so I will write some tests when I have some spare time ...  
> but secretly I was hoping that this thread would goad someone else  
> into writing the tests and publishing their results. :-)

I've got a parallel (using Pthreads) Monte Carlo test program in C
that could be easily ported.  If nobody wants to do my work for me ;-P
then I'll get to it as soon as I can.  But I don't have PRNG quality
metrics -- those are the main things we should port if we're into
writing new parallel PRNGs.  btw you probably don't have to implement
your own from scratch -- you could just port something like SPRNG:

http://sprng.fsu.edu/Version2.0/index.html

I've written a little about interfaces for parallel PRNGs here:

http://www.cs.berkeley.edu/~mhoemmen/cs194/Tutorials/prng.pdf

I have the feeling that the "right interface" for a single stream of
pseudorandom numbers is a seq, rather than a "function" that you
call.

mfh
--~--~-~--~~~---~--~~
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 podcast by Stuart Halloway

2008-12-03 Thread bc

I just noticed that there's a new Clojure podcast by Stuart Halloway
on the Pragmatic Programmers site:

http://pragprog.com/podcasts/show/24

The blurb says:

"Stuart Halloway, author of "Programming Clojure", tells Susannah
Pfalzer all about this new and cool programming language. Stuart
explains how Clojure helps you move beyond noun-based programming
toward verb-based programming, and why pure functions are important
for concurrency. It's a lot of Lisp, but with Less parentheses--even
fewer than Java itself. See how to be more expressive on the Java VM,
and how Clojure is different from Scala and Groovy."

- Bill
--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Dakshinamurthy Karra

I am using jline with contrib.repl and it is working pretty well. I
use this command:

java -classpath
.:./jline-0.9.93.jar:classes:clojure/clojure.jar:clojure-contrib/clojure-contrib.jar
jline.ConsoleRunner clojure.main -e "(use 'clojure.contrib.repl-ln)"
-e "(repl)"

-- KD

Dakshinamurthy Karra
(blog: http://blog.marathontesting.com)
(daily dose: http://twitter.com/marathontesting)



On Wed, Dec 3, 2008 at 10:09 PM, Randall R Schulz <[EMAIL PROTECTED]> wrote:
>
> On Wednesday 03 December 2008 08:27, Dudley Flanders wrote:
>> On Dec 3, 2008, at 9:06 AM, Randall R Schulz wrote:
>> > Also, does anybody know how gain any degree or kind of control over
>> > signal handling in Java? Preferably pure Java, but since everything
>> > I do is on Linux, a native-code solution for that platform would be
>> > acceptable.
>>
>> Not in a portable way, but if you're running a Sun JDK, there's
>> sun.misc.Signal and sun.misc.SignalHandler.
>
> Good information. Thanks.
>
> Perhaps Steve would consider applying them to making his fancy REPL more
> robust for terminal users?
>
>
>> :dudley
>
>
> Randall Schulz
>
> >
>

--~--~-~--~~~---~--~~
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: proposal: match multimethod

2008-12-03 Thread axo...@gmail.com



On Dec 2, 2:08 pm, Rich Hickey <[EMAIL PROTECTED]> wrote:
> On Dec 2, 12:16 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote:
> > In Ruby, most things match by value equality. But
> > classes match their instances. Ranges match things in the range.
> > Regexps match strings that they would match against.

> fcase/condf, which I'd like to get in, here:
>
> http://groups.google.com/group/clojure/browse_frm/thread/dee910bef629...

> Also, I think people will want a true structural match macro at some
> point (yesterday).

Here is a wide-open design space of facilities with overlapping
functionality that can be put to a wide variety of different
purposes.  cond clauses, case statements, generic procedure
dispatch a la CLOS, pattern-directed invocation a la ML and
Haskell, destructuring function arguments into formal parameters,
destructuring data structures by patterns, matching regular
expressions, and even pattern matching for operating a rule-based
deduction system all consist of two basic components: which
pattern successfully matches determines the code to be executed
next, and the bindings to the variables of that pattern are
handed to that next piece of code.  They vary in how much each
aspect is emphasized and in the language of permissible patterns,
and in the user-extensibility of the pattern language and the
match sites.  I would love for someone to work out a coherent
Grand Unified Theory of Pattern Matching.  Failing that my two
cents are to suggest that the design of constructs in this space,
like fcase or ===, would benefit from conciously carving out an
appropriate chunk of the space for them to inhabit.

~Alexey

--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 9:32 AM, Drew Olson wrote:

> Would it make sense to add a :gen-class declaration and have the - 
> main function automatically call the repl function? This would make  
> launching the repl less painful for new-comers.
>
> - Drew

It is a good idea and I'll work on it. What I do at the moment is have  
a small script that does what the "-e" commands do in my post. I give  
the path to that script as an argument to clojure.main.

--Steve


--~--~-~--~~~---~--~~
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: DISCUSS: replace (rand)

2008-12-03 Thread Konrad Hinsen

On Dec 3, 2008, at 17:45, Mark H. wrote:

> I have the feeling that the "right interface" for a single stream of
> pseudorandom numbers is a seq, rather than a "function" that you
> call.

I'd provide two interfaces:

1) Low-level: (rng seed) yielding a pair [random-number, new-seed]
2) High-level: (random seed) yielding an infinite (obviously lazy)  
seq of the random numbers obtained starting from the given seed.

What I consider important is the explicit specification of the seed,  
which means that the code always says explicitly where its random  
number sequence starts from.


I just happen to have those two functions in the example section of  
my monad implementation, as rng works nicely in the state monad:

(defn rng [seed]
   (let [m  259200
value  (/ (float seed) (float m))
next   (rem (+ 54773 (* 7141 seed)) m)]
 (list value next)))

(defn random [seed]
   (let [[value next] (rng seed)]
 (lazy-cons value (random next

This particular implementation of rng is probably not a good one  
(it's the first algorithm I found), but my point here is the  
interface, not the algorithm.

Konrad.


--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Randall R Schulz

On Wednesday 03 December 2008 09:10, Dakshinamurthy Karra wrote:
> I am using jline with contrib.repl and it is working pretty well. I
> use this command:

I recently switched from JLine to rlwrap. I think the latter is 
preferable, but I'm sure there are matters of taste involved.


> ...
>
> -- KD


Randall Schulz

--~--~-~--~~~---~--~~
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: clojure.contrib.trace misses a #

2008-12-03 Thread Meikel Brandmeyer

Hi,

there is a missing # in the new trace code. Patch attached.
One could think, that clojure-contrib uses clojure-contrib:
there's defvar in clojure.contrib.def.

Sincerely
Meikel



missing-sharp.patch
Description: Binary data




smime.p7s
Description: S/MIME cryptographic signature


Re: Clojure podcast by Stuart Halloway

2008-12-03 Thread Stuart Halloway

A few other details: the podcast is free, and fairly short (23 minutes).

Cheers,
Stuart

> I just noticed that there's a new Clojure podcast by Stuart Halloway
> on the Pragmatic Programmers site:
>
> http://pragprog.com/podcasts/show/24
>
> The blurb says:
>
> "Stuart Halloway, author of "Programming Clojure", tells Susannah
> Pfalzer all about this new and cool programming language. Stuart
> explains how Clojure helps you move beyond noun-based programming
> toward verb-based programming, and why pure functions are important
> for concurrency. It's a lot of Lisp, but with Less parentheses--even
> fewer than Java itself. See how to be more expressive on the Java VM,
> and how Clojure is different from Scala and Groovy."
>
> - Bill
> >


--~--~-~--~~~---~--~~
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: clojure.contrib.trace misses a #

2008-12-03 Thread Stuart Sierra

Fixed, thanks.
-Stuart Sierra

On Dec 3, 12:36 pm, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
> Hi,
>
> there is a missing # in the new trace code. Patch attached.
> One could think, that clojure-contrib uses clojure-contrib:
> there's defvar in clojure.contrib.def.
>
> Sincerely
> Meikel
>
>  missing-sharp.patch
> < 1KViewDownload
>
>
>
>  smime.p7s
> 5KViewDownload
--~--~-~--~~~---~--~~
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: proposal: match multimethod

2008-12-03 Thread Stuart Sierra

On Dec 2, 2:08 pm, Rich Hickey <[EMAIL PROTECTED]> wrote:
> I'm pretty sure I don't like the sound of that at all. We had a nice
> discussion about fcase/condf, which I'd like to get in, here:
>
> http://groups.google.com/group/clojure/browse_frm/thread/dee910bef629...

And I haven't forgotten about that, just haven't had time to work on
it.  Anyone else who wants to tackle it is welcome.
-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
-~--~~~~--~~--~--~---



Clojure template library

2008-12-03 Thread Jeff Rose

I've just pushed a template library for Clojure up onto github for 
public use.  You can find it here:

http://github.com/rosejn/clj-libs/tree/master

This library is based loosely on erb from Ruby, which is the only other 
template system I've used, and it allows you to insert Clojure 
scriptlets inside a text document.  Following is a short example of how 
it currently works.  Any thoughts, suggestions or feedback are welcome. 
  I plan on making it easier to instantiate pages by passing a hash, or 
maybe a sequence of hashes, which will be successively bound for you. 
I'll probably add some configuration options for handling whitespace and 
trimming newlines too.  Any other ideas or patches welcome.

Cheers,
Jeff

;; Here is a short example of creating an HTML template and then
;; instantiating it under a binding to generate the string output.

;; Define an HTML page template with embedded Clojure code
(def *page*
"Dear <%= winner %>,

We are pleased to inform you that you have been nominated as
president of this years <%= club %> club.  Great job!  You will
soon receive a set of important items:



<% (doseq [doc documents] -%>
<%= doc %>
<% ) -%>



Thanks for all your hard work.
Sincerely,
<%= from %>
")

;; Need these or binding complains...
(def winner nil)
(def club nil)
(def documents nil)
(def from nil)

(let [page (template *page*)]
;; Now calling (page) under different bindings will produce different
;; pages.
   (binding [winner "Joe Bob"
 club   "Winners"
 documents ["winner's check" "waiver" "member list"]
 from   "Winners Club Headquarters"]
 (println (page)))


--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Meikel Brandmeyer

Hi,

Am 03.12.2008 um 18:24 schrieb Stephen C. Gilardi:

Would it make sense to add a :gen-class declaration and have the
-main function automatically call the repl function? This would make
launching the repl less painful for new-comers.

It is a good idea and I'll work on it. What I do at the moment is have
a small script that does what the "-e" commands do in my post. I give
the path to that script as an argument to clojure.main.


I tried to trace down, what happens before we enter the Repl.
The only points I noticed were setting the namespace to user
and setting the command-line-args. I wrote a simple main to
do this. Patch attached. To be started with clojure.contrib.repl_ln.
Note: _ instead of -.

Sincerely
Meikel



repl-main.patch
Description: Binary data




smime.p7s
Description: S/MIME cryptographic signature


Re: Clojure template library

2008-12-03 Thread Stuart Sierra

On Dec 3, 1:04 pm, Jeff Rose <[EMAIL PROTECTED]> wrote:
> I've just pushed a template library for Clojure up onto github for
> public use.

Cool!  One thing to consider, a noted flaw in ERB: use real XML
processing instructions, like "" instead of "<%= .. %>".
That way your template can be a valid XML document.  Yes, it's more
verbose, but PHP does it.  Or, if you want, allow user-definable
delimiters.
-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
-~--~~~~--~~--~--~---



PATCH for clojure.contrib.javadoc: use any local/remote javadocs

2008-12-03 Thread Stuart Sierra
Hi Christophe, hi list,

I really like clojure.contrib.javadoc; I've wanted something like this
for a while.  But I wanted it to work for other packages besides the
core Java API, so this patch (attached) does that.  It also works for
both local and remote Javadoc files.  What do you think?  In the
process, I separated the web-browser functions into a separate lib,
since those might be useful elsewhere.

-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
-~--~~~~--~~--~--~---

Index: src/clojure/contrib/javadoc.clj
===
--- src/clojure/contrib/javadoc.clj	(revision 268)
+++ src/clojure/contrib/javadoc.clj	(working copy)
@@ -6,44 +6,69 @@
 ;   the terms of this license.
 ;   You must not remove this notice, or any other, from this software.
 
-; a repl helper to quickly open JDK javadocs.
+; a repl helper to quickly open javadocs.
 
-(ns clojure.contrib.javadoc)
+(ns clojure.contrib.javadoc
+(:use clojure.contrib.browse)
+(:import (java.io File)))
 
-(defn- open-url-in-browser [url]
-  (try 
-(when (clojure.lang.Reflector/invokeStaticMethod "java.awt.Desktop" 
-  "isDesktopSupported" (to-array nil))
-  (-> (clojure.lang.Reflector/invokeStaticMethod "java.awt.Desktop" 
-"getDesktop" (to-array nil))
-(.browse (java.net.URI. url)))
-  url)
-(catch ClassNotFoundException e
-  nil)))
-
-(defn- open-url-in-swing [url]
-  (let [htmlpane (javax.swing.JEditorPane. url)]
-(.setEditable htmlpane false)
-(.addHyperlinkListener htmlpane
-  (proxy [javax.swing.event.HyperlinkListener] []
-(hyperlinkUpdate [#^javax.swing.event.HyperlinkEvent e]
-  (when (= (.getEventType e) (. javax.swing.event.HyperlinkEvent$EventType ACTIVATED))
-(if (instance? javax.swing.text.html.HTMLFrameHyperlinkEvent e)
-  (-> htmlpane .getDocument (.processHTMLFrameHyperlinkEvent e))
-  (.setPage htmlpane (.getURL e)))
-(doto (javax.swing.JFrame.)
-  (setContentPane (javax.swing.JScrollPane. htmlpane))
-  (setBounds 32 32 700 900)
-  (show
+(def
+ #^{:doc "Ref to a list of local paths for Javadoc-generated HTML
+  files."}
+ *local-javadocs* (ref (list)))
 
+(def *core-java-api*
+ "http://java.sun.com/javase/6/docs/api/";)
+
+(def
+ #^{:doc "Ref to a map from package name prefixes to URLs for remote
+  Javadocs."}
+ *remote-javadocs*
+ (ref (sorted-map
+   "java." *core-java-api*
+   "javax." *core-java-api*
+   "org.ietf.jgss." *core-java-api*
+   "org.omg." *core-java-api*
+   "org.w3c.dom." *core-java-api*
+   "org.xml.sax." *core-java-api*
+   "org.apache.commons.codec." "http://commons.apache.org/codec/api-release/";
+   "org.apache.commons.io." "http://commons.apache.org/io/api-release/";
+   "org.apache.commons.lang." "http://commons.apache.org/lang/api-release/";)))
+
+(defn add-local-javadoc
+  "Adds to the list of local Javadoc paths."
+  [path]
+  (dosync (commute *local-javadocs* conj path)))
+
+(defn add-remote-javadoc
+  "Adds to the list of remote Javadoc URLs.  package-prefix is the
+  beginning of the package name that has docs at this URL."
+  [package-prefix url]
+  (dosync (commute *remote-javadocs* assoc package-prefix url)))
+
+(defn find-javadoc-url
+  "Searches for a URL for the given class name.  Tries
+  *local-javadocs* first, then *remote-javadocs*.  Returns a string."
+  [classname]
+  (let [path (.replace classname \. File/separatorChar)]
+(if-let [file (first
+   (filter #(.exists %)
+   (map #(File. % (str path ".html"))
+@*local-javadocs*)))]
+  (str "file://" (.getAbsolutePath file))
+  ;; If no local file, try remote URLs:
+  (some (fn [[prefix url]]
+(when (.startsWith classname prefix)
+  (str url path ".html")))
+@*remote-javadocs*
+
 (defn javadoc
- "Opens a browser window displaying the javadoc for the argument."
- [class-or-object]
+  "Opens a browser window displaying the javadoc for the argument.
+  Tries *local-javadocs* first, then *remote-javadocs*."
+  [class-or-object]
   (let [c (if (instance? Class class-or-object) 
 class-or-object 
-(class class-or-object))
-url (str "http://java.sun.com/javase/6/docs/api/";
-  (-> c .getName (.replace \. \/) (.replace \$ \.)) 
-  ".html")]
-(or (open-url-in-browser url) (open-url-in-swing url
-
+(class class-or-object))]
+(if-let [url (find-javadoc-url (.ge

Re: slime+clojure problem

2008-12-03 Thread Vijay Lakshminarayanan

If you've got enough time to spare, I'd recommend trying out the
clojurebox that was released a few days ago.  I installed it, ensured
it worked and then replicated that in my .emacs.

Once you have a basic setup working you can easily make the needed
changes to run the latest version.

On Wed, Dec 3, 2008 at 6:19 PM, Dimitre Liotev <[EMAIL PROTECTED]> wrote:
>
> Peter Eddy wrote:
>>> How are you attempting to start slime? Are you doing:
>>>
>>> 1. C-u M-x slime RET clojure RET
>>>
>>> OR
>>>
>>> 2. M-- M-x slime RET clojure RET
>>>
>>
>> Well, either method caused this error for me. I deleted all my slime
>> and clojure-related source trees and re-checked everything out again
>> (taking advantage to organize everything a little better this time
>> around), but same problem.
>>
>> So I backed up my .emacs and then got rid of all configuration for the
>> other lisps I was using (clisp, openmcl and sbcl) and now I can
>> successfully start slime for clojure.
>>
>> I'll eventually re-add the config I removed and try to find what it
>> was that broke clojure/slime.
>>
>> thanks everyone.
>>
>> - Peter
>>
>
>
> If you have set "slime-lisp-implementations", make sure the entry for
> clojure looks like this:
>
> (clojure ("clojure") :init swank-clojure-init)
>
> For example, my slime-lisp-implementations is:
>
>   (setq slime-lisp-implementations
> `(
>   (sbcl ("sbcl"))
>   (ccl ("ccl"))
>   (clojure ("clojure") :init swank-clojure-init)
>   (clisp ("clisp"))
>   (abcl ("abcl"))
>   (cmucl ("lisp"))
>   (s48 ("scheme48") :init slime48-init-command)
>
>
>
> If I specify (clojure ("clojure")) instead of (clojure (clojure") :init
> swank-clojure-init), I get the same error as you.
>
> --
> dl
>
>
> >
>

--~--~-~--~~~---~--~~
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 template library

2008-12-03 Thread Jeff Rose

Ok, that makes sense.  I'll do it.  What about the other options 
available in erb though?  Do we use this:


   * 


Will '' pass for valid xml?

-Jeff

Stuart Sierra wrote:
> On Dec 3, 1:04 pm, Jeff Rose <[EMAIL PROTECTED]> wrote:
>> I've just pushed a template library for Clojure up onto github for
>> public use.
> 
> Cool!  One thing to consider, a noted flaw in ERB: use real XML
> processing instructions, like "" instead of "<%= .. %>".
> That way your template can be a valid XML document.  Yes, it's more
> verbose, but PHP does it.  Or, if you want, allow user-definable
> delimiters.
> -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
-~--~~~~--~~--~--~---



Using main(...) Entry Points From Clojure

2008-12-03 Thread Randall R Schulz

Hi,

I really like cli4j and have a nice pattern I follow in creating CLI 
entry points for my project. I find it has a lot of advantages, 
including a declarative means of defining your CLI syntax using 
annotations.

So I thought it might be nice not to have to write all new interface 
wrappers to gain access to these command-oriented interfaces from a 
REPL context. It turned out to be remarkably easy to do this, and I 
thought I'd pass on my experience. It should be entirely applicable 
even for those not using cli4j.


Here's what I did:

1) Wrote a few helper functions to allow keywords such as :o or :option 
to stand in for "-o" or "--option" arguments. There are three variants 
(at least conceptually), to produce A) a list; B) a vector and C) a 
String[] holding the converted arguments.

To wit:

(defn make-cli-arglist
 "Create a list of strings encoding a CLI invocation from
  a sequence of keywords and other (atomic) values"
 [args]
 (map
  #(if (keyword? %)
   (let [opt-name (name %)]
(if (> (.length opt-name) 1)
(str "--" opt-name)
(str \- opt-name)))
   (str %))
  args))

(defn make-cli-argvec
 "Create a vector of strings encoding a CLI invocation from
  a sequence of keywords and other (atomic) values"
 [args]
 (apply vector (make-cli-arglist args)))

(defn make-cli-argarray
 "Create a vector of strings encoding a CLI invocation from
  a sequence of keywords and other (atomic) values"
 [args]
 (into-array String (make-cli-arglist args)))


2) Wrote a top-level launcher function that converts its arguments using 
(1C) and calls the embedding entry point (see (3)) of the Java 
command-line class.

3) Wrote an alternate entry point to the Java main(String[] args) that 
returns its termination status rather than calling System.exit(status). 
(Naturally, I was both delighted and surprised when my first successful 
attempt dumped me out of Clojure upon completing its invocation.)

4) The last refinement I added was a macro version of (2), which means 
that for arguments that don't contain any characters that are special 
in Clojure, enclosing those arguments in quote marks is unnecessary. 
This is, of course, directly analogous to a similar requirement in any 
Unix shell.

Note: This actually obviates the keyword conversion aspect of the 
argument list synthesizer in (1), though conversion to all String 
instances is still necessary, of course. The one possibly still-useful 
thing that code does is blur the distinction between single-character 
options (which use a single hyphen) and multi-character options (which 
use two hyphens) by automatically choosing the proper syntax for the 
converted option name.


So far, the only visible "seam" I've noticed is that when you use the 
keyword-as-option mode and there's an error, the old CLI code, not ever 
having seen a Lisp keyword (nor having any notion of such things) 
prints diagnostics using hyphens.


Between this approach and Steve G.'s new REPL, I feel I'm going to get 
an interactive environment for my full suite of tools that is 
independent of a Unix shell virtually for free. Other advantages of 
this include platform independence (I have potential users on Windows) 
and the elimination of the JVM start-up overhead for each individual 
invocation.

I know this isn't barely actually Clojure programming, just an exercise 
of Clojure's very slick Java integration, but I found it gratifying.


Randall Schulz

--~--~-~--~~~---~--~~
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: DISCUSS: replace (rand)

2008-12-03 Thread Mark H.

On Dec 3, 9:27 am, Konrad Hinsen <[EMAIL PROTECTED]> wrote:
> I'd provide two interfaces:
>
> 1) Low-level: (rng seed) yielding a pair [random-number, new-seed]
> 2) High-level: (random seed) yielding an infinite (obviously lazy)  
> seq of the random numbers obtained starting from the given seed.
>
> What I consider important is the explicit specification of the seed,  
> which means that the code always says explicitly where its random  
> number sequence starts from.

Some PRNGs make a distinction between "seed" and "state."  For
example, the Mersenne Twister uses one integer as a seed, but an array
of integers as its state, which it modifies each time a new
pseudorandom number is requested.  Of course the "seed" in the sense
of your interface could be that "state" (with the PRNG rewritten to
copy the state before updating it), since the state suffices to
continue the PRNG stream from any particular point.  The MT uses a
rather large amount of state but you lose all the advantages of seqs
and immutability if you don't copy it.

Some parallel PRNGs have two different seeds:  one to guarantee a
unique noncorrelated stream for each processor, and another to seed
the stream.  This isn't much different than your interface, though.

btw (not to you, to another post I recall in this thread) seeding a
PRNG using the thread id isn't enough to guarantee that different
threads don't have correlated PRNG streams.

mfh
--~--~-~--~~~---~--~~
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: Using main(...) Entry Points From Clojure

2008-12-03 Thread Randall R Schulz

Hello again,

Sorry to follow-up on my own post, but another idea came to me shortly 
after sending it.

On Wednesday 03 December 2008 10:49, Randall R Schulz wrote:
> ...
>
> Between this approach and Steve G.'s new REPL, I feel I'm going to
> get an interactive environment for my full suite of tools that is
> independent of a Unix shell virtually for free. Other advantages of
> this include platform independence (I have potential users on
> Windows) and the elimination of the JVM start-up overhead for each
> individual invocation.

Now I'm thinking that the idea about a REPL mode (call it "shell mode," 
perhaps) in which outer parentheses were assumed might actually be 
nice.

Of course, that gets you into the need for a continuation character when 
an invocation must be split across lines and probably other issues, as 
well (people might start asking for file-system tie-ins such as file 
name globbing or completions based on file names...). But perhaps it's 
worth a little more thought, after all.


Randall Schulz

--~--~-~--~~~---~--~~
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: fix imports

2008-12-03 Thread Vijay Lakshminarayanan

On Tue, Dec 2, 2008 at 1:53 AM, Stuart Sierra
<[EMAIL PROTECTED]> wrote:
>
> On Nov 28, 7:41 am, lpetit <[EMAIL PROTECTED]> wrote:
>> The "fix import" action could try to resolve an unknown symbol by
>> first searching the symbol in one of the classpath available
>> namespaces, and then search for java classes in the classpath.
>> It could then add an import/require command for each found resolution
>> (and if several resolutions found, ad all, letting the user solve
>> manually the conflict).
>>
>> This could be provided as an IDE action, and also, I think, as a
>> clojure function that could work directly on files.
>
> JDEE  does this, for Java source code.

This is far from complete and should be expanded but I got this from a
few hours of hacking:

(import '(java.util.jar JarFile JarEntry)
'(java.io File IOException))

(defn find-all
  "(for [x coll :when (test-fn item (key-fn x))] x)"
  ([item coll test-fn key-fn]
 (filter #(test-fn item (key-fn %)) coll))
  ([item coll test-fn]
 (find-all item coll test-fn #'identity))
  ([item coll]
 (find-all item coll #'= #'identity)))

(defn find-reg-in-seq
  ([reg coll key]
 (find-all reg coll #'re-find key))
  ([reg coll]
 (find-reg-in-seq reg coll #'identity)))

(defn dir-or-jar->seq
  [path-entity]
  (cond (instance? File path-entity)
(if (.isDirectory #^File path-entity)
  (file-seq path-entity)
  (throw (IOException. "Cannot search within a file.")))
(instance? JarFile path-entity)
(enumeration-seq (.entries #^JarFile path-entity))
true
(throw (UnsupportedOperationException.
(str "Cannot handle " (class path-entity))

(defn find-re-in-path-entity [reg path-entity]
  (find-reg-in-seq reg
   (dir-or-jar->seq path-entity)
   #(.getName %)))

(defn find-class-in-path-entity [class-name path-entity]
  (find-re-in-path-entity (re-pattern (str #"[^A-Za-z0-9$]" class-name
".class$"))
  path-entity))

(def *rt-jar* (.toString
   (File.
(File. (.getProperty System "java.home") "lib") "rt.jar")))

(defn find-java-class-in-classpath [class-name]
  (let [cpath (cons *rt-jar* (.split (.getProperty System "java.class.path")
 (.getProperty System "path.separator")))]
   (mapcat #'identity
   (filter #(not (nil? %))
   (for [#^String path cpath]
 (find-class-in-path-entity class-name
(if (.endsWith path ".jar")
  (JarFile. path)
  (File. path

(defn find-java-class [class-name]
  (map (fn [o] (let [#^String s (.toString #^Object o)
 l (.length s)]
 (.. s (substring 0 (- l 6)) (replace "/" "."
   (find-java-class-in-classpath class-name)))

;;; *eof*

It looks inside all jar files and at all .class files inside
directories in the classpath and rt.jar -- the java runtime library
and returns the list of classes that exist on the classpath.

I haven't written it inside a namespace etc.  It's saved in a file
named "stuff.clj" because I couldnt' think of a good name.

user> (load "stuff")
nil
user> (find-java-class "List")
("com.sun.xml.internal.bind.v2.schemagen.xmlschema.List"
"java.awt.List" "java.util.List")
user> (find-java-class "URL")
("java.net.URL")
user> (find-java-class "NonExistent")
("com.sun.corba.se.impl.protocol.NonExistent")
user> (find-java-class "NonExistentClass")
nil

;; I never expected there'd be a class named "NonExistent" ;-)

The above code is released under public domain so anyone may do what
they wish with it.

Cheers
Vijay

--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Mark Volkmann

On Wed, Dec 3, 2008 at 11:25 AM, Randall R Schulz <[EMAIL PROTECTED]> wrote:
>
> On Wednesday 03 December 2008 09:10, Dakshinamurthy Karra wrote:
>> I am using jline with contrib.repl and it is working pretty well. I
>> use this command:
>
> I recently switched from JLine to rlwrap. I think the latter is
> preferable, but I'm sure there are matters of taste involved.

I made the same switch. The big sell for me is support for vi
keystrokes in the REPL. I feel much more productive with rlwrap than
JLine.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: AOT Compilation for Contrib

2008-12-03 Thread Stephen C. Gilardi

On Nov 28, 2008, at 5:07 PM, Meikel Brandmeyer wrote:

> Hi,
>
> I'm kind of lost with the latest works on the compiler.
> However here is a short patch, which modifies build.xml
> of contrib to also compile the sources.

[...]

> The build.xml adds all jar files in the path given by
> the CLOJURE_LIB environment variable to the
> classpath.

Can we make clojure-contrib/build.xml work such that if you specify a  
location for a clojure.jar as a property, it compiles (the stand-alone  
compilable parts of ) clojure-contrib into clojure-contrib.jar, but if  
you don't specify the location it just jars up the clojure-contrib  
sources?

That would be one flexible way to handle needing clojure.jar in order  
to compile, but not wanting an absolute dependency.

Alternatively, perhaps clojure/build.xml should build clojure- 
contrib.jar if it's told where to find the clojure-contrib source  
directory.

Any thoughts?

--Steve

--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 1:12 PM, Meikel Brandmeyer wrote:

> I tried to trace down, what happens before we enter the Repl.
> The only points I noticed were setting the namespace to user
> and setting the command-line-args. I wrote a simple main to
> do this. Patch attached. To be started with clojure.contrib.repl_ln.
> Note: _ instead of -.

Patch applied. Thanks very much, Meikel!

--Steve


--~--~-~--~~~---~--~~
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.contrib.repl-ln available

2008-12-03 Thread Randall R Schulz

On Wednesday 03 December 2008 11:26, Mark Volkmann wrote:
> On Wed, Dec 3, 2008 at 11:25 AM, Randall R Schulz <[EMAIL PROTECTED]> 
wrote:
> > On Wednesday 03 December 2008 09:10, Dakshinamurthy Karra wrote:
> >> I am using jline with contrib.repl and it is working pretty well.
> >> I use this command:
> >
> > I recently switched from JLine to rlwrap. I think the latter is
> > preferable, but I'm sure there are matters of taste involved.
>
> I made the same switch. The big sell for me is support for vi
> keystrokes in the REPL. I feel much more productive with rlwrap than
> JLine.

There are other things. E.g., JLine gets confused after suspending the 
REPL (using SIGTSTP / CTRL-Z) and it does not support completion or (a 
personal favorite) CTRL+LEFT-ARROW and +RIGHT-ARROW. Rlwrap also has 
incremental search (CTRL-R and SHIFT+CTRL-R).

The only real down-side of CTRL+ARROW is that I get in the habit of 
using them (previously only in BASH) and then out of habit I type them 
in Vim, which causes bad things to happen...

Randall Schulz

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



A try on condp (was: Re: proposal: match multimethod)

2008-12-03 Thread Meikel Brandmeyer

Hi Stuart and Rich,

Am 03.12.2008 um 19:00 schrieb Stuart Sierra:

I'm pretty sure I don't like the sound of that at all. We had a nice
discussion about fcase/condf, which I'd like to get in, here:

http://groups.google.com/group/clojure/browse_frm/thread/ 
dee910bef629...


And I haven't forgotten about that, just haven't had time to work on
it.  Anyone else who wants to tackle it is welcome.


How about the following:

(defmacro condp
  "condp compares the given needle with the first clause using the  
given

  predicate. In case the predicate returns true the second clause is
  returned. Otherwise condp goes on with the rest of the clauses. In
  case there is an odd number of clauses the last one will be returned
  if no preceding clause matched. If no default clause is given an
  exception is thrown. The predicate is called with needle as first
  argument and the first clause as second argument."
  [pred needle & clauses]
  (let [c(count clauses)
par  (rem c 2)
cls  (take (if (zero? par) c (dec c)) clauses)
cls  (mapcat (fn [[x c]] `[(~xprd ~xndl ~x) ~c]) (partition 2  
cls))

xndl (gensym "condp_needle__")
xprd (gensym "condp_predicate__")
lst  (if (zero? par)
   `(throw (Exception. (str "No condp clause matched for: "
(prn-str ~xndl
   (last clauses))]
`(let [~xprd ~pred
   ~xndl ~needle]
   (cond
 [EMAIL PROTECTED]
 :else ~lst

I mulled about the (x _) syntax, but to be honest: I think #() is
perfectly sufficient. We would need to quote all the contents to
prevent multiple evaluation, but then we have to recurse and check
for _ vs. non-_...

I expect the predicate to be a function of two arguments with the first
being the needle and the second being the clause, we compare to.
Predicates where order doesn't matter or the order agrees may be simply
used. Others or more complicated expressions can be wrapped in a #().
Here we still have a problem for #(pred (complicated-computation) %2
%1)

In case the number of clauses is even, and no clause matched the
predicate, we throw an exception. In case the number of clauses is
odd, we return the last one as default. I think adding a simple nil
is tolerable, making the "I ignore a failed run" explicit.

What do you think?

Sincerely
Meikel





smime.p7s
Description: S/MIME cryptographic signature


Building regex pattern literals (Noob question)

2008-12-03 Thread Blaine

I want to build a regular expression pattern literal (I think that's
what they're called) like #"a.*" out of separate strings like "a" and
".*".

user> (re-seq #"a.*" "bab")   ; this is cool
("ab")
user> (re-seq #(str "a" ".*") "bab")  ; but this, in all its noobness,
is not
; Evaluation aborted.
user> #(str "a" ".*")
#  ; what
is this thing?  can I use it somehow?

I appreciate the help.

- Blaine
--~--~-~--~~~---~--~~
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: Building regex pattern literals (Noob question)

2008-12-03 Thread Randall R Schulz

On Wednesday 03 December 2008 11:57, Blaine wrote:
> I want to build a regular expression pattern literal (I think that's
> what they're called) like #"a.*" out of separate strings like "a" and
> ".*".
>
> user> (re-seq #"a.*" "bab")   ; this is cool
> ("ab")
> user> (re-seq #(str "a" ".*") "bab")  ; but this, in all its
> noobness, is not
> ; Evaluation aborted.
> user> #(str "a" ".*")
> #  ; what
> is this thing?  can I use it somehow?

You're using a reader notation unrelated to regular expressions. 
Instead, #(...) is a shorthand notation for an anonymous function 
definition.


In this case, you'll have to build up the textual form of the pattern 
(being careful to use all the necessary extra backslashes) and then 
when that's complete, use (re-pattern ...) to turn that string into a 
Pattern instance.

Perhaps more easily, you can combine the string concatenation with the 
Pattern compilation in a single form:

  (re-pattern (str "a" ".*" "b"))

or

  (re-seq (re-pattern (str "a" ".*" "b")) "babba")

user=> (re-seq (re-pattern (str "a" ".*" "b")) "babba")
("abb")


> I appreciate the help.
>
> - Blaine


Randall Schulz

--~--~-~--~~~---~--~~
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: A try on condp (was: Re: proposal: match multimethod)

2008-12-03 Thread Brian Doyle
Can you include an example usage of this function?  Thanks.

On Wed, Dec 3, 2008 at 12:51 PM, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:

> Hi Stuart and Rich,
>
> Am 03.12.2008 um 19:00 schrieb Stuart Sierra:
>
>> I'm pretty sure I don't like the sound of that at all. We had a nice
>>> discussion about fcase/condf, which I'd like to get in, here:
>>>
>>> http://groups.google.com/group/clojure/browse_frm/thread/dee910bef629...
>>>
>>
>> And I haven't forgotten about that, just haven't had time to work on
>> it.  Anyone else who wants to tackle it is welcome.
>>
>
> How about the following:
>
> (defmacro condp
>  "condp compares the given needle with the first clause using the given
>  predicate. In case the predicate returns true the second clause is
>  returned. Otherwise condp goes on with the rest of the clauses. In
>  case there is an odd number of clauses the last one will be returned
>  if no preceding clause matched. If no default clause is given an
>  exception is thrown. The predicate is called with needle as first
>  argument and the first clause as second argument."
>  [pred needle & clauses]
>  (let [c(count clauses)
>par  (rem c 2)
>cls  (take (if (zero? par) c (dec c)) clauses)
>cls  (mapcat (fn [[x c]] `[(~xprd ~xndl ~x) ~c]) (partition 2 cls))
>xndl (gensym "condp_needle__")
>xprd (gensym "condp_predicate__")
>lst  (if (zero? par)
>   `(throw (Exception. (str "No condp clause matched for: "
>(prn-str ~xndl
>   (last clauses))]
>`(let [~xprd ~pred
>   ~xndl ~needle]
>   (cond
> [EMAIL PROTECTED]
> :else ~lst
>
> I mulled about the (x _) syntax, but to be honest: I think #() is
> perfectly sufficient. We would need to quote all the contents to
> prevent multiple evaluation, but then we have to recurse and check
> for _ vs. non-_...
>
> I expect the predicate to be a function of two arguments with the first
> being the needle and the second being the clause, we compare to.
> Predicates where order doesn't matter or the order agrees may be simply
> used. Others or more complicated expressions can be wrapped in a #().
> Here we still have a problem for #(pred (complicated-computation) %2
> %1)
>
> In case the number of clauses is even, and no clause matched the
> predicate, we throw an exception. In case the number of clauses is
> odd, we return the last one as default. I think adding a simple nil
> is tolerable, making the "I ignore a failed run" explicit.
>
> What do you think?
>
> Sincerely
> Meikel
>
>
>
>

--~--~-~--~~~---~--~~
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: A try on condp (was: Re: proposal: match multimethod)

2008-12-03 Thread Meikel Brandmeyer

Hello again,

Am 03.12.2008 um 20:51 schrieb Meikel Brandmeyer:
   cls  (mapcat (fn [[x c]] `[(~xprd ~xndl ~x) ~c]) (partition 2  
cls))

   xndl (gensym "condp_needle__")
   xprd (gensym "condp_predicate__")


Oops. These should of course be changed to be in the
right order.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: Building regex pattern literals (Noob question)

2008-12-03 Thread J. McConnell

On Wed, Dec 3, 2008 at 3:10 PM, Randall R Schulz <[EMAIL PROTECTED]> wrote:
>
> You're using a reader notation unrelated to regular expressions.
> Instead, #(...) is a shorthand notation for an anonymous function
> definition.

You can read more about the other reader macros here:

http://clojure.org/reader

Note the "Dispatch" list item under "Macro Characters".

- J.

--~--~-~--~~~---~--~~
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 podcast by Stuart Halloway

2008-12-03 Thread Randall R Schulz

On Wednesday 03 December 2008 09:07, bc wrote:
> I just noticed that there's a new Clojure podcast by Stuart Halloway
> on the Pragmatic Programmers site:
>
> http://pragprog.com/podcasts/show/24
>
> ...

I just listened to the interview. It was good, but I think for denizens 
here, there won't be much that's new.

I think the only thing I picked up that I hadn't heard of before was the 
concept of combining native-type annotations and overflow exception 
handling to create as-needed promotion to arbitrary-precision numeric 
types. (Time indexes 14:25 - 16:10.)


Randall Schulz

--~--~-~--~~~---~--~~
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: Building regex pattern literals (Noob question)

2008-12-03 Thread Chouser

On Wed, Dec 3, 2008 at 2:57 PM, Blaine <[EMAIL PROTECTED]> wrote:
>
> I want to build a regular expression pattern literal (I think that's
> what they're called) like #"a.*" out of separate strings like "a" and
> ".*".
>
> user> (re-seq #"a.*" "bab")   ; this is cool
> ("ab")
> user> (re-seq #(str "a" ".*") "bab")  ; but this, in all its noobness, is not
> ; Evaluation aborted.
> user> #(str "a" ".*")
> #  ; what
> is this thing?  can I use it somehow?

It's a function!  You could have built the same thing like this:
user=> (fn [] (str "a" ".*"))
#

You can use it, but it has nothing to do with regex:
user=> (def thing #(str "a" ".*"))
#'user/thing
user=> (thing)
"a.*"

It's just a function that returns a literal string.  A "regex" in
Clojure/Java is actually a java.util.regex.Pattern:
user=> (class #"")
java.util.regex.Pattern

To programmatically build one, you'll have to use that class directly,
or 're-pattern':
user=> (doc re-pattern)
-
clojure.core/re-pattern
([s])
  Returns an instance of java.util.regex.Pattern, for use, e.g. in
  re-matcher.
nil
user=> (re-pattern (str "a" ".*"))
#"a.*"

...so back to your original example:
user=> (re-seq (re-pattern (str "a" ".*")) "bab")
("ab")

But remember that you may need extra backslashes inside the "string"
parts, compared to the equivalent #"regex" literal.

Or if each piece of your regex can stand alone, you could take
advantage of the fact that the .toString method on Pattern returns a
sufficiently escaped string:

user=> (re-seq (re-pattern (str #"s" #"\w*")) "sue sang a song")
("sue" "sang" "song")

--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
-~--~~~~--~~--~--~---



Adding boolean?

2008-12-03 Thread Tom Emerson

I found myself needing the following today, and it was noticeably
missing from core.clj --- any reason not to include it?

(defn boolean?
  "Returns true if b is a Boolean (i.e., true or false)"
  [b]
  (instance? Boolean b))

Peace,

-tree

-- 
Tom Emerson
[EMAIL PROTECTED]
http://www.dreamersrealm.net/~tree

--~--~-~--~~~---~--~~
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: A try on condp (was: Re: proposal: match multimethod)

2008-12-03 Thread Meikel Brandmeyer

Hi,

Am 03.12.2008 um 21:10 schrieb Brian Doyle:


Can you include an example usage of this function?  Thanks.


(condp = x
  1 "We got a one."
  2 (str "We got a " (- 3 1))
  "We got something else."))

Sincerely
Meikel

smime.p7s
Description: S/MIME cryptographic signature


Re: Clojure could be to Concurrency-Oriented Programming what Java was to OOP

2008-12-03 Thread Bill Clementson

Hi Mark,

On Tue, Dec 2, 2008 at 10:38 PM, Mark H. <[EMAIL PROTECTED]> wrote:
> On Dec 1, 12:03 am, bc <[EMAIL PROTECTED]> wrote:
>> I've written a blog post titled "Clojure could be to Concurrency-
>> Oriented Programming what Java was to OOP" in which I discuss
>> Clojure's approach to concurrency:http://bc.tech.coop/blog/081201.html
>>
>> Any comments/criticisms would be appreciated.
>
> Great article! :-)

Thanks!

> A picky point -- "concurrency" refers to multiple actors and the
> shared data problem (which is not necessarily related to performance),
> whereas "the free lunch is over" refers to "parallelism" (using
> multiple CPUs to improve performance), regardless of what terminology
> the article actually uses ;-)

The definition of "concurrency" is a bit problematic because it can
mean different things to different people. Some people don't like to
use it to refer to "parallelism"; however, others choose to use a more
"all-encompassing" definition of concurrency. Wikipedia's definition
(http://en.wikipedia.org/wiki/Concurrency_(computer_science)) includes
both forms of concurrency:
"In computer science, concurrency is a property of systems in which
several computational processes are executing at the same time, and
potentially interacting with each other. The study of concurrency
encompasses a broad range of systems, from tightly-coupled, largely
synchronous parallel computing systems, to loosely-coupled, largely
asynchronous distributed systems. The concurrent processes may be
executing truly simultaneously, in the case that they run on separate
processors, or their execution steps may be interleaved to produce the
appearance of concurrency, as in the case of separate processes
running on a multitasking system."

In my article, I tried to differentiate between concurrent processes
running in the same address space and concurrent processes that are
running on multiple different machines. I used the terms
"non-distributed concurrency" for the former and "distributed
concurrency" for the latter . In Herb Sutter's "the free lunch is
over" article (although his article discusses the potential benefits
of parallel computing, multi-core CPU's, and different threading
advances), his quote "Concurrency is the next major revolution in how
we write software" was made in the context of an overview of
concurrency in general. In any case, he was probably using the
"all-encompassing" definition of concurrency (which is not "wrong").

--
Bill Clementson

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Extending Clojure's STM with external transactions

2008-12-03 Thread Dave Griffith


It often happens that I would like to have gaurantees about the
consistency of in-memory data structures and external resources.  For
instance, in the last two large systems I've built, the system would
respond to an external message received via socket, do some complex
processing based on the contents of the message which modified it's
internal state, write a log of the message to a database and update
some other database tables so that the internal state of the system
was reconstructable in case of crash, and then send some other
messages to clients via socket.  This all had to either work, or not
work, with full ACID properties for the system as a whole (both the
database and memory).  This was an enormous pain, requiring in-memory
rollback functionality to be coded by hand for each and every possible
interaction.

It seems like it should be possible to extend the STM semantics of
Clojure to allow this sort of thing to Just Work.  From the user point
of view, one would call dosync-external, rather than dosync, and pass
it an external (JTA?) transaction manager along with the operations to
be executed.  If either the in-memory operations or the external
operations required rollback, then both would be, otherwise both would
be committed.  If committed, any agent sends that the transaction had
sent would occur.  Simple to use, and pretty much exactly what's
required for a high-reliability message processing engine.  Literally
thousands of lines of code would disappear from each of my last two
projects.

Looking over the current implementation of Clojure, I think I've
convinced myself of the following facts.

1) This can't be done purely in Clojure code itself, as the necessary
hooks into the STM don't exist (nor, I would argue, should they).

2) This could be done pretty easily by hacking the Clojure runtime, at
a (obviously excessive) cost of inducing a hard dependency between the
core runtime and some particular transaction manager.  The STM
implementation already has enough of a two-phase commit structure to
make it pretty easy to integrate with any given transaction management
system.

3) Creating some sort of plugin system so that arbitrary transaction
managers could be integrated with the Clojure STM runtime is doable,
but doesn't much fit with the current architecture.

4) If one were to do such a thing, it would be pretty easy to extend
the STM with features like timeouts and such.

Thoughts? Am I missing anything?  Has this already been attempted in
some way I was unable to google for?  My temptation is to try to
implement something as a quick spike and see how it works.

--Dave Griffith



--~--~-~--~~~---~--~~
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: slime+clojure problem

2008-12-03 Thread Dimitre Liotev

Vijay Lakshminarayanan wrote:
> If you've got enough time to spare, I'd recommend trying out the
> clojurebox that was released a few days ago.  I installed it, ensured
> it worked and then replicated that in my .emacs.
>
> Once you have a basic setup working you can easily make the needed
> changes to run the latest version.
>
>   

I am not sure if you are replying to me - my clojure setup works, as 
described below.
I guess Clojurebox is good for people who are not familiar with Emacs.

> On Wed, Dec 3, 2008 at 6:19 PM, Dimitre Liotev <[EMAIL PROTECTED]> wrote:
>   
>> If you have set "slime-lisp-implementations", make sure the entry for
>> clojure looks like this:
>>
>> (clojure ("clojure") :init swank-clojure-init)
>>
>> For example, my slime-lisp-implementations is:
>>
>>   (setq slime-lisp-implementations
>> `(
>>   (sbcl ("sbcl"))
>>   (ccl ("ccl"))
>>   (clojure ("clojure") :init swank-clojure-init)
>>   (clisp ("clisp"))
>>   (abcl ("abcl"))
>>   (cmucl ("lisp"))
>>   (s48 ("scheme48") :init slime48-init-command)
>>
>>
>>
>> If I specify (clojure ("clojure")) instead of (clojure (clojure") :init
>> swank-clojure-init), I get the same error as you.
>>
>> --
>> dl
>> 

--
Dimitre Liotev

--~--~-~--~~~---~--~~
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: AOT Compilation for Contrib

2008-12-03 Thread Meikel Brandmeyer

Hello Stephen,

Am 03.12.2008 um 20:35 schrieb Stephen C. Gilardi:

Can we make clojure-contrib/build.xml work such that if you specify a
location for a clojure.jar as a property, it compiles (the stand-alone
compilable parts of ) clojure-contrib into clojure-contrib.jar, but if
you don't specify the location it just jars up the clojure-contrib
sources?

That would be one flexible way to handle needing clojure.jar in order
to compile, but not wanting an absolute dependency.

Alternatively, perhaps clojure/build.xml should build
clojure-contrib.jar if it's told where to find the clojure-contrib
source directory.

Any thoughts?


Hmm.. having clojure/build.xml compile clojure-contrib is somehow
contrary to the "not an absolute dependency" idea.

I think your initial suggestion, is a good idea. I changed the
build.xml file to look for a property called clojure.jar. If it
exists, we use it and compile the libraries. Otherwise - well -
we don't...

Invocation: ant -Dclojure.jar=/path/to/clojure.jar

Sincerely
Meikel



  
Pack all clojure-contrib sources into a JAR.
  

  
  

  

  
  

  


  

  


  

  

  



  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

  

  

  
  
  
  

  

  






smime.p7s
Description: S/MIME cryptographic signature


Re: Embedding Clojure/swank into existing Java system

2008-12-03 Thread Anton Vodonosov

Hi Craig,

clojure.main/with-bindings was exactly what I needed.
With it my JSP became trivial few liner: http://paste.lisp.org/display/71541

Thank you.

- Anton
--~--~-~--~~~---~--~~
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: Building regex pattern literals (Noob question)

2008-12-03 Thread Blaine

I'm all straightened out.  Thanks everyone.  Very helpful.

On Dec 3, 3:18 pm, Chouser <[EMAIL PROTECTED]> wrote:
> On Wed, Dec 3, 2008 at 2:57 PM, Blaine <[EMAIL PROTECTED]> wrote:
>
> > I want to build a regular expression pattern literal (I think that's
> > what they're called) like #"a.*" out of separate strings like "a" and
> > ".*".
>
> > user> (re-seq #"a.*" "bab")   ; this is cool
> > ("ab")
> > user> (re-seq #(str "a" ".*") "bab")  ; but this, in all its noobness, is 
> > not
> > ; Evaluation aborted.
> > user> #(str "a" ".*")
> > #  ; what
> > is this thing?  can I use it somehow?
>
> It's a function!  You could have built the same thing like this:
> user=> (fn [] (str "a" ".*"))
> #
>
> You can use it, but it has nothing to do with regex:
> user=> (def thing #(str "a" ".*"))
> #'user/thing
> user=> (thing)
> "a.*"
>
> It's just a function that returns a literal string.  A "regex" in
> Clojure/Java is actually a java.util.regex.Pattern:
> user=> (class #"")
> java.util.regex.Pattern
>
> To programmatically build one, you'll have to use that class directly,
> or 're-pattern':
> user=> (doc re-pattern)
> -
> clojure.core/re-pattern
> ([s])
>   Returns an instance of java.util.regex.Pattern, for use, e.g. in
>   re-matcher.
> nil
> user=> (re-pattern (str "a" ".*"))
> #"a.*"
>
> ...so back to your original example:
> user=> (re-seq (re-pattern (str "a" ".*")) "bab")
> ("ab")
>
> But remember that you may need extra backslashes inside the "string"
> parts, compared to the equivalent #"regex" literal.
>
> Or if each piece of your regex can stand alone, you could take
> advantage of the fact that the .toString method on Pattern returns a
> sufficiently escaped string:
>
> user=> (re-seq (re-pattern (str #"s" #"\w*")) "sue sang a song")
> ("sue" "sang" "song")
>
> --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: AOT Compilation for Contrib

2008-12-03 Thread Stephen C. Gilardi


On Dec 3, 2008, at 4:23 PM, Meikel Brandmeyer wrote:

> I think your initial suggestion, is a good idea. I changed the
> build.xml file to look for a property called clojure.jar. If it
> exists, we use it and compile the libraries. Otherwise - well -
> we don't...
>
> Invocation: ant -Dclojure.jar=/path/to/clojure.jar

Excellent, thanks! I've checked that in.

Now (most of) contrib will be compiled and the class files placed in  
clojure-contrib.jar file if the ant property "clojure.jar" points to  
clojure.jar (as shown in Meikel's example above).

This allows contribs to have "main" routines and in other ways take  
advantage of AOT compilation goodness.

The parts of contrib that aren't compiled are the parts that depend on  
third party libraries.

--Steve

(Next we just need to work on getting the build time down...)

  Buildfile: build.xml

  init:
  [mkdir] Created dir: /ext/clojure-contrib/classes

  compile_clojure:
   [java] Compiling clojure.contrib.command-line to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.cond to /ext/clojure-contrib/ 
classes
   [java] Compiling clojure.contrib.def to /ext/clojure-contrib/ 
classes
   [java] Compiling clojure.contrib.duck-streams to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.except to /ext/clojure-contrib/ 
classes
   [java] Compiling clojure.contrib.fcase to /ext/clojure-contrib/ 
classes
   [java] Compiling clojure.contrib.import-static to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.javadoc to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.lazy-seqs to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.memoize to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.mmap to /ext/clojure-contrib/ 
classes
   [java] Compiling clojure.contrib.ns-utils to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.pred to /ext/clojure-contrib/ 
classes
   [java] Compiling clojure.contrib.repl-ln to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.seq-utils to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.sql.internal to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.sql to /ext/clojure-contrib/ 
classes
   [java] Compiling clojure.contrib.str-utils to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.test-is to /ext/clojure- 
contrib/classes
   [java] Compiling clojure.contrib.trace to /ext/clojure-contrib/ 
classes
   [java] Compiling clojure.contrib.zip-filter to /ext/clojure- 
contrib/classes

  jar:
[jar] Building jar: /ext/clojure-contrib/clojure-contrib.jar

  BUILD SUCCESSFUL
  Total time: 2 seconds


--~--~-~--~~~---~--~~
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 indentation conventions

2008-12-03 Thread levand

I am coming to Clojure from the Java side, and am completely ignorant
about lisp indentation & newline conventions.

Some things are easy to pick up from posted examples and common
sense...newline + tab after the parameters vector when defining a
function, etc.

But I did some web searches on lisp & emacs conventions, and some
things aren't so clear. For example, this googled web page (http://
dept-info.labri.u-bordeaux.fr/~strandh/Teaching/MTP/Common/Strandh-
Tutorial/indentation.html) indicates that in the "if" special form,
each sub-expression should be aligned. Is this accomplished by tabs +
spaces until they align? What if the editor isn't using a fixed-width
font (or is it assumed that it always is?) Or is that the emacs editor
aligning things irrespective of what whitespace characters are really
there?

Which leads to the other immortal question - tab characters, or [n]
consecutive spaces? I'm fairly ambivalent myself and can go either
way, but is there a clear preferred way in the clojure community that
I would be better served by adhering to?

Does anyone know of a reference for, or would care to enumerate what
standard clojure indenting ought to be?

I'm particularly interested in this as I've been hacking about with a
clojure eclipse plugin for my own use and am considering adding auto-
indent features.

--~--~-~--~~~---~--~~
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: AOT Compilation for Contrib

2008-12-03 Thread Drew Olson
On Wed, Dec 3, 2008 at 5:27 PM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote:

 Buildfile: build.xml
>
>  init:
>  [mkdir] Created dir: /ext/clojure-contrib/classes
>
>  compile_clojure:
>   [java] Compiling clojure.contrib.command-line to /ext/clojure-
> contrib/classes
>   [java] Compiling clojure.contrib.cond to /ext/clojure-contrib/
> classes
>   [java] Compiling clojure.contrib.def to /ext/clojure-contrib/
> classes
>   [java] Compiling clojure.contrib.duck-streams to /ext/clojure-
> contrib/classes

...

Seeing this output brings up a question for me: why doesn't
clojure.lang.Compile behave like javac in that it will recursively compile
all source files in a directory structure. It seems like it would be much
nicer to say:

java -cp /path/to/clojure.jar clojure.lang.compile clojure.contrib

and have all sub-namespaces (not sure this is a word?) compile. Maybe it
should take a directory rather than a namespace:

java -cp /path/to/clojure.jar clojure.lang.compile src

Also, is their a reason why the compile destination can not be passed as a
command line argument?

- Drew

--~--~-~--~~~---~--~~
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 indentation conventions

2008-12-03 Thread Meikel Brandmeyer

Hi,

Am 03.12.2008 um 22:06 schrieb levand:

I am coming to Clojure from the Java side, and am completely ignorant
about lisp indentation & newline conventions.


Good. Then you aren't spoiled, yet. ;)

My advice: get a reasonable editor like emacs or vim and
the corresponding clojure modes. They will help you with
automatic indentation. Just go with that and you won't have
problems.


Which leads to the other immortal question - tab characters, or [n]
consecutive spaces? I'm fairly ambivalent myself and can go either
way, but is there a clear preferred way in the clojure community that
I would be better served by adhering to?


Never ever use tabs. Eg.

(some-function xxx
   yyy)

is one way to format a multi-line function call. Mixing tabs and
spaces in front of the yyy just begs for ugly effects for people
with different tab settings. And since the function name in general
doesn't align well with tabs you need spaces anyway. So use only
spaces.


Does anyone know of a reference for, or would care to enumerate what
standard clojure indenting ought to be?


Personally, I like the vim way of indenting. But that's not a
reference of course.


I'm particularly interested in this as I've been hacking about with a
clojure eclipse plugin for my own use and am considering adding auto-
indent features.


In that case, I'd suggest to pick a style you like from an other
editor or a particular library (eg. clojure.core itself) and try
to implement that.

This easily turns into religious flame wars. So my Disclaimer:
Nothing of the said (except maybe the tab thing) is any reference
and your mileage may vary!

Sincerely
Meikel




smime.p7s
Description: S/MIME cryptographic signature


Monadic Parsing

2008-12-03 Thread jim

Continuing with the monad theme, I decided to implement monadic
parsing in Clojure.  Erik Meijer and Graham Hutton published a paper
called "Monadic Parsing in Haskell" and I implemented the examples
from that paper in Clojure.  The code is available here:

http://groups.google.com/group/clojure/web/monad-parser.clj

And you also need the monad code from here:

http://clojure.googlegroups.com/web/monad-redux.clj

The code is uncommented and should be read in parallel with the
original paper from here (pdf):

http://www.cs.nott.ac.uk/~gmh/pearl.pdf

Comments welcome.

Next up: monad transformers

Jim
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



For Comprehension and println (Noob Question)

2008-12-03 Thread aria42

Hi all,
  When I run the following from the REPL, I see the result of the
"println"

(defn read-docs [duc-dir]
  (for [file (.listFiles (java.io.File. duc-dir))
  :when (.isFile file)]
   (do
 (println file)
 (.getName  file


  However, when embedded in a script (using clojure.lang.Script), I
don't see the result of the println. I'm primarily using it for
debugging the compreshension variables.

   Thanks a lot, Aria


--~--~-~--~~~---~--~~
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: Extending Clojure's STM with external transactions

2008-12-03 Thread Rich Hickey



On Dec 3, 3:48 pm, Dave Griffith <[EMAIL PROTECTED]> wrote:
> It often happens that I would like to have gaurantees about the
> consistency of in-memory data structures and external resources.  For
> instance, in the last two large systems I've built, the system would
> respond to an external message received via socket, do some complex
> processing based on the contents of the message which modified it's
> internal state, write a log of the message to a database and update
> some other database tables so that the internal state of the system
> was reconstructable in case of crash, and then send some other
> messages to clients via socket.  This all had to either work, or not
> work, with full ACID properties for the system as a whole (both the
> database and memory).  This was an enormous pain, requiring in-memory
> rollback functionality to be coded by hand for each and every possible
> interaction.
>
> It seems like it should be possible to extend the STM semantics of
> Clojure to allow this sort of thing to Just Work.  From the user point
> of view, one would call dosync-external, rather than dosync, and pass
> it an external (JTA?) transaction manager along with the operations to
> be executed.  If either the in-memory operations or the external
> operations required rollback, then both would be, otherwise both would
> be committed.  If committed, any agent sends that the transaction had
> sent would occur.  Simple to use, and pretty much exactly what's
> required for a high-reliability message processing engine.  Literally
> thousands of lines of code would disappear from each of my last two
> projects.
>
> Looking over the current implementation of Clojure, I think I've
> convinced myself of the following facts.
>
> 1) This can't be done purely in Clojure code itself, as the necessary
> hooks into the STM don't exist (nor, I would argue, should they).
>
> 2) This could be done pretty easily by hacking the Clojure runtime, at
> a (obviously excessive) cost of inducing a hard dependency between the
> core runtime and some particular transaction manager.  The STM
> implementation already has enough of a two-phase commit structure to
> make it pretty easy to integrate with any given transaction management
> system.
>
> 3) Creating some sort of plugin system so that arbitrary transaction
> managers could be integrated with the Clojure STM runtime is doable,
> but doesn't much fit with the current architecture.
>
> 4) If one were to do such a thing, it would be pretty easy to extend
> the STM with features like timeouts and such.
>
> Thoughts? Am I missing anything?  Has this already been attempted in
> some way I was unable to google for?  My temptation is to try to
> implement something as a quick spike and see how it works.
>

It's definitely an interesting idea - I don't think anyone is working
on it. I don't have enough knowledge of JTA/XA to do it myself, but
could provide advice about integration with the STM.

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: change in doto behavior

2008-12-03 Thread Blaine

The example on http://clojure.org/jvm_hosted should reflect this.  I'm
not sure this is the proper venue to report such stuff.  I've used
this example (successfully) to convince those that normally walk away
when I start talking about lisp to give clojure a look.  I just cut
and paste it into the repl.  It may be boring, but when you have only
seconds for the pitch...

On Dec 2, 10:12 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote:
> Yes.dotois more general now. The . is needed to indicate Java  
> interop calls becausedotocan do other things which are not Java  
> interop calls:
>
>   (doto"double" println println)
> double
> double
> -> "double"
>
> Stuart
>
> > Can someone tell me whether this change was intentional?  In the
> > 20080916 release, I get this:
>
> > user=> (doto(new java.util.HashMap) (.put "a" "b"))
> > java.lang.IllegalArgumentException: No matching method found: .put
> > java.lang.IllegalArgumentException: No matching method found: .put
> >    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:44)
> >    at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
> >    at user.eval__4117.invoke(Unknown Source)
> >    at clojure.lang.Compiler.eval(Compiler.java:3891)
> >    at clojure.lang.Repl.main(Repl.java:75)
> > user=> (doto(new java.util.HashMap) (put "a" "b"))
> > {a=b}
>
> > In revision 1139, I get this:
>
> > user=> (doto(new java.util.HashMap) (put "a" "b"))
> > java.lang.Exception: Unable to resolve symbol: put in this context
> > (NO_SOURCE_FILE:2)
> > user=> (doto(new java.util.HashMap) (.put "a" "b"))
> > #=(java.util.HashMap. {"a" "b"})
>
> > I'm using JRE 1.6.0.10.
>
> > Bill Smith
--~--~-~--~~~---~--~~
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: For Comprehension and println (Noob Question)

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 7:19 PM, aria42 wrote:

> Hi all,
>  When I run the following from the REPL, I see the result of the
> "println"
>
> (defn read-docs [duc-dir]
>  (for [file (.listFiles (java.io.File. duc-dir))
>  :when (.isFile file)]
>   (do
> (println file)
> (.getName  file
>
>
>  However, when embedded in a script (using clojure.lang.Script), I
> don't see the result of the println. I'm primarily using it for
> debugging the compreshension variables.
>
>   Thanks a lot, Aria

Hi Aria,

The result returned by the "for" function is a lazy sequence. It will  
only produce as many values as are actually requested by its caller.  
In the case of the repl, the "print" part of the read-eval-print-loop  
will force it to produce all the results. In the case of Script, there  
is nothing to force the output, so it will never be produced and  
println won't be called.

If your primary goal is the side-effect produced by "println", doseq  
(which has recently been upgraded to be a complete non-lazy  
counterpart to "for") should do the trick. Just drop it in in place of  
"for". (it will ignore the result returned by (.getName file) in that  
case, so that can and should be removed.) Another way to do this would  
be to pass the result of "for" to "dorun".

If your primary goal is to get the sequence of names, continue to use  
"for" and avoid the "println", but understand that unless you do  
something with the result, it won't actually be produced. A way to  
"force" all items to be evaluated is to pass the result of "for" to  
"doall".

In either case, you'll avoid the confusing mixture of output that gets  
printed by the code you posted.

--Steve


--~--~-~--~~~---~--~~
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 indentation conventions

2008-12-03 Thread Mark Volkmann

On Wed, Dec 3, 2008 at 4:49 PM, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Am 03.12.2008 um 22:06 schrieb levand:
>>
>> I am coming to Clojure from the Java side, and am completely ignorant
>> about lisp indentation & newline conventions.
>
> Good. Then you aren't spoiled, yet. ;)
>
> My advice: get a reasonable editor like emacs or vim and
> the corresponding clojure modes. They will help you with
> automatic indentation. Just go with that and you won't have
> problems.
>
>> Which leads to the other immortal question - tab characters, or [n]
>> consecutive spaces? I'm fairly ambivalent myself and can go either
>> way, but is there a clear preferred way in the clojure community that
>> I would be better served by adhering to?
>
> Never ever use tabs. Eg.
>
> (some-function xxx
>   yyy)
>
> is one way to format a multi-line function call. Mixing tabs and
> spaces in front of the yyy just begs for ugly effects for people
> with different tab settings. And since the function name in general
> doesn't align well with tabs you need spaces anyway. So use only
> spaces.
>
>> Does anyone know of a reference for, or would care to enumerate what
>> standard clojure indenting ought to be?
>
> Personally, I like the vim way of indenting. But that's not a
> reference of course.
>
>> I'm particularly interested in this as I've been hacking about with a
>> clojure eclipse plugin for my own use and am considering adding auto-
>> indent features.
>
> In that case, I'd suggest to pick a style you like from an other
> editor or a particular library (eg. clojure.core itself) and try
> to implement that.
>
> This easily turns into religious flame wars. So my Disclaimer:
> Nothing of the said (except maybe the tab thing) is any reference
> and your mileage may vary!

I would like it if the team of Clojure committers would come up with
some basic guidelines for formatting code and maybe some advice that
goes beyond formatting. The kinds of guidelines I'd like to see are
the following:

Limit line lengths, perhaps to 80. Why 80? Because it works well with
printers and long lines of code are harder to quickly understand.

Limit the number of lines in a single function, perhaps with a goal of
15 being an upper limit. Why? Because it can be time consuming to
figure out what a long function is doing. If a function is longer than
that, odds are it is doing more than one fundamental thing and can be
broken into smaller, perhaps private, well-named functions that are
called from the original function. This can dramatically reduce the
need for comments.

Either put all the arguments to a function on a single line (if it
will fit in the line length limit) or put each argument on a separate
line. Anything else is harder to read.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: A try on condp (was: Re: proposal: match multimethod)

2008-12-03 Thread Rich Hickey



On Dec 3, 2:51 pm, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
> Hi Stuart and Rich,
>
> Am 03.12.2008 um 19:00 schrieb Stuart Sierra:
>
> >> I'm pretty sure I don't like the sound of that at all. We had a nice
> >> discussion about fcase/condf, which I'd like to get in, here:
>
> >>http://groups.google.com/group/clojure/browse_frm/thread/
> >> dee910bef629...
>
> > And I haven't forgotten about that, just haven't had time to work on
> > it.  Anyone else who wants to tackle it is welcome.
>
> How about the following:
>
> (defmacro condp
>"condp compares the given needle with the first clause using the
> given
>predicate. In case the predicate returns true the second clause is
>returned. Otherwise condp goes on with the rest of the clauses. In
>case there is an odd number of clauses the last one will be returned
>if no preceding clause matched. If no default clause is given an
>exception is thrown. The predicate is called with needle as first
>argument and the first clause as second argument."
>[pred needle & clauses]
>(let [c(count clauses)
>  par  (rem c 2)
>  cls  (take (if (zero? par) c (dec c)) clauses)
>  cls  (mapcat (fn [[x c]] `[(~xprd ~xndl ~x) ~c]) (partition 2
> cls))
>  xndl (gensym "condp_needle__")
>  xprd (gensym "condp_predicate__")
>  lst  (if (zero? par)
> `(throw (Exception. (str "No condp clause matched for: "
>  (prn-str ~xndl
> (last clauses))]
>  `(let [~xprd ~pred
> ~xndl ~needle]
> (cond
>   [EMAIL PROTECTED]
>   :else ~lst
>
> I mulled about the (x _) syntax, but to be honest: I think #() is
> perfectly sufficient. We would need to quote all the contents to
> prevent multiple evaluation, but then we have to recurse and check
> for _ vs. non-_...
>
> I expect the predicate to be a function of two arguments with the first
> being the needle and the second being the clause, we compare to.
> Predicates where order doesn't matter or the order agrees may be simply
> used. Others or more complicated expressions can be wrapped in a #().
> Here we still have a problem for #(pred (complicated-computation) %2
> %1)
>
> In case the number of clauses is even, and no clause matched the
> predicate, we throw an exception. In case the number of clauses is
> odd, we return the last one as default. I think adding a simple nil
> is tolerable, making the "I ignore a failed run" explicit.
>
> What do you think?
>

needle is a strange name - what's the origin? expr is probably better.

I'm ok with odd clause is default, else throw if not match.

I think the expr should be passed second to the fn - in most cases
where it matters, that is a more useful default:

contains?, re-find, instance? etc.

I almost whipped this up yesterday, but I got sidetracked thinking
about how best to provide a feature like Scheme's cond's =>. Do you
know it? It feeds the value of the test to the fn on the rhs of the
clause. It can be useful.

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
-~--~~~~--~~--~--~---



Unary Application of (= ...)

2008-12-03 Thread Randall R Schulz

Hi,

What's the rationale for accepting unary applications of =?

To wit:

user=> (= nil)
true

user=> (= true)
true

user=> (= false)
true

user=> (= 0)
true

user=> (= 1)
true

user=> (= =)
true

etc.


By the way, I do understand while (or) is false and (and) is true, but I 
don't see why = allows a single argument.


Randall Schulz

--~--~-~--~~~---~--~~
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: Unary Application of (= ...)

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 9:15 PM, Randall R Schulz wrote:

> By the way, I do understand while (or) is false and (and) is true,  
> but I
> don't see why = allows a single argument.

I don't know the answer, but I do see it making sense as the final  
value in this sequence:

(= 1 1 1 ...)
(= 1 1 1)
(= 1 1)
(= 1)

They all return true and in each case it means "all the arguments have  
the same value".

--Steve


--~--~-~--~~~---~--~~
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: Unary Application of (= ...)

2008-12-03 Thread Randall R Schulz

On Wednesday 03 December 2008 18:28, Stephen C. Gilardi wrote:
> On Dec 3, 2008, at 9:15 PM, Randall R Schulz wrote:
> > By the way, I do understand while (or) is false and (and) is true,
> > but I don't see why = allows a single argument.
>
> I don't know the answer, but I do see it making sense as the final
> value in this sequence:
>
> (= 1 1 1 ...)
> (= 1 1 1)
> (= 1 1)
> (= 1)
>
> They all return true and in each case it means "all the arguments
> have the same value".

OK, so it's consistent with the null-ary (and) (no argument is false) 
and (or) (there is a true argument). But from that perspective, 
shouldn't the definition extend to the null-ary case, too?

But I wonder if this doesn't just induce more debugging than is 
necessary. That was the case for me (if it wasn't apparent).


> --Steve


Randall Schulz

--~--~-~--~~~---~--~~
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: Unary Application of (= ...)

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 9:39 PM, Randall R Schulz wrote:

> OK, so it's consistent with the null-ary (and) (no argument is false)
> and (or) (there is a true argument). But from that perspective,
> shouldn't the definition extend to the null-ary case, too?


I think not. How would you decide the values of (=) and (not=)?  
Presumably one should be true and one should be false.

You can also look at (and) and (or) and (+) and (*) as each returning  
the identity element for their operation. There is no such identity  
element for =. That may put it in the same boat as (-) and (/) which  
really require at least one argument to make some sense.

--Steve


--~--~-~--~~~---~--~~
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: Unary Application of (= ...)

2008-12-03 Thread Randall R Schulz

On Wednesday 03 December 2008 18:48, Stephen C. Gilardi wrote:
> On Dec 3, 2008, at 9:39 PM, Randall R Schulz wrote:
> > OK, so it's consistent with the null-ary (and) (no argument is
> > false) and (or) (there is a true argument). But from that
> > perspective, shouldn't the definition extend to the null-ary case,
> > too?
>
> I think not. How would you decide the values of (=) and (not=)?
> Presumably one should be true and one should be false.
>
> You can also look at (and) and (or) and (+) and (*) as each returning
> the identity element for their operation. There is no such identity
> element for =. That may put it in the same boat as (-) and (/) which
> really require at least one argument to make some sense.

OK. I'll buy that

But it is also the case that subtraction and division _do_ have identity 
elements. They follow directly from the application of the inverse 
operation to the corresponding operator's identity element. In other 
words, the identity element for division is the multiplicative inverse 
of the identity element for multiplication. Likewise for subtraction / 
addition.


> --Steve


Randall Schulz

--~--~-~--~~~---~--~~
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: slime+clojure problem

2008-12-03 Thread Vijay Lakshminarayanan

On Thu, Dec 4, 2008 at 2:33 AM, Dimitre Liotev <[EMAIL PROTECTED]> wrote:
>
> Vijay Lakshminarayanan wrote:
>> If you've got enough time to spare, I'd recommend trying out the
>> clojurebox that was released a few days ago.  I installed it, ensured
>> it worked and then replicated that in my .emacs.
>>
>> Once you have a basic setup working you can easily make the needed
>> changes to run the latest version.
>>
>>
>
> I am not sure if you are replying to me - my clojure setup works, as
> described below.
> I guess Clojurebox is good for people who are not familiar with Emacs.

I'm sorry, I subscribe to the emails so I just replied to the last
thread.  My reply was to Peter Eddy.  I guess when seeing it as a tree
it must seem weird.  I'll be more careful the next time.

Thanks
Vijay

>> On Wed, Dec 3, 2008 at 6:19 PM, Dimitre Liotev <[EMAIL PROTECTED]> wrote:
>>
>>> If you have set "slime-lisp-implementations", make sure the entry for
>>> clojure looks like this:
>>>
>>> (clojure ("clojure") :init swank-clojure-init)
>>>
>>> For example, my slime-lisp-implementations is:
>>>
>>>   (setq slime-lisp-implementations
>>> `(
>>>   (sbcl ("sbcl"))
>>>   (ccl ("ccl"))
>>>   (clojure ("clojure") :init swank-clojure-init)
>>>   (clisp ("clisp"))
>>>   (abcl ("abcl"))
>>>   (cmucl ("lisp"))
>>>   (s48 ("scheme48") :init slime48-init-command)
>>>
>>>
>>>
>>> If I specify (clojure ("clojure")) instead of (clojure (clojure") :init
>>> swank-clojure-init), I get the same error as you.
>>>
>>> --
>>> dl
>>>
>
> --
> Dimitre Liotev
>
> >
>

--~--~-~--~~~---~--~~
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: delimited continuations for web development

2008-12-03 Thread Monsieur Pinocchio

On Tue, Dec 2, 2008 at 12:52 PM "Jan Rychter" <[EMAIL PROTECTED]> wrote:
>
> Rich Hickey <[EMAIL PROTECTED]> writes:
> > On Jun 20, 11:58 am, Jaime Barciela <[EMAIL PROTECTED]> wrote:
> >> Hello Phil,
> >>
> >> My understanding is that Common Lisp doesn't have support for
> >> continuations either and that's why Weblocks uses cl-cont (http://
> >> common-lisp.net/project/cl-cont/, a library by the same author) to
> >> "fake" them
> >>
> >> The implication appears to be that you don't need compiler support for
> >> them if you have macros (which are, in a way, compiler extensions)
> >>
> >> I know the Java world has tried and the Resources section here is a
> >> good summary:http://www-128.ibm.com/developerworks/java/library/j-cb03216
> >>
> >> The search continues :)
> >>
> >> Thanks
> >> Jaime
> >>
> >> On Jun 20, 11:30 am, Phil Jordan <[EMAIL PROTECTED]> wrote:
> >>
> >> > Jaime Barciela wrote:
> >> > > Is there anybody writing or thinking about writing a continuations
> >> > > +component-based web framework for Clojure? Although I don't think I
> >> > > can carve time to start such a project myself I would be happy to
> >> > > contribute to one if it exists.
> >>
> >> > Clojure doesn't have support for continuations, and as far as I've seen,
> >> > nobody has tried anything like it. I have no idea how hard it would be
> >> > to implement them, as I'm insufficiently familiar with the JVM's guts.
> >>
> >> > However, there appear to be some continuation and coroutine libraries
> >> > for Java out there. I've never looked into these, so I don't know if
> >> > they've got any limitiations that limit the usefulness for this kind of
> >> > purpose, but if they work in Java, they should work with Clojure. Google
> >> > returns plenty of results to start digging, although at first glance it
> >> > worries me that these libraries seem to be written for Java 1.0, which,
> >> > I think, didn't yet support native threads and still used Green threads.
> >> > (effectively a way of implementing coroutines)
> >>
> > I know they are all the rage, but I am skeptical of the trend towards
> > continuation-based web apps, especially to the degree in which they
> > hold state in language-based continuations.
> >
> > First, it encourages writing apps like the old 70's style terminal
> > apps - present a menu, wait for a choice, goto the next screen etc -
> > very imperative. Yes, it's easy, and so was that. Then there were
> > event-driven interfaces, and the world moved on.
> >
> > Second, why ever would I want a client's state tied up in something as
> > opaque as a language continuation?
> >
> > Third, there are bound to be things captured in a continuation whose
> > viability is extremely time or context dependent - prices,
> > availability etc. To the extent you need to care about what is ok from
> > the captured stack and what you need to refresh on resumption,
> > continuations are insufficient.
> >
> > Fourth, the continuations freeze the application logic - what if the
> > business rules or workflow have changed since the continuation was
> > captured? Continuations reflect a view of applications as static.
> >
> > That's not to say that these frameworks aren't trying to address real
> > challenges. Some of the challenges have to do with state-transition/
> > workflow management. Some have to do with breaking the 1:1
> > relationship between connections and threads, and process re-
> > activation. There are some cool Comet capabilities in the Java servlet
> > containers that address the latter (some even call themselves
> > continuations, but are in reality event-driven).
> >
> > The short of it is that Clojure is not going to provide continuations
> > any time soon, and I encourage Clojure web framework developers to
> > think outside the box rather than chase this trend.
> 
> Rich,
> 
> I'm responding to an old thread, as I've just discovered Clojure, and
> I've just been thinking about how to start using it. I also work with
> Weblocks (and like it a lot).
> 
> Your comments are spot-on if applied to one particular approach to
> continuation-based web development. That approach is popular with
> Schemers, as Scheme supports first-class continuations as part of the
> language. There have been many presentations and demos by schemers where
> each HTTP request basically calls a continuation with the entire
> application state. This is not what Weblocks does.
> 
> Weblocks does something quite different. The continuations we're talking
> about are delimited and do not serve the purpose of freezing the
> application logic. Also, the sequential/imperative flow you mention
> isn't their main purpose. The main goal is to support actions, e.g. code
> like this:
> 
>   (defmethod render-widget-body :before ((w news-story) &rest args)
> [...]
>   (when (display-mode-toggling-enabled w)
> (ecase (display-mode-of w)
>   (:short (link "[+]" (toggle-display-mode w)))
>   (:full (link "[-]" (toggle-di

License of/permission for Clojure's logo

2008-12-03 Thread samppi

I want to put the Clojure logo:
http://clojure.googlegroups.com/web/Clojure-logo.png?gda=y8lqvUIAAABoLitVpBTEcNIQc_NHg39S6iU75fHiOxnOGiH4bfPrlzZZL8wLBEcX9EgDZpMYxIxV4u3aa4iAIyYQIqbG9naPgh6o8ccLBvP6Chud5KMzIQ

...on Wikipedia's article on Clojure. What is the license of Clojure's
logo--is it a free image? Or can Mr. Hickley give me permission to use
it on Wikipedia?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



(doc)strings after param in defn

2008-12-03 Thread Mon Key


I apologize if this has been brought up before... But, where does the
doc
string on the `my-test' defn below reside.

In case one evaluating (doc my-test returns the doc string.  In case
two (doc evaluates the string as nil).

Is this value interned with the symbol and if so where and how do I
access that value.

If not, should I be able to defn with the doc string out of place
without first passing a keyword?

;;; Doc String before param
(defn my-test
"appropriately placed documentation string for my-test"
 []
(= my-test my-test))

user> (doc my-test)
-
user/my-test
([])
  appropriately placed documentation string for my-test
nil

;;; Doc String after param
(defn my-test
 []
"misplaced documentation string for my-test"
(= my-test my-test))


user> (doc my-test)
-
user/my-test
([])
  nil
nil

--~--~-~--~~~---~--~~
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: recur won't work in tail position within cond

2008-12-03 Thread puzzler

(defn sub-til-0 [n]
  (if (zero? n) 0 (recur (dec 1

works but the equivalent

(defn sub-til-0 [n]
  (cond
   [(zero? n) 0]
   [:else (recur (dec 1))]))

does not.

Recursion is already limited enough in Clojure...  give us recur in
tail position within cond!  :)

Thanks,

Mark
--~--~-~--~~~---~--~~
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: Unary Application of (= ...)

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 9:58 PM, Randall R Schulz wrote:

> But it is also the case that subtraction and division _do_ have  
> identity
> elements. They follow directly from the application of the inverse
> operation to the corresponding operator's identity element. In other
> words, the identity element for division is the multiplicative inverse
> of the identity element for multiplication. Likewise for subtraction /
> addition.

I agree. By the identity element argument, (/) should be 1 and (-)  
should be 0.

--Steve


--~--~-~--~~~---~--~~
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: delimited continuations for web development

2008-12-03 Thread harrison clarke
the hard part about implementing continuations in a language that doesn't
already support them is that you're trying to capture it from within.

with a delimited continuation, you're capturing it from the outside, so you
don't have that problem.

--~--~-~--~~~---~--~~
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: recur won't work in tail position within cond

2008-12-03 Thread harrison clarke
did cond change syntax?

last i checked, it was

(cond (case) (expr)

 (case) (expr)

 )

--~--~-~--~~~---~--~~
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: recur won't work in tail position within cond

2008-12-03 Thread Brian Doyle
This seems to work for me:

(defn sub-til-0 [n]
(cond
  (zero? n) 0
  :else (recur (dec 1

I'm not sure what those extra ['s are for in your example.

On Wed, Dec 3, 2008 at 9:39 PM, puzzler <[EMAIL PROTECTED]> wrote:

>
> (defn sub-til-0 [n]
>  (if (zero? n) 0 (recur (dec 1
>
> works but the equivalent
>
> (defn sub-til-0 [n]
>  (cond
>   [(zero? n) 0]
>   [:else (recur (dec 1))]))
>
> does not.
>
> Recursion is already limited enough in Clojure...  give us recur in
> tail position within cond!  :)
>
> Thanks,
>
> Mark
> >
>

--~--~-~--~~~---~--~~
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: (doc)strings after param in defn

2008-12-03 Thread Stephen C. Gilardi

On Dec 3, 2008, at 11:35 PM, Mon Key wrote:

> I apologize if this has been brought up before... But, where does  
> the doc string on the `my-test' defn below reside.

It becomes metadata for the var that your defn form defines. You can  
see all the metadata with (meta (var my-test)).

> If not, should I be able to defn with the doc string out of place  
> without first passing a keyword?

I don't understand the question about the keyword.

This is a valid function:

(defn hi [] "hello")

It's not a doc string out of place, it's a function that always  
returns the same string.

--Steve


--~--~-~--~~~---~--~~
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: Unary Application of (= ...)

2008-12-03 Thread Krukow



On Dec 4, 5:40 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> I agree. By the identity element argument, (/) should be 1 and (-)  
> should be 0.
>

Regarding *the* identity argument, I think it only works if the
operator is associative. Otherwise, you can talk about a left identity
or a right identity (if it exists). A right identity for op is an x so
that for all y: y op x = y. The left identity is an x so that for all
y: x op y. Clojure seems to be using the 'right' identity argument ;-)

Anyway, another interpretation of '=' would be logical/set-theoretic:

(= o1 o2 ... on)  means: for all x,y in {o1, ... ,on} . x = y.

Then (not= o1 o2 ... on) could just be (not (= o1 o2 ... on)).

Then (=) would be true and (not=) would be false.

Kind Regards,
- Karl
--~--~-~--~~~---~--~~
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: (doc)strings after param in defn

2008-12-03 Thread Mon Key

I'm sure I'm missing something

Maybe I should re address the issue in a different way; outside of
`meta' what other way is there to do a *visual* check/comparison to
test if two otherwise identical and/or nearly identical symbols
contain identical slot values?

In the case where the `doc' string (disregarding whether it is
actually a doc string or not) is placed after the param how does one
catch this (mis)placement when examining the `meta' on the symbol
returns nil?

Following is the same series of evaluations at the REPL with better
annotation

;;; ===
;;; evaluating my-test defn with doc string *after* param
;;; ===
user> (defn my-test
 []
"misplaced documentation string for my-test"
(= my-test my-test))
#'user/my-test
;;; ===
;;; evaluating my-test with doc string *after* param
;;; ===
user> (my-test)
true
;;; ===
;; examining meta of my-test defn with doc string *after* param
;;; ===
user> (meta (var my-test))
{:ns #, :file "NO_SOURCE_FILE", :name my-
test, :arglists ([]), :line 1}
;;; ===
;;; evaluating doc of my-test defn with doc string *after* param
;;; ===
user> (doc my-test)
-
user/my-test
([])
  nil
nil
;;; ===
;;; evaluating my-test defn with doc string *before* param
;;; ===
user> (defn my-test
"appropriately placed documentation string for my-test"
 []
(= my-test my-test))
#'user/my-test
;;; ===
;;; evaluating my-test with doc string *before* param
;;; ===
user> (my-test)
true
;;; ===
;; examining meta of my-test defn with doc string *before* param
;;; ===
user> (meta (var my-test))
{:ns #, :doc "appropriately placed documentation
string for my-test", :file "NO_SOURCE_FILE", :name my-test, :arglists
([]), :line 1}
;;; ===
;; evaluating doc of my-test defn with doc string *before* param
;;; ===
user> (doc my-test)
-
user/my-test
([])
  appropriately placed documentation string for my-test
nil
;;; ===

On Dec 3, 11:58 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> On Dec 3, 2008, at 11:35 PM, Mon Key wrote:
>
> > I apologize if this has been brought up before... But, where does  
> > the doc string on the `my-test' defn below reside.
>
> It becomes metadata for the var that your defn form defines. You can  
> see all the metadata with (meta (var my-test)).
>
> > If not, should I be able to defn with the doc string out of place  
> > without first passing a keyword?
>
> I don't understand the question about the keyword.
>
> This is a valid function:
>
> (defn hi [] "hello")
>
> It's not a doc string out of place, it's a function that always  
> returns the same string.
>
> --Steve
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >