Re: Clojure Box (was Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?)

2008-11-21 Thread Geoffrey Teale
2008/11/21 Boris Schmid <[EMAIL PROTECTED]>

>
> Nice!. As a newbie, I found lispbox one of the easiest ways to set up
> a lisp + emacs on windows, so I think a clojurebox will be a good
> thing for people.
>
> (although currently I'm just using ssh to get to my work and emacs -nw
> from there.)
>

I concur - it certainly helps out a lot of people I've spoken to when I
recommend "Practical Common Lisp" to them.

I haven't read the shiny new Clojure book yet (I will do soon - just have
other things on right now), but it would be great to have an environment
like this that users on Windows/Mac/Linux/.. whatever, could grab and get
going straight away.

-- 
Geoff

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

2008-11-21 Thread Mark McGranaghan

I've created some experimental HTML docs for Clojure. You can see them
on S3:
http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html

Or, just for kicks, on Amazon's new Cloud Front CDN:
http://d2nbqsesuabw8o.cloudfront.net/tmp/doc-1116/index.html

You can see the code I used to generate them on GitHub:
http://github.com/mmcgrana/clj-doc

The generation code is open for public perusal but will require some
tweaking for public use (e.g. I still have paths hard coded). Any help
along these lines would be greatly appreciated.

Most methods in the clj-doc source have docstrings and in total its
only a couple hundred lines of code: you should be able to find your
way around if you're interested. The best entry point is bin/gen.clj.
Again, any comments or suggests would be appreciated.

I hope that some of you find this interesting/useful/helpful in your
Clojure endeavors,
- 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: Suggest allowing java property to specify *compile-path*

2008-11-21 Thread Stephen C. Gilardi


On Nov 20, 2008, at 2:04 PM, Rich Hickey wrote:

> I'm in favor. I'd like to get a single story together incorporating  
> Stuart's build.xml, his file compiler:
>
> http://groups.google.com/group/clojure/msg/4f0aa3be9a2dc79d
>
> and this path suggestion.

I've uploaded a patch that works like Stuart's file compiler, but it  
takes lib names as arguments and compiles them.

It's written in Java and works with the patched build.xml to produce a  
working clojure.jar containing only class files.

http://clojure.googlegroups.com/web/build-xml-compile.patch

It represents my take on a clean, simple story.

The Java part would be slightly simpler if my suggestion for how  
Clojure allows compile-path to be specified were embedded elsewhere in  
Clojure, but it's pretty simple as is.

It occurred to me that perhaps Repl.java, Script.java and the new  
Compile.java might be more naturally placed in a new clojure.util  
package rather than clojure.lang.

I'll appreciate hearing Stuart's and your thoughts about whether this  
is sufficient or if it needs work and whether or not we also need a  
file compiler.

--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 Box (was Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?)

2008-11-21 Thread AlamedaMike

I would find it useful. Given the number of posts on this group
concerning editor setups, I'd say that a lot of others would as well.

Mike
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure HTML Documentation

2008-11-21 Thread walterc

way cool! thanks!

On Nov 21, 4:17 pm, Mark McGranaghan <[EMAIL PROTECTED]> wrote:
> I've created some experimental HTML docs for Clojure. You can see them
> on S3:http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html
>
> Or, just for kicks, on Amazon's new Cloud Front 
> CDN:http://d2nbqsesuabw8o.cloudfront.net/tmp/doc-1116/index.html
>
> You can see the code I used to generate them on 
> GitHub:http://github.com/mmcgrana/clj-doc
>
> The generation code is open for public perusal but will require some
> tweaking for public use (e.g. I still have paths hard coded). Any help
> along these lines would be greatly appreciated.
>
> Most methods in the clj-doc source have docstrings and in total its
> only a couple hundred lines of code: you should be able to find your
> way around if you're interested. The best entry point is bin/gen.clj.
> Again, any comments or suggests would be appreciated.
>
> I hope that some of you find this interesting/useful/helpful in your
> Clojure endeavors,
> - 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
-~--~~~~--~~--~--~---



Monads in Clojure

2008-11-21 Thread Konrad Hinsen

As a first non-trivial exercice, I wrote an implementation of monads  
in Clojure. I just uploaded it to the Group:

http://clojure.googlegroups.com/web/monads.clj

The file contains the macro definitions, the definitions of three  
popular monads (maybe, list, state), and some illustrations of their  
use. Comments are welcome!

One thing I was wondering about: if I want to turn this into a  
library module, where could I place it in Java's namespace hierarchy?  
I don't have my own domain (and don't need one), and even though I  
could have it hosted somewhere (such as SourceForge), it doesn't look  
like a good idea to have the package name depend on a hosting site  
that might not be forever. How do others approach this problem?

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 Box (was Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?)

2008-11-21 Thread Dmitry Neverov

> The result so far packs all of the above features in a 46MB installer. I'm
> willing to pursue finishing it (and possibly making it smaller) if it would
> be useful to others and if I can find a place to put it up.

Great! I look forward to use it!

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



Eclipse Plugin- any plans for this?

2008-11-21 Thread [EMAIL PROTECTED]

Like it says, I was just curious if any work had been done to
integrate Clojure with the Eclipse environment?  It's pretty well the
only thing keeping me from using Clojure at the moment, and I'd guess
there are a few others like me coming from the traditional Java code-
monkey demographic, so, any info would be appreciated.
Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: offtopic - where are you come from? (poll)

2008-11-21 Thread Tim Lossen

Berlin, Germany

--~--~-~--~~~---~--~~
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: Bureaucracy has reached Wikibooks

2008-11-21 Thread Jeff Rose

I think having any barriers to entry for contributing documentation will 
without doubt cut down the amount contributed.  If quality becomes an 
issue then policies like these might make sense to look at, but until 
then a fully open system that lets people improve the content over time 
and add when it makes sense seems far preferable.

-Jeff

Meikel Brandmeyer wrote:
> Dear Clojurians,
> 
> I found out, what the problem with the wiki is.
> 
> On 15th of November there was a new "feature" installed
> on Wikibooks: "Flagged Revs"[1]. Its sublime aims are to
> improve the quality of the presented material by freezing
> known good revisions. In between, changes can be made,
> but are not shown to anonymous users. Special users
> so-called "editors" resp. "reviewers" can review a page
> and then release a new version. This should be familiar
> to any software developer.
> 
> However such status must be assigned by some administrator.
> That means, that we are now basically locked out. We can
> change the wiki, but it is not shown to the public.
> 
> The whole system also includes some kind of ranking
> system for grammar, style, content and correctness. This
> ranking is intended to provide a quality measure for
> readers to judge how much trust they should put into
> the content, or which quality they should expect from
> the writing.
> 
> However, as with all these KPI systems: you get what
> you measure.
> 
> - For grammar and spelling: we have a lot of contributors
>   from around the world - Asia, India, Europe, North and
>   South America, Australia. A lot of these people (including
>   myself) are non-native english speakers. There will
>   always be mistakes in spelling or grammar.
> 
> - For style: with so many contributors it is hard to keep
>   a consistent style across sections written by different
>   people. Let alone writing in a "compelling" style...
> 
> Concerning coverage and correctness, I fully go with
> the mentioned points (see link below). The content must
> be correct and should cover all important aspects + x.
> And if that is not the case one has to fix it.
> 
> Still I don't like this new system.
> 
> First of all we have to install some group, which is
> assigned "Editor" status. Otherwise we cannot release
> our own contributions. Some John Doe from Wikibooks
> is certainly not qualified to judge coverage or correctness
> unless he is a Clojure programmer himself.
> 
> Nevertheless, the situation is as it is. We have to cope
> with it and should discuss how to handle the wiki. I see
> the following possible ways:
> 
> - Abandon the wiki completely. People don't read it anyway,
>   and if they do their comment is "atrocious".
> 
> - Move to another hosting platform and continue with
>   the "self-organising wiki" approach.
> 
> - Stick with wikibooks and install some editor group, which
>   reviews contributions. Fixes spelling and grammar. Checks
>   correctness. Takes care for a consistent style. etc.
> 
> I strongly oppose the first point. I put it here only for
> completeness sake.
> 
> How do we proceed? Any thoughts?
> 
> Sincerely
> Meikel
> 
> [1]: http://en.wikibooks.org/wiki/Help:Article_validation
> 


--~--~-~--~~~---~--~~
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: Newbie: Creating a MapEntry

2008-11-21 Thread Rich Hickey



On Nov 21, 12:07 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> On Nov 21, 2008, at 12:03 AM, samppi wrote:
>
> > Is it possible to create a MapEntry from scratch?
>
> user=> (def a (clojure.lang.MapEntry. 3 4))
> #'user/a
> user=> (key a)
> 3
> user=> (val a)
> 4
> user=>
>
> You can also make it a little shorter by importing
> clojure.lang.MapEntry .
>

I make no promises about the continued existence of MapEntry. Please
don't use it.

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 Box (was Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?)

2008-11-21 Thread Rich Hickey



On Nov 20, 7:49 pm, "Shawn Hoover" <[EMAIL PROTECTED]> wrote:
> On Thu, Nov 20, 2008 at 8:27 AM, Daniel Renfer <[EMAIL PROTECTED]> wrote:
> > perhaps what we need is a clojure-in-a-box solution. We could create a
> > package containing a version of clojure, emacs, slime, swank-clojure,
> > clojure-mode, and clojure-contrib. This could be as simple as a zip
> > file, but even better would be to have a simple installer exe.
>
> > All a new user would have to would be to download the exe, run it, and
> > choose emacs from their start menu. Everything would already be
> > configured to work with whatever version these tools were built
> > against. You could even install links to clojure
> > documentation/resource sites. (clojure.org, the wiki, the irc logs,
> > projecture, etc.)
>
> > I, of course, focus on Windows users because they are the people that
> > would most appreciate an all-in-one installer package. You could
> > easily create packages for OSX and distros of Linux.
>
> > This wouldn't help those that already have a running version emacs
> > that they're trying to set up, but that's what the other documentation
> > sites are for.
>
> > Does anyone have experience in creating windows installers like this?
> > I could look into it if people think it's a good idea, but I'm
> > inexperienced in these matters.
>
> I made a first pass at a Windows installer today. It's similar to the
> Lispbox from gigamonkeys.com, targeting Windows users who want to try
> Clojure and are willing to learn Emacs at the same time (I wouldn't think
> this would include many users, but then again it worked out for me with the
> Lispbox). Components include a recent Emacs 23 from the EmacsW32 project and
> the latest CVS/Subversion/Git versions of Clojure, Clojure Contrib,
> clojure-mode, swank-clojure, and Slime. Once Clojure has a release I would
> want to use that and all the compatible tools.
>
> There is a single MSI that installs the programs and code, creates a
> shortcut, associates clj files, launches with minimal emacs configuration
> (hides the GNU splash screen!), and automatically starts a REPL. I couldn't
> get inferior-lisp to launch today (Java just wasn't liking my
> inferior-lisp-program). I think slime is fine for new users as long as they
> don't have to configure it. The benefit of tab-completion at the REPL makes
> it worth it. And what better welcome to Clojure than "Connected. Hack and be
> merry!"
>
> The result so far packs all of the above features in a 46MB installer. I'm
> willing to pursue finishing it (and possibly making it smaller) if it would
> be useful to others and if I can find a place to put it up.
>

I'm sure a lot of people will appreciate this, thanks, although I have
to admit to a pang of sadness that tiny Clojure comes in a box 100x
its size :(

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: mutability

2008-11-21 Thread islon

There's no problem with clojure, the problem is with me: I'm a
complete noob in clojure programming =)
That's why I asked if anyone wanted to port the game. I'll probably
learn more reading someone's idiomatic code than my own bad code.
I started this project to learn scala so the final code could probably
be done in less than 1000 LOC.
Later today I'll commit the code to github and send the link.

> Even if you have to make every
> modification inside a dosync using the syntax that you originally
> provided, why not write a function that captures that and be done with
> it? Or, if you have to, a macro?

Because:
1 - there's lot of different states with different semantics and
collections, this function/macro would need to be generic and thus
take a lot of parameters.
2 - I could made one function to each statefull data structure, anyway
would be a lot of code compared to the scala one-liner.
3 - maybe I'm mising something...

> Sure, I'd be interested in porting it, would give me a reason to learn
> Scala :).

The code is simple (except for the generate map algorithm) if you know
java and OO =)

I don't know if the clojure version will be much more concise than the
scala version.
Scala is the most "low ceremony" language i found, even more than
ruby, but idiomatic clojure is probably more, I think.

Regards.
Islon

On 21 nov, 02:41, Timothy Pratley <[EMAIL PROTECTED]> wrote:
> > Step right up folks and place your bet.
>
> Depends on the implementer, Chouser can do it in 95 LOC
--~--~-~--~~~---~--~~
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 HTML Documentation

2008-11-21 Thread Craig Andera

Very nice! As it turns out, I've been heavily involved in writing the
documentation infrastructure that MSDN uses for the last few years, so
I have some sympathy for this problem space. :)

A few things I'd like to see:

* I'd like to see the URL for the page change when navigating to a new
topic. Right now it's pretty hard to bookmark a page or email a URL to
some particular piece of documentation since the URL is always
index.html.
* I want to be able to click on a namespace and see all the symbols
for just that namespace. Would make it easy to explore the libraries
by functional area.
* I'd like to be able to get back to the home page from any other
page, or go up to the namespace page.
* Maybe the namespace page could have snippets of the doc next to the
names. Perhaps the first 30 characters of the doc string or something
simple like that.
* If this supported annotations, that would be fantastic, but
obviously that's a whole 'nother level.

On Fri, Nov 21, 2008 at 3:17 AM, Mark McGranaghan <[EMAIL PROTECTED]> wrote:
>
> I've created some experimental HTML docs for Clojure. You can see them
> on S3:
> http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html
>
> Or, just for kicks, on Amazon's new Cloud Front CDN:
> http://d2nbqsesuabw8o.cloudfront.net/tmp/doc-1116/index.html
>
> You can see the code I used to generate them on GitHub:
> http://github.com/mmcgrana/clj-doc
>
> The generation code is open for public perusal but will require some
> tweaking for public use (e.g. I still have paths hard coded). Any help
> along these lines would be greatly appreciated.
>
> Most methods in the clj-doc source have docstrings and in total its
> only a couple hundred lines of code: you should be able to find your
> way around if you're interested. The best entry point is bin/gen.clj.
> Again, any comments or suggests would be appreciated.
>
> I hope that some of you find this interesting/useful/helpful in your
> Clojure endeavors,
> - 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: Eclipse Plugin- any plans for this?

2008-11-21 Thread Ralf Bensmann
Take a look at enclojure http://www.enclojure.org (despite it'a NetBeans
plugin)

On Fri, Nov 21, 2008 at 9:25 AM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> Like it says, I was just curious if any work had been done to
> integrate Clojure with the Eclipse environment?  It's pretty well the
> only thing keeping me from using Clojure at the moment, and I'd guess
> there are a few others like me coming from the traditional Java code-
> monkey demographic, so, any info would be appreciated.
> Thanks
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure Box (was Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?)

2008-11-21 Thread Chouser

On Fri, Nov 21, 2008 at 7:39 AM, Rich Hickey <[EMAIL PROTECTED]> wrote:
>
> I'm sure a lot of people will appreciate this, thanks, although I have
> to admit to a pang of sadness that tiny Clojure comes in a box 100x
> its size :(

I would hate to discourage this in any way (or let my vim roots show
too much) but jEdit is a 2 or 3MB download.  I bet it wouldn't be very
hard to get a Clojure REPL in there.

--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: Eclipse Plugin- any plans for this?

2008-11-21 Thread MikeM


This came up on the list not long ago, don't know what the status is:

http://code.google.com/p/clojure-dev/
--~--~-~--~~~---~--~~
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 Box (was Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?)

2008-11-21 Thread blackdog

On Fri, 21 Nov 2008 07:57:16 -0500
Chouser <[EMAIL PROTECTED]> wrote:

> 
> On Fri, Nov 21, 2008 at 7:39 AM, Rich Hickey <[EMAIL PROTECTED]>
> wrote:
> >
> > I'm sure a lot of people will appreciate this, thanks, although I
> > have to admit to a pang of sadness that tiny Clojure comes in a box
> > 100x its size :(
> 
> I would hate to discourage this in any way (or let my vim roots show
> too much) but jEdit is a 2 or 3MB download.  I bet it wouldn't be very
> hard to get a Clojure REPL in there.
> 
> --Chouser
> 
> > 

I have one i didn't finish (after rediscovering emacs :)) if anyone
wants it. I should maybe upload it to the group. It has syntax
hilighting, repl, and tree (courtesy of enclojure).

bd

--~--~-~--~~~---~--~~
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: Eclipse Plugin- any plans for this?

2008-11-21 Thread Peter Wolf

I've just begun work on an IntelliJ plugin.  However since I am new to 
both Clojure and writing plugins it won't be ready for a while. 

Eventually I'll be looking for testers.
Peter

MikeM wrote:
> This came up on the list not long ago, don't know what the status is:
>
> http://code.google.com/p/clojure-dev/
> >
>
>   


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



Creating temporary namespaces from a function fails; why?

2008-11-21 Thread [EMAIL PROTECTED]

Hello all,

I am trying to set up a test for a function that finds stuff in a
sequence of namespaces given as parameter.  So, my test function must
set up temporary namespaces with some stuff, which I'll pass on to the
function for the test duration.  However, the code does not compile,
as my references to the symbols in the temporary namespace bring
namespace existence issues.  This reproduces the behavior:

(defn f []
  (try
(create-ns 'ns-a)
(in-ns 'ns-a)
(refer-clojure)
(defn fn-a [] :a/a)
(in-ns 'user)
(println ns-a/fn-a)  ; Expect some function pointer string.
(finally (remove-ns 'ns-a

This fails to compile from the REPL, with error message being

java.lang.Exception: No such namespace: ns-a (NO_SOURCE_FILE:8)

Am I trying to do something that's outside of the specification for
first-class namespaces?  Thank you for your thoughts,

Benoit
--~--~-~--~~~---~--~~
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: Creating temporary namespaces from a function fails; why?

2008-11-21 Thread [EMAIL PROTECTED]

Forgot to mention...

> (defn f []
>   (try
>     (create-ns 'ns-a)
>     (in-ns 'ns-a)
>     (refer-clojure)
>     (defn fn-a [] :a/a)
>     (in-ns 'user)
>     (println ns-a/fn-a)  ; Expect some function pointer string.
>     (finally (remove-ns 'ns-a

If I change the (println...) form for the following:

(println (all-ns))

# appears in the list and if instead it is

(println (find-ns 'ns-a))

I also get #.

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



odd behavior for use/ ns :use

2008-11-21 Thread Stuart Halloway

The "right way" to use, most of the time, is inside an ns:

(ns foo
   (:use [clojure.contrib.str-utils :only (str-join re-split)]))

However, for the interactive examples in the book, it is nice to just  
switch namespaces at the REPL, where ns is bad form. So instead, you  
would do this:

(in-ns 'bar)
-> #
(clojure.core/use [clojure.contrib.str-utils :only (str-join re-split)])
-> java.lang.ClassNotFoundException: clojure.contrib.str-utils  
(NO_SOURCE_FILE:10)

Except, as you can see, it doesn't work. You have to quote the vector:

(clojure.core/use '[clojure.contrib.str-utils :only (str-join re- 
split)])
-> nil

Is this by design? Quoting a vector doesn't feel right.

Stuart

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure HTML Documentation

2008-11-21 Thread Konrad Hinsen

On Nov 21, 2008, at 9:17, Mark McGranaghan wrote:

> I've created some experimental HTML docs for Clojure. You can see them
> on S3:
> http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html

Very useful, thanks!

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: loss of gen-and-load-class functionality

2008-11-21 Thread Rich Hickey



On Nov 20, 4:42 pm, Stuart Sierra <[EMAIL PROTECTED]> wrote:
> On Nov 20, 2:14 pm, Stephen Wrobleski <[EMAIL PROTECTED]> wrote:
>
> > Furthermore, requiring the use of (ns ..) to create a class makes defining a
> > class with a macro somewhat tedious (seems like you'd have to bind *ns*, so
> > that (ns ..) could mutate it), if even possible.
>
> This is probably temporary, but it's something to think about.  I have
> also used macros to define classes with gen-and-save-class.
> -S

I'd appreciate examples of gen-and-load-class and gen-and-save-class
use not well supported by the AOT gen-class.

What I am interested in is the scenarios/use-cases.

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: odd behavior for use/ ns :use

2008-11-21 Thread Stephen C. Gilardi

On Nov 21, 2008, at 8:39 AM, Stuart Halloway wrote:

> The "right way" to use, most of the time, is inside an ns:
>
> (ns foo
>   (:use [clojure.contrib.str-utils :only (str-join re-split)]))
>
> However, for the interactive examples in the book, it is nice to just
> switch namespaces at the REPL, where ns is bad form. So instead, you
> would do this:
>
> (in-ns 'bar)
> -> #
> (clojure.core/use [clojure.contrib.str-utils :only (str-join re- 
> split)])
> -> java.lang.ClassNotFoundException: clojure.contrib.str-utils
> (NO_SOURCE_FILE:10)
>
> Except, as you can see, it doesn't work. You have to quote the vector:
>
> (clojure.core/use '[clojure.contrib.str-utils :only (str-join re-
> split)])
> -> nil
>
> Is this by design? Quoting a vector doesn't feel right.

The arguments to use are evaluated. Symbols and lists need quoting to  
represent themselves rather than being resolved and evaluated  
(symbols) or treated as a call (lists). You can quote the vector or  
you can quote individual symbols and lists.

user=> (clojure.core/use ['clojure.contrib.str-utils :only '(str-join  
re-split)])
nil

I prefer to quote the vector.

At one time require and use were macros. I changed that when I saw  
that it was somewhat difficult to drive them from another program:  
since their arguments were not evaluated, the arguments couldn't be  
stored in a var or passed along as arguments by another function, for  
example.

Rich mused about making them macros again at one point to avoid this  
quoting. Perhaps the convenient use of requre/use/refer/in-ns at the  
repl is a significantly more important use case than passing their  
arguments in a way that requires evaluation and we should revisit  
making the whole suite of them macros.

--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: Monads in Clojure

2008-11-21 Thread walterc

how about clojure-contrib?

On Nov 21, 7:14 pm, Konrad Hinsen <[EMAIL PROTECTED]> wrote:
> As a first non-trivial exercice, I wrote an implementation of monads  
> in Clojure. I just uploaded it to the Group:
>
>        http://clojure.googlegroups.com/web/monads.clj
>
> The file contains the macro definitions, the definitions of three  
> popular monads (maybe, list, state), and some illustrations of their  
> use. Comments are welcome!
>
> One thing I was wondering about: if I want to turn this into a  
> library module, where could I place it in Java's namespace hierarchy?  
> I don't have my own domain (and don't need one), and even though I  
> could have it hosted somewhere (such as SourceForge), it doesn't look  
> like a good idea to have the package name depend on a hosting site  
> that might not be forever. How do others approach this problem?
>
> 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: odd behavior for use/ ns :use

2008-11-21 Thread Stuart Halloway

> Rich mused about making them macros again at one point to avoid this  
> quoting. Perhaps the convenient use of requre/use/refer/in-ns at the  
> repl is a significantly more important use case than passing their  
> arguments in a way that requires evaluation and we should revisit  
> making the whole suite of them macros.

Hi Steve,

Thanks for the clarification of the history. I am fine with leaving it  
as-is.

Stuart


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: loss of gen-and-load-class functionality

2008-11-21 Thread Robert Lally
I'm not entirely clear how the new AOT compilation works, or how I convert
old code to use the new mechanism.

As an example - I had a call to gen-and-save-class in a file that created a
custom exception type just before the function that would throw it was
defined. I've changed that to just gen-class, which I hoped would create a
class that could be found - but it doesn't seem to work. I had assumed that
gen-and-save-class was coming back since it is just commented out in the
source file, but if I don't need it .. great. Any guidance on the new
functionality would be appreciated.


R.

2008/11/21 Rich Hickey <[EMAIL PROTECTED]>

>
>
>
> On Nov 20, 4:42 pm, Stuart Sierra <[EMAIL PROTECTED]> wrote:
> > On Nov 20, 2:14 pm, Stephen Wrobleski <[EMAIL PROTECTED]> wrote:
> >
> > > Furthermore, requiring the use of (ns ..) to create a class makes
> defining a
> > > class with a macro somewhat tedious (seems like you'd have to bind
> *ns*, so
> > > that (ns ..) could mutate it), if even possible.
> >
> > This is probably temporary, but it's something to think about.  I have
> > also used macros to define classes with gen-and-save-class.
> > -S
>
> I'd appreciate examples of gen-and-load-class and gen-and-save-class
> use not well supported by the AOT gen-class.
>
> What I am interested in is the scenarios/use-cases.
>
> 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: Creating temporary namespaces from a function fails; why?

2008-11-21 Thread Michael Reid

Hi,

I think what is going on here is that the namespace ns-a does not
exist until the code is executed; however, in order execute the code
it must be first compiled.

It is during the compilation phase that the namespace 'ns-a' cannot be
found, because indeed, it does not yet exist.

I cannot think of an easy way around this at the moment. I'm curious
what the reasoning behind creating this temporary namespace is?

There may be a different approach that won't get you caught up between
the compilation/execution phases.

/mike.

On Fri, Nov 21, 2008 at 8:31 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Forgot to mention...
>
>> (defn f []
>>   (try
>> (create-ns 'ns-a)
>> (in-ns 'ns-a)
>> (refer-clojure)
>> (defn fn-a [] :a/a)
>> (in-ns 'user)
>> (println ns-a/fn-a)  ; Expect some function pointer string.
>> (finally (remove-ns 'ns-a
>
> If I change the (println...) form for the following:
>
> (println (all-ns))
>
> # appears in the list and if instead it is
>
> (println (find-ns 'ns-a))
>
> I also get #.
>
> Benoit
> >
>

--~--~-~--~~~---~--~~
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 Box (was Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?)

2008-11-21 Thread Shawn Hoover
On Fri, Nov 21, 2008 at 7:57 AM, Chouser <[EMAIL PROTECTED]> wrote:

>
> On Fri, Nov 21, 2008 at 7:39 AM, Rich Hickey <[EMAIL PROTECTED]> wrote:
> >
> > I'm sure a lot of people will appreciate this, thanks, although I have
> > to admit to a pang of sadness that tiny Clojure comes in a box 100x
> > its size :(
>
> I would hate to discourage this in any way (or let my vim roots show
> too much) but jEdit is a 2 or 3MB download.  I bet it wouldn't be very
> hard to get a Clojure REPL in there.
>
> --Chouser
>

Thanks for the feedback, folks. The size does bother me a little (adding
Emacs is like adding another Java runtime or JDK, in terms of size and
learning), but given the interest shown so far and the usefulness of the
Lispbox, I think this will serve some subset of users. I'll see what I can
do. If someone publishes a tidy jEdit package that's easier to get started
with, I'm all for that too.

Shawn

--~--~-~--~~~---~--~~
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: Creating temporary namespaces from a function fails; why?

2008-11-21 Thread [EMAIL PROTECTED]

> I cannot think of an easy way around this at the moment.

I've browsed through the namespace documentation and I think that I
can get by with the (ns-resolve) form.  I feel it could be more
concise and elegant, though.

> I'm curious
> what the reasoning behind creating this temporary namespace is?
>
> There may be a different approach that won't get you caught up between
> the compilation/execution phases.

As I've mentioned in my first post, I'm coding a function that finds
functions with a certain metadata field within namespaces I pass on to
it.  To test it, I want to set up namespaces with minimal stuff for
testing, namespaces that I want to throw away once the test is passed.

My problems don't seem to stop at referencing the stuff I put in these
temporary namespaces.  It also seems that the (defn) macros that I
expected would define mappings in the temporary namespaces expand
before the execution of the test function.  This means that these
definitions don't go in the temporary namespaces, but in the same
namespace as the test function itself.  The only way that I've found
yet to effectively put these defn's in the temp namespaces is to wrap
them in quoted-lists and invoke eval:

(eval '(defn fn-a [] :a/a))

The posts I got to read last week with regards to eval suggested it
was bad style.  Is there a more elegant way to do this?

Benoit
--~--~-~--~~~---~--~~
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: Monads in Clojure

2008-11-21 Thread Konrad Hinsen

On Nov 21, 2008, at 15:01, walterc wrote:

> how about clojure-contrib?

Actually, I have no idea of how clojure-contrib works. Is this a  
repository for all kinds of Clojure add-ons? Or stuff selected by  
Rich for a specific reason?

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: Monads in Clojure

2008-11-21 Thread Stuart Sierra

On Nov 21, 10:06 am, Konrad Hinsen <[EMAIL PROTECTED]> wrote:
> Actually, I have no idea of how clojure-contrib works. Is this a
> repository for all kinds of Clojure add-ons? Or stuff selected by
> Rich for a specific reason?

Rich gives out commit permission on clojure-contrib to people who are
interested, but he doesn't dictate what goes in.  You have to sign the
Clojure Contributor agreement, which basically says that if the
Clojure license changes at some point, you allow your contribution to
be released under the same license (still open-source, of course).
-Stuart Sierra


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: loss of gen-and-load-class functionality

2008-11-21 Thread Stuart Sierra

On Nov 21, 8:46 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
> I'd appreciate examples of gen-and-load-class and gen-and-save-class
> use not well supported by the AOT gen-class.

Don't know if this is supported now not, but here's my old
gen_classes.clj:

(defmacro defclass [name & args]
  `(do
 (println ~(str "Generating " name))
 (gen-and-save-class *dir* ~name [EMAIL PROTECTED])))

(defmacro defmapreduce [name]
  `(defclass ~name
 :extends org.apache.hadoop.mapred.MapReduceBase
 :implements [org.apache.hadoop.mapred.Mapper
  org.apache.hadoop.mapred.Reducer]))

(defmapreduce "org.altlaw.func.ohm1.GroupFiles")
(defmapreduce "org.altlaw.func.ohm1.AssignIds")
(defmapreduce "org.altlaw.func.ohm1.ProcessUpdate")
(defmapreduce "org.altlaw.func.pro.Process")
... lots more like that ...

-Stuart Sierra
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Newbie: Creating a MapEntry

2008-11-21 Thread J. McConnell

On Fri, Nov 21, 2008 at 12:03 AM, samppi <[EMAIL PROTECTED]> wrote:
>
> Is it possible to create a MapEntry from scratch? The reason why I'm
> asking is because I want to mess with sequences of two-sized vectors,
> and it would be really cool if I could use the key and val functions
> on them rather than (get % 0) and (get % 1):
>
>  (map #(str "Key:" (key %) "Value:" (val %)) [(map-entry :a 3) (map-
> entry :b 2) (map-entry :a 1) (map-entry :c 0)])

Since Rich discouraged use of the MapEntry class, here are a couple of options.

First, one thing worth remembering is that vectors are functions of
their indexes, so you can do this and get rid of the "get"'s:

(map #(str "Key: " (% 0) "Value: " (% 1)) [[:a 3] [:b 2] [:a 1] [:c 0]])

Second, if it was the use of (key) and (val) that you were most
interested in, you could create your own (map-entry) function:

user=> (defn map-entry [k v] (first {k v}))
#'user/map-entry
user=> (map #(str "Key:" (key %) "Value:" (val %))
  [(map-entry :a 3) (map-entry :b 2) (map-entry :a 1) (map-entry :c 0)])
("Key::aValue:3" "Key::bValue:2" "Key::aValue:1" "Key::cValue:0")

HTH,

- 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: Suggest allowing java property to specify *compile-path*

2008-11-21 Thread Stuart Sierra

On Nov 21, 3:56 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> I've uploaded a patch that works like Stuart's file compiler, but it  
> takes lib names as arguments and compiles them.

Shucks, looks like all that was missing (from my 2nd try) was
Symbol.intern!  Oh well.  This looks good to me.  I think a file-based
compiler might still be useful, e.g. for running Clojure as an
"interpreter" like Perl/Ruby/Python.  But maybe it's easier if the
unit of compilation remains the lib.  The only potential source of
confusion I see is that compilation uses libs but invocation
(clojure.lang.Script) uses files.

I feel like Clojure is in an odd position right now.  At first, it was
source-code-based, like a scripting language, and people used it that
way (at least I did).  With the addition of the AOT compiler, it's
looking more like a compiled language, with the bonus that it can
compile source code on-the-fly.

So we've got the scripting-language style: java -jar clojure.jar my-
script.clj
And the Java style: java -jar clojure.jar my.cool.lib

So there's a decision to be made: should Clojure behave more like a
scripting language (invoke by file) or more like Java (invoke by
class)?  There are pros and cons either way.  Theoretically, it could
support both.

-Stuart Sierra
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Monads in Clojure

2008-11-21 Thread Chouser

On Fri, Nov 21, 2008 at 6:14 AM, Konrad Hinsen
<[EMAIL PROTECTED]> wrote:
>
> As a first non-trivial exercice, I wrote an implementation of monads
> in Clojure. I just uploaded it to the Group:
>
>http://clojure.googlegroups.com/web/monads.clj

This is pretty code.  Did you just implement symbol-macro-let?  Very nice.

I noticed that you have a private function (monad-expr) used by a
macro, and was about to comment that that doesn't work -- but your
function is used by the macro, not the *expansion* of the macro, so it
should work just fine.  I'll have to keep that in mind.

(zero? n) is an idiom for (= 0 n)

Alas even your beautiful, succinct implementation and careful code
comments are apparently insufficient for me to understand monads.

I'll keep trying. :-)

--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: Eclipse Plugin- any plans for this?

2008-11-21 Thread verec

I'm still active on this, as I'm sure Casey is. Though the recent crop
of incompatible changes means some rework as the target is moving :)
--
JFB

On Nov 21, 1:03 pm, MikeM <[EMAIL PROTECTED]> wrote:
> This came up on the list not long ago, don't know what the status is:
>
> http://code.google.com/p/clojure-dev/
--~--~-~--~~~---~--~~
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 HTML Documentation

2008-11-21 Thread Mark McGranaghan

Thanks for the thoughts Craig.

* I'm experimenting with a "namespaces" tab that will complement the
current "vars" listing that is available now.
* The ability to link in also sounds good, though I'll focus on that
once the URL of the docs themselves is stable.
* Having online docs opens up a lot of possibilities, including
annotations, inter-function linking, and per-var usage stats. We'll
see (:

- Mark

On Fri, Nov 21, 2008 at 8:00 AM, Craig Andera <[EMAIL PROTECTED]> wrote:
>
> Very nice! As it turns out, I've been heavily involved in writing the
> documentation infrastructure that MSDN uses for the last few years, so
> I have some sympathy for this problem space. :)
>
> A few things I'd like to see:
>
> * I'd like to see the URL for the page change when navigating to a new
> topic. Right now it's pretty hard to bookmark a page or email a URL to
> some particular piece of documentation since the URL is always
> index.html.
> * I want to be able to click on a namespace and see all the symbols
> for just that namespace. Would make it easy to explore the libraries
> by functional area.
> * I'd like to be able to get back to the home page from any other
> page, or go up to the namespace page.
> * Maybe the namespace page could have snippets of the doc next to the
> names. Perhaps the first 30 characters of the doc string or something
> simple like that.
> * If this supported annotations, that would be fantastic, but
> obviously that's a whole 'nother level.
>
> On Fri, Nov 21, 2008 at 3:17 AM, Mark McGranaghan <[EMAIL PROTECTED]> wrote:
>>
>> I've created some experimental HTML docs for Clojure. You can see them
>> on S3:
>> http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html
>>
>> Or, just for kicks, on Amazon's new Cloud Front CDN:
>> http://d2nbqsesuabw8o.cloudfront.net/tmp/doc-1116/index.html
>>
>> You can see the code I used to generate them on GitHub:
>> http://github.com/mmcgrana/clj-doc
>>
>> The generation code is open for public perusal but will require some
>> tweaking for public use (e.g. I still have paths hard coded). Any help
>> along these lines would be greatly appreciated.
>>
>> Most methods in the clj-doc source have docstrings and in total its
>> only a couple hundred lines of code: you should be able to find your
>> way around if you're interested. The best entry point is bin/gen.clj.
>> Again, any comments or suggests would be appreciated.
>>
>> I hope that some of you find this interesting/useful/helpful in your
>> Clojure endeavors,
>> - 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: Monads in Clojure

2008-11-21 Thread Konrad Hinsen

On 21.11.2008, at 17:10, Chouser wrote:

> On Fri, Nov 21, 2008 at 6:14 AM, Konrad Hinsen
> <[EMAIL PROTECTED]> wrote:
>>
>> As a first non-trivial exercice, I wrote an implementation of monads
>> in Clojure. I just uploaded it to the Group:
>>
>>http://clojure.googlegroups.com/web/monads.clj
>
> This is pretty code.  Did you just implement symbol-macro-let?   
> Very nice.

Thanks!  I don't  know what symbol-macrolet is/does, so I can't  
comment on that. It's probably some Common Lisp thing, right?

> I noticed that you have a private function (monad-expr) used by a
> macro, and was about to comment that that doesn't work -- but your
> function is used by the macro, not the *expansion* of the macro, so it
> should work just fine.  I'll have to keep that in mind.

Yes, it is used only at expansion time.

> (zero? n) is an idiom for (= 0 n)

Good to know!

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: Newbie: Creating a MapEntry

2008-11-21 Thread samppi

Yes, thank you—(key) and (val) were what I was interested in, so I'll
use the latter function you gave. What I'm wondering though is, if
MapEntries aren't guaranteed for the future, what is being planned for
(key) and (val) too. Oh, well. :)

On Nov 21, 8:23 am, "J. McConnell" <[EMAIL PROTECTED]> wrote:
> On Fri, Nov 21, 2008 at 12:03 AM, samppi <[EMAIL PROTECTED]> wrote:
>
> > Is it possible to create a MapEntry from scratch? The reason why I'm
> > asking is because I want to mess with sequences of two-sized vectors,
> > and it would be really cool if I could use the key and val functions
> > on them rather than (get % 0) and (get % 1):
>
> >  (map #(str "Key:" (key %) "Value:" (val %)) [(map-entry :a 3) (map-
> > entry :b 2) (map-entry :a 1) (map-entry :c 0)])
>
> Since Rich discouraged use of the MapEntry class, here are a couple of 
> options.
>
> First, one thing worth remembering is that vectors are functions of
> their indexes, so you can do this and get rid of the "get"'s:
>
> (map #(str "Key: " (% 0) "Value: " (% 1)) [[:a 3] [:b 2] [:a 1] [:c 0]])
>
> Second, if it was the use of (key) and (val) that you were most
> interested in, you could create your own (map-entry) function:
>
> user=> (defn map-entry [k v] (first {k v}))
> #'user/map-entry
> user=> (map #(str "Key:" (key %) "Value:" (val %))
>   [(map-entry :a 3) (map-entry :b 2) (map-entry :a 1) (map-entry :c 0)])
> ("Key::aValue:3" "Key::bValue:2" "Key::aValue:1" "Key::cValue:0")
>
> HTH,
>
> - 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 HTML Documentation

2008-11-21 Thread Michael Beauregard

I like where you are going with this. Reminds me of www.gotapi.com. I
don't know if gotapi is open or not, but your stuff may fit nicely in
there.

Michael

On Fri, Nov 21, 2008 at 9:31 AM, Mark McGranaghan <[EMAIL PROTECTED]> wrote:
>
> Thanks for the thoughts Craig.
>
> * I'm experimenting with a "namespaces" tab that will complement the
> current "vars" listing that is available now.
> * The ability to link in also sounds good, though I'll focus on that
> once the URL of the docs themselves is stable.
> * Having online docs opens up a lot of possibilities, including
> annotations, inter-function linking, and per-var usage stats. We'll
> see (:
>
> - Mark
>
> On Fri, Nov 21, 2008 at 8:00 AM, Craig Andera <[EMAIL PROTECTED]> wrote:
>>
>> Very nice! As it turns out, I've been heavily involved in writing the
>> documentation infrastructure that MSDN uses for the last few years, so
>> I have some sympathy for this problem space. :)
>>
>> A few things I'd like to see:
>>
>> * I'd like to see the URL for the page change when navigating to a new
>> topic. Right now it's pretty hard to bookmark a page or email a URL to
>> some particular piece of documentation since the URL is always
>> index.html.
>> * I want to be able to click on a namespace and see all the symbols
>> for just that namespace. Would make it easy to explore the libraries
>> by functional area.
>> * I'd like to be able to get back to the home page from any other
>> page, or go up to the namespace page.
>> * Maybe the namespace page could have snippets of the doc next to the
>> names. Perhaps the first 30 characters of the doc string or something
>> simple like that.
>> * If this supported annotations, that would be fantastic, but
>> obviously that's a whole 'nother level.
>>
>> On Fri, Nov 21, 2008 at 3:17 AM, Mark McGranaghan <[EMAIL PROTECTED]> wrote:
>>>
>>> I've created some experimental HTML docs for Clojure. You can see them
>>> on S3:
>>> http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html
>>>
>>> Or, just for kicks, on Amazon's new Cloud Front CDN:
>>> http://d2nbqsesuabw8o.cloudfront.net/tmp/doc-1116/index.html
>>>
>>> You can see the code I used to generate them on GitHub:
>>> http://github.com/mmcgrana/clj-doc
>>>
>>> The generation code is open for public perusal but will require some
>>> tweaking for public use (e.g. I still have paths hard coded). Any help
>>> along these lines would be greatly appreciated.
>>>
>>> Most methods in the clj-doc source have docstrings and in total its
>>> only a couple hundred lines of code: you should be able to find your
>>> way around if you're interested. The best entry point is bin/gen.clj.
>>> Again, any comments or suggests would be appreciated.
>>>
>>> I hope that some of you find this interesting/useful/helpful in your
>>> Clojure endeavors,
>>> - 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: Newbie: Creating a MapEntry

2008-11-21 Thread Rich Hickey



On Nov 21, 11:40 am, samppi <[EMAIL PROTECTED]> wrote:
> Yes, thank you—(key) and (val) were what I was interested in, so I'll
> use the latter function you gave. What I'm wondering though is, if
> MapEntries aren't guaranteed for the future, what is being planned for
> (key) and (val) too. Oh, well. :)
>

There's a difference between supporting key and val and allowing you
to create MapEntries directly. key and val will stick around.

Rich

> On Nov 21, 8:23 am, "J. McConnell" <[EMAIL PROTECTED]> wrote:
>
> > On Fri, Nov 21, 2008 at 12:03 AM, samppi <[EMAIL PROTECTED]> wrote:
>
> > > Is it possible to create a MapEntry from scratch? The reason why I'm
> > > asking is because I want to mess with sequences of two-sized vectors,
> > > and it would be really cool if I could use the key and val functions
> > > on them rather than (get % 0) and (get % 1):
>
> > >  (map #(str "Key:" (key %) "Value:" (val %)) [(map-entry :a 3) (map-
> > > entry :b 2) (map-entry :a 1) (map-entry :c 0)])
>
> > Since Rich discouraged use of the MapEntry class, here are a couple of 
> > options.
>
> > First, one thing worth remembering is that vectors are functions of
> > their indexes, so you can do this and get rid of the "get"'s:
>
> > (map #(str "Key: " (% 0) "Value: " (% 1)) [[:a 3] [:b 2] [:a 1] [:c 0]])
>
> > Second, if it was the use of (key) and (val) that you were most
> > interested in, you could create your own (map-entry) function:
>
> > user=> (defn map-entry [k v] (first {k v}))
> > #'user/map-entry
> > user=> (map #(str "Key:" (key %) "Value:" (val %))
> >   [(map-entry :a 3) (map-entry :b 2) (map-entry :a 1) (map-entry :c 0)])
> > ("Key::aValue:3" "Key::bValue:2" "Key::aValue:1" "Key::cValue:0")
>
> > HTH,
>
> > - 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 HTML Documentation

2008-11-21 Thread Daniel Eklund

beautiful !

thanks... i was just looking for something like this

On Nov 21, 3:17 am, Mark McGranaghan <[EMAIL PROTECTED]> wrote:
> I've created some experimental HTML docs for Clojure. You can see them
> on S3:http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html
>
> Or, just for kicks, on Amazon's new Cloud Front 
> CDN:http://d2nbqsesuabw8o.cloudfront.net/tmp/doc-1116/index.html
>
> You can see the code I used to generate them on 
> GitHub:http://github.com/mmcgrana/clj-doc
>
> The generation code is open for public perusal but will require some
> tweaking for public use (e.g. I still have paths hard coded). Any help
> along these lines would be greatly appreciated.
>
> Most methods in the clj-doc source have docstrings and in total its
> only a couple hundred lines of code: you should be able to find your
> way around if you're interested. The best entry point is bin/gen.clj.
> Again, any comments or suggests would be appreciated.
>
> I hope that some of you find this interesting/useful/helpful in your
> Clojure endeavors,
> - 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: Newbie: Creating a MapEntry

2008-11-21 Thread Stephen C. Gilardi

On Nov 21, 2008, at 10:23 AM, J. McConnell wrote:

> user=> (defn map-entry [k v] (first {k v}))

Very nice!

--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: Suggest allowing java property to specify *compile-path*

2008-11-21 Thread Chouser

On Fri, Nov 21, 2008 at 10:46 AM, Stuart Sierra
<[EMAIL PROTECTED]> wrote:
>
> So there's a decision to be made: should Clojure behave more like a
> scripting language (invoke by file) or more like Java (invoke by
> class)?  There are pros and cons either way.  Theoretically, it could
> support both.

I vote both.  A few days ago I typed up something like this in a scratch file:

1. (require 'my.foo) (my.foo/-main "arg1" "arg2")
2. clj my/foo.clj arg1 arg2
3. my/foo.clj arg1 arg2
4. java my.foo arg1 arg2

The idea was that it should be possible to write a single clj file and
have all these forms work.

Numbers 2 and 3 (and possibly 1) are compiling .clj on the fly.

Use case 1 shows the file being used as a library, with its -main
function only being run if explicitly requested.

2 implies that when run this way, -main is called automatically with
*command-line-args*

3 implies the use of #!/bin/env clj or some such at the top of
foo.clj, and again -main would be called automatically

4 shows the use of my.foo after its been compiled to a class file.  It
would be reasonable for the stand-alone compiler to also provide an
option to produce a .jar file directly, allowing a fifth use case:

5. java -jar my-foo.jar arg1 arg2

A cleverly written clj shell-script ought to be able to do all this
today, though that doesn't work well as a cross-platform solution.  So
the question is -- are these use cases generally desirable?  They are
to me, but am I alone?

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



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

2008-11-21 Thread Stuart Sierra
Hi Rich, everyone,

The attached patch combines Repl, Script, and the lib compiler that
Stephen G. and I have worked on.

$ java -jar clojure.jar -help
Usage: java -jar clojure.jar [options] [file]

Options:
  -help   This help message
  -eval expr  Evaluate an expression (may be repeated)
  -compile libs...  Compile the named libs; terminates options
  -repl   Run an interactive Read-Eval-Print Loop (default)
  fileRun a script; extra args in *command-line-args*
  -   Run a script read from standard input


-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/clj/precompile.clj
===
--- src/clj/precompile.clj	(revision 1121)
+++ src/clj/precompile.clj	(working copy)
@@ -1,11 +0,0 @@
-;; This script is run by the Ant build task to precompile the core
-;; Clojure source files.
-
-(println "Compiling Clojure core sources...")
-
-(binding [*compile-path* (System/getProperty "clojure.compile.path")]
-  (compile 'clojure.core)
-  (compile 'clojure.set)
-  (compile 'clojure.xml)
-  (compile 'clojure.zip)
-  (compile 'clojure.inspector))
Index: src/jvm/clojure/lang/Main.java
===
--- src/jvm/clojure/lang/Main.java	(revision 0)
+++ src/jvm/clojure/lang/Main.java	(revision 0)
@@ -0,0 +1,198 @@
+/**
+ *   Copyright (c) Rich Hickey. All rights reserved.
+ *   The use and distribution terms for this software are covered by the
+ *   Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+ *   which can be found in the file CPL.TXT at the root of this distribution.
+ *   By using this software in any fashion, you are agreeing to be bound by
+ * 	 the terms of this license.
+ *   You must not remove this notice, or any other, from this software.
+ **/
+
+package clojure.lang;
+
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.List;
+
+public class Main {
+
+static final String COMPILE_PATH_PROP = "clojure.compile.path";
+
+static final Symbol USER = Symbol.create("user");
+static final Symbol CLOJURE = Symbol.create("clojure.core");
+
+static final Var in_ns = RT.var("clojure.core", "in-ns");
+static final Var refer = RT.var("clojure.core", "refer");
+static final Var ns = RT.var("clojure.core", "*ns*");
+static final Var compile_path = RT.var("clojure.core", "*compile-path*");
+static final Var warn_on_reflection = RT.var("clojure.core", "*warn-on-reflection*");
+static final Var print_meta = RT.var("clojure.core", "*print-meta*");
+static final Var print_length = RT.var("clojure.core", "*print-length*");
+static final Var print_level = RT.var("clojure.core", "*print-level*");
+static final Var star1 = RT.var("clojure.core", "*1");
+static final Var star2 = RT.var("clojure.core", "*2");
+static final Var star3 = RT.var("clojure.core", "*3");
+static final Var stare = RT.var("clojure.core", "*e");
+static final Var cmd_line_args = RT.var("clojure.core", "*command-line-args*");
+static final Var compile = RT.var("clojure.core", "compile");
+
+public static void repl(String[] args) throws Exception {
+commandLineArgs(args);
+
+//repl IO support
+LineNumberingPushbackReader rdr = new LineNumberingPushbackReader(new InputStreamReader(System.in, RT.UTF8));
+OutputStreamWriter w = (OutputStreamWriter) RT.OUT.get();
+Object EOF = new Object();
+
+//start the loop
+w.write("Clojure\n");
+for(; ;) {
+try {
+w.write(Compiler.currentNS().name + "=> ");
+w.flush();
+Object r = LispReader.read(rdr, false, EOF, false);
+if(r == EOF) {
+w.write("\n");
+w.flush();
+break;
+}
+Object ret = Compiler.eval(r);
+RT.print(ret, w);
+w.write('\n');
+star3.set(star2.get());
+star2.set(star1.get());
+star1.set(ret);
+} catch(Throwable e) {
+Throwable c = e;
+while(c.getCause() != null)
+c = c.getCause();
+((PrintWriter) RT.ERR.get()).println(e instanceof Compiler.CompilerException ? e : c);
+stare.set(e);
+}
+}
+}
+
+public static void runScript(String[] args) throws Exception {
+

Re: Monads in Clojure

2008-11-21 Thread Chouser

On Fri, Nov 21, 2008 at 11:40 AM, Konrad Hinsen
<[EMAIL PROTECTED]> wrote:
>
> Thanks!  I don't  know what symbol-macrolet is/does, so I can't
> comment on that. It's probably some Common Lisp thing, right?

Probably, though when googling it just now, I seem to have found some
third-party implementations, so who knows.

My impression, though, is that it provides the ability to define a
local macro where the macro doesn't need to be called from the head of
a list, but is just a symbol that can be dropped in anywhere.  Perhaps
someone who actually knows something about a lisp other than Clojure
can comment.

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



Which paper discusses Henry Baker's (sp?) egal?

2008-11-21 Thread Brett Hoerner

I've watched a lot of Clojure videos now, and keep hearing Rich
mention "Henry Baker's egal".  Does someone have the actual paper
title where Baker talks about this?  I have an ACM subscription (and
assume that's where I'd find it) - but no dice on finding egal (sp?)
and Henry G Baker has a hell of a lot of papers. ;)

Thanks!
Brett

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



Release .zip file

2008-11-21 Thread Phil Hagelberg

Hey, I just downloaded clojure for the first time, grabbing the zip
file and uncompressing it. I noticed it dumped everything in-place
rather than creating a clojure/ subdirectory for the files, so it was
a bit of a mess to clean up.

It's not a big deal at all, but it would ever-so-slightly improve the
"out of the box" experience for people wanting to just try it out if
it didn't dump a bunch of files in places where you don't expect them.

thanks,
Phil

--~--~-~--~~~---~--~~
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: Which paper discusses Henry Baker's (sp?) egal?

2008-11-21 Thread Rich Hickey



On Nov 21, 12:36 pm, Brett Hoerner <[EMAIL PROTECTED]> wrote:
> I've watched a lot of Clojure videos now, and keep hearing Rich
> mention "Henry Baker's egal".  Does someone have the actual paper
> title where Baker talks about this?  I have an ACM subscription (and
> assume that's where I'd find it) - but no dice on finding egal (sp?)
> and Henry G Baker has a hell of a lot of papers. ;)
>

http://home.pipeline.com/~hbaker1/ObjectIdentity.html

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: Monads in Clojure

2008-11-21 Thread Adam Jones



On Nov 21, 3:14 am, Konrad Hinsen <[EMAIL PROTECTED]> wrote:
> As a first non-trivial exercice, I wrote an implementation of monads  
> in Clojure. I just uploaded it to the Group:
>
>        http://clojure.googlegroups.com/web/monads.clj
>
> The file contains the macro definitions, the definitions of three  
> popular monads (maybe, list, state), and some illustrations of their  
> use. Comments are welcome!

Since they support mzero and mplus, aren't these equivalent to
Haskell's MonadPlus? (i.e. they're a little more than *just* monads)
I'm trying to work my way through that material too, so I'm not
entirely sure. Either way, cool stuff.

I've been kicking around the idea of re-implementing Haskell
typeclasses on top of multimethods. Now that I think more about it,
this probably wouldn't be much work. The two big issues I can see are
ensuring incomplete instances can't be created and figuring out how
the dispatch function can work sanely. Haskell has an advantage here
in that the only thing typeclasses dispatch on is the types involved,
so it's trivial to not clobber any existing definitions.

-Adam

>
> One thing I was wondering about: if I want to turn this into a  
> library module, where could I place it in Java's namespace hierarchy?  
> I don't have my own domain (and don't need one), and even though I  
> could have it hosted somewhere (such as SourceForge), it doesn't look  
> like a good idea to have the package name depend on a hosting site  
> that might not be forever. How do others approach this problem?
>
> 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: mutability

2008-11-21 Thread Adam Jones



On Nov 20, 12:23 pm, islon <[EMAIL PROTECTED]> wrote:
> I'm porting my single thread simple mud-like rpg game from scala to
> clojure and one thing that is annoying me is the code needed to change
> some var.
> In scala I do things like that:
>
> val player = new Player(...)
>
> player.str += 1
>
> in clojure I have to do (player is a struct and its attributes are
> refs):
>
> (def player (Player ...))
>
> (dosync (ref-set player (assoc player :str (inc (:str player)
>
> In scala when I want mutability I just define the variable with "var"
> instead of "val", just one letter, simple and elegant.
> It's a game, it's full of states and mutability, the game is single
> thread, I don't need transactions. Am I missing something?

If this is really that big of a deal, you could always go the macro
route. I'm not experienced enough to say if this is a long-term good
decision, but here's a first pass, don't even have Clojure available
to try it, attempt at wrapping up Chouser's suggestion (I think :=
would be better here, but that clashes with keyword definition):

(defmacro |= [target attr fun]
  "Updates 'attr' of 'target' by passing the current value to 'fun'
and commuting the result, all inside of a transaction"
  `(dosync
(commute ~target update-in [~attr] ~fun)))

With usage:

(|= player :str inc)

That look a little better?

-Adam
--~--~-~--~~~---~--~~
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] Add build/run instructions to the readme.

2008-11-21 Thread Phil Hagelberg

For Java people this is probably obvious, but I didn't really have a
clue how to compile the project after checking out the source. Here is
a patch that makes the readme a little more helpful.

-Phil

diff --git a/readme.txt b/readme.txt
index 93b74a2..a2bbb0d 100644
--- a/readme.txt
+++ b/readme.txt
@@ -10,6 +10,13 @@
 Docs: http://clojure.sourceforge.net/
 Feedback: http://groups.google.com/group/clojure

+To build, use "ant" or "mvn install"
+Once it's built, start the REPL with:
+
+  $ java -cp clojure.jar clojure.lang.Repl # if using ant
+
+  $ java -cp target/clojure-lang-*.jar clojure.lang.Repl # if using
maven
+
 
--
 This program uses the ASM bytecode engineering library which is
distributed
 with the following notice:

--~--~-~--~~~---~--~~
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] Add build/run instructions to the readme.

2008-11-21 Thread Stephen C. Gilardi


> On Nov 21, 2008, at 2:50 PM, Phil Hagelberg wrote:
>>
>> For Java people this is probably obvious, but I didn't really have a
>> clue how to compile the project after checking out the source.  
>> Here is
>> a patch that makes the readme a little more helpful.

Does "java -jar clojure.jar" work to launch a repl for both builds?  
Can we change one or the other so that the jars they build are  
identical?

--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: Add build/run instructions to the readme.

2008-11-21 Thread Phil Hagelberg

On Nov 21, 12:04 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> Does "java -jar clojure.jar" work to launch a repl for both builds?  
> Can we change one or the other so that the jars they build are  
> identical?

No, mvn install places it in target/. Sounds like this should be
fixed.

-Phil
--~--~-~--~~~---~--~~
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: loss of gen-and-load-class functionality

2008-11-21 Thread Stephen Wrobleski

On Fri, Nov 21, 2008 at 05:46:00AM -0800, Rich Hickey wrote:
> I'd appreciate examples of gen-and-load-class and gen-and-save-class
> use not well supported by the AOT gen-class.
> 
> What I am interested in is the scenarios/use-cases.


I've got a DSL which compiles an abstraction to a class. These abstractions
are accessible from the rest of the Java platform, and fit very nicely as
classes (with immutable fields and pure methods). The DSL accesses metadata
on previously defined abstractions to generate new ones, and some of the
base abstractions are written directly in Java for performance. Basically,
classes provide a common meeting ground across the JVM.


Now, I can see a standard way of doing something like this

(defmacro def-gen-class [name & options]
  (let [{:keys [name bytecode]}
(eval `(gen-class ~(str name) [EMAIL PROTECTED]))]
(if *compile-files*
  (.writeClassFile Compiler (.replace name "." "/")
bytecode)
  (.. clojure.lang.RT ROOT_CLASSLOADER
  (defineClass (str name) bytecode)))

  '(do)))

(Haven't thought much about the proper phasing. But I used a macro so that
nothing is left around after compile-time)


Do you have something against Java classes, or does Clojure only shun them
because they can't be redefined? Being a JVM language, I would think a full
(defclass ..) form would be a no-brainer, for exporting APIs to rest of Java
land.


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: Patch: universal main() with repl/script/compile

2008-11-21 Thread Jarkko Oranen

Really neat!

One request though:
Please don't remove the line  from the build file.
It's helpful for people who want to use SLIME. SLIME needs the .clj
files for its "show definition" functionality and it'd be much nicer
to just be able to uncomment that instead of having to figure out what
you need to add to get the .clj files included in the jar.

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



French translation of the Clojure rationale

2008-11-21 Thread Vincent Foley

Hello everyone,

I don't know if there are French speakers lurking on this group, but
I'd really appreciate if somebody could make sure that my translation
of the Clojure rationale is accurate and typo-free.

Clojure
===

Clients et investisseurs ont des investissements substantiels dans les
plate-formes standards utilisées en industrie, telles que la JVM, et
sont
confortables avec leur performance, leur stabilité et leur sécurité.
Même
s'ils envient la brièveté, la flexibilité et la productivité des
langages
dynamiques, les programmeurs Java ont des soucis de compatibilité avec
l'infrastructure des clients, d'accès aux bibliothèques et modules
déjà
existants et de performance avec lesquels ils doivent composer.  De
plus, ils
font face chaque jour à des problèmes en lien à la concurrence dûs à
l'utilisation de threads et de verrous.  Clojure est un effort pour
créer un
langage dynamique et pragmatique dans ce contexte.  Il vise à être un
langage
à usage général qui est adapté à toutes les tâches pour lesquelles
Java est
utilisé.  Il reflète également la réalité que, dans un contexte de
programmation concurrente, la mutation omniprésente et incontrôlée des
valeurs
doit être éliminée.

Clojure atteint ses buts en se jumelant à une plate-forme utilisée en
industrie, la JVM; en modernisant un langage vénérable, Lisp; en
encourageant
la programmation fonctionnelle via des structures de données immuables
et
persistantes; et en offrant un support de première classe pour la
concurrence
via un système de mémoire transactionnelle (software transactional
memory, STM)
et des agents asynchrones.  Le résultat est un langage robuste,
pratique et
rapide.

Pourquoi Clojure?
-

Pourquoi ai-je écrit un nouveau langage de programmation?  Parce que
je
voulais:

* Un Lisp
* Adapté à la programmation fonctionnelle
* En symbiose avec une plate-forme établie
* Créé pour la concurrence

Et je n'en trouvais aucun.  Voici un aperçu de quelques unes des idées
derrière Clojure.

Lisp est une bonne chose


- Souvent émulé et pillé, jamais dupliqué
- Le calcul lambda produit un noyau très petit
- Presque pas de syntaxe
- Les avantages principaux sont encore que le code est du data et les
  abstractions syntaxiques
- Pourquoi pas un Lisp standardisé?
- Innovation lente ou inexistante suite à la standardisation
- Les structures de données fondamentales sont modifiables et
  non-extensibles.
- La concurrence n'est pas adressée dans les spécifications
- De bonnes implémentations existent déjà pour la JVM (ABCL, Kawa,
SISC)
- Les Lisps standards sont leur propre plate-forme
- Clojure est un Lisp qui n'est pas contraint par la rétro-
compatibilité
- Étend le paradigme de code-is-data aux vecteurs et aux maps
- Les structures de données fondamentales sont immuables
- Les structures de données fondamentales sont des abstractions
  extensibles
- Adopte une plate-forme existante (JVM)


La programmation fonctionnelle est une bonne chose
--

- Données immuables et fonctions de premier ordre
- La programmation fonctionnelle est possible dans Lisp, mais par
convention
  et discipline
- Si une structure de données est modifiable, il est dangereux de
présumer
  qu'elle ne le sera pas
- Dans les Lisps traditionnels, seule la liste est
structurellement
  récursive
- Les langages de programmation fonctionnelle purs sont habituellement
typés
  statiquement
- Pas idéal pour tout le monde ou dans tous les cas
- Clojure est un langage fonctionnel avec une emphase sur le dynamisme
- Toutes les structures de données sont immuables, persistantes et
sont
  structurellement récursives
- Collections et types de retour hétérogènes
- Polymorphisme dynamique


Langages et plate-formes


- Les machines virtuelles, pas les systèmes d'exploitation, sont les
  plate-formes du futur.  Elles offrent:
- Des systèmes de types
- Des bibliothèques
- Abstraites du systèmes d'exploitation
- *Énorme* ensemble d'accessoires
- Bibliothèques standards et externes
- La gestion de la mémoire et d'autres ressources
- Un ramasse-miettes est un accessoire de la plate-forme, pas
du
  langage
- Bytecode et compilation JIT
- Abstraits du matériel de l'ordinateur
- Langage en tant que plate-forme vs. langage + plate-forme
- Ancienne méthode: chaque langage défini son propre support
d'exécution
- Ramasse-miette, bytecode, systèmes de types, bibliothèques,
etc.
- Nouvelle façon (JVM, .NET)
- Le support d'exécution est indépendant du langage
- Langage construit pour une plate-forme vs. langage porté à une plate-
forme
- Bon nombre de nouveaux langages adoptent la philosophie "le
langage est
  la plate-forme"
- Quand ils sont portés vers une autre plate-forme, ils ont des
problèmes
  de compatibilité

Re: French translation of the Clojure rationale

2008-11-21 Thread Vincent Foley

Sorry about the line endings, Google groups seems to have truncated
them to a width shorter than Vim.
--~--~-~--~~~---~--~~
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: universal main() with repl/script/compile

2008-11-21 Thread Stuart Sierra

On Nov 21, 3:58 pm, Jarkko Oranen <[EMAIL PROTECTED]> wrote:
> Please don't remove the line  from the build file.
> It's helpful for people who want to use SLIME. SLIME needs the .clj
> files for its "show definition" functionality and it'd be much nicer
> to just be able to uncomment that instead of having to figure out what
> you need to add to get the .clj files included in the jar.

Good point.  Probably the .clj files should always be included in the
jar, then.  Thanks, Jarkko.
-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
-~--~~~~--~~--~--~---



Use of "/" to call static method in generated classes

2008-11-21 Thread Craig McDaniel

Testing the new (ns ... :genclass ...), I copied Rich's example from
http://paste.lisp.org/display/70665:

(ns my.hello
  (:gen-class
   :extends javax.swing.DefaultCellEditor
   :constructors {[Integer] [javax.swing.JCheckBox]}
   :factory makeone
   :methods [[mymax [int] int]]
   :init init
   :main true
   :state myint
   :exposes {clickCountToStart {:get get-c-count :set set-c-count}})
  )

(defn- -main [foo]
  (println "Hello" foo "World!")
  (let [x (my.hello. 42)]
(prn (.mymax x 21

(defn- -init [myint]
  [[(javax.swing.JCheckBox.)] myint])

(defn- -mymax [this i]
  (max i (.myint this)))

(defn- -getCellEditorValue [this]
  (prn :getCellEditorValue)
  nil)

I can compile and run the example, but it doesn't work with the "/"
syntax for main, even though main is a static method:

user> (.getProperty System "java.class.path")
"/home/kreg/src/clojure/trunk/clojure.jar:/home/kreg/src/junk"
user> (binding [*compile-path* "/home/kreg/src/junk"] (compile
'my.hello))
#{my.hello swank ...}
user> (.main my.hello (into-array ["Bizarro"]))
Hello Bizarro World!
42
nil
user> (my.hello/main (into-array ["Bizarro"]))

java.lang.Exception: No such var: my.hello/main

Works from command line ok:

[EMAIL PROTECTED] ~/src/junk
$ java -cp .:/home/kreg/src/clojure/trunk/clojure.jar my.hello
"Bizarro"
Hello Bizarro World!
42
--~--~-~--~~~---~--~~
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: French translation of the Clojure rationale

2008-11-21 Thread verec

Je ne peux que louer l'effort et surtout éviter de décourager les
bonnes volontés, mais le résultat est si verbeux et si proche de ce
qu'on peut lire en informatique en Français, que je ne peux que douter
très fort de l'impact d'une telle traduction.

Je n'ai jamais cru un seul instant qu'une langue autre que celle dans
laquelle une invention se fait ou une pratique se développe puisse
jamais arriver à exprimer la justesse et précision de ce que se dit
dans la langue source, un peu comme l'Italien pour la musique
classique, ou (jusqu'à il y a quelques temps) le Français en
diplomatie.

Lecteur Francophones, si vous êtes tant soit peu sérieux au sujet de
Clojure out de tout développement lié a l'informatique vous vous devez
d'apprendre et maitriser la langue Anglaise,

stakeholder = partie prenante
!= shareholder = actionnaire = investisseur

core = noyau != coeur=heart

Multi-core = multi-unité centrales

Mes opinions, of course! :-)
--
JFB


--~--~-~--~~~---~--~~
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: Eclipse Plugin- any plans for this?

2008-11-21 Thread Tomi Neste
Maybe the Common Lisp Cusp (http://www.bitfauna.com/projects/cusp/) mode
(view, plugin?) for Eclipse could be used as a base? It seems to use SLIME's
Swank protocol which already has Clojure support in the form of
swank-clojure that works well with Emacs.

--~--~-~--~~~---~--~~
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: French translation of the Clojure rationale

2008-11-21 Thread Vincent Foley

Salut JF,

Merci pour tes commentaires.  Je suis d'accord que l'exercice est
quelque peu futile: l'anglais est la langue officielle de
l'informatique et les traductions en français me font frémir.  Je ne
crois pas qu'une personne puisse devenir un programmeur sérieux sans
être à l'aise en anglais.

Cela dit, au cours des derniers mois je me suis tenu dans des groupes
de discussions de programmation francophones et j'ai découvert qu'un
nombre assez important de gens sont soit très mal à l'aise en anglais
ou y sont carrément hostiles.  Cette traduction vise simplement à
présenter la création de Rich aux gens qui cliquent sur le bouton
"Back" de leur navigateur quand ils tombent sur la langue de
Shakespeare; je veux capturer les curieux, les bidouilleurs, ceux qui
cherchent quelque chose de neuf, quelque chose de moderne, quelque
chose de différent.

Si c'est pas indiscret, je pourrais savoir si tu es Français ou
Québecois (ou autre)?  Je sais pas si c'est régional, mais au Québec
on utilise le terme multi-coeur (http://fr.wikipedia.org/wiki/
Multicore) pour parler d'un processeur multi-core.

Merci encore des commentaires.

Vincent.

P.S.: Présentement, le format est un peu cru: c'est du markdown, je
vais convertir cela à du HTML; ça donnera au document une allure plus
lisible.


On Nov 21, 4:42 pm, verec <[EMAIL PROTECTED]>
wrote:
> Je ne peux que louer l'effort et surtout éviter de décourager les
> bonnes volontés, mais le résultat est si verbeux et si proche de ce
> qu'on peut lire en informatique en Français, que je ne peux que douter
> très fort de l'impact d'une telle traduction.
>
> Je n'ai jamais cru un seul instant qu'une langue autre que celle dans
> laquelle une invention se fait ou une pratique se développe puisse
> jamais arriver à exprimer la justesse et précision de ce que se dit
> dans la langue source, un peu comme l'Italien pour la musique
> classique, ou (jusqu'à il y a quelques temps) le Français en
> diplomatie.
>
> Lecteur Francophones, si vous êtes tant soit peu sérieux au sujet de
> Clojure out de tout développement lié a l'informatique vous vous devez
> d'apprendre et maitriser la langue Anglaise,
>
> stakeholder = partie prenante
> != shareholder = actionnaire = investisseur
>
> core = noyau != coeur=heart
>
> Multi-core = multi-unité centrales
>
> Mes opinions, of course! :-)
> --
> JFB
--~--~-~--~~~---~--~~
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: universal main() with repl/script/compile

2008-11-21 Thread Stephen C. Gilardi
On Nov 21, 2008, at 12:34 PM, Stuart Sierra wrote:

> The attached patch combines Repl, Script, and the lib compiler that
> Stephen G. and I have worked on.


Hi Stuart,

I like the concept very much.

I had a couple of problems in working with the patch:

[1] patch on Mac OS X Leopard rejected the build.xml portion of the  
patch you posted. I'm not sure what the problem was. As a result, I  
made the changes manually to a fresh svn 1121 build.xml.

[2] your clojure.lang.Main uses Arrays.copyOfRange which is apparently  
unavailable until Java SE 6. We are targeting Java 1.5 in the ant  
task. I'm unable to get this to compile even if I remove the  
"target=1.5" option. I find that a bit odd because my default java  
tools should be Java 6-based.

[3] Is the example at the top of build.xml under "description" still  
correct? I would like to see the example be "java -jar clojure.jar" to  
launch a REPL.

Thanks for Main! I think it's a great idea and I look forward to using  
it.

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



Any style/idiom hints for this random sampling function?

2008-11-21 Thread [EMAIL PROTECTED]

I needed a random sampling function for work and wrote this in
Clojure.

(defn random-sample
  "Take a random sample of size `sample-size' from the `items'
sequence.

This uses Algorithm R -- random sampling with a reservoir.  It
requires O(`sample-size') space and does not need to know the size of
`items' ahead of time.  Described in Knuth's The Art of Computer
Programming, volume 2."
  [sample-size items]
  (let [maybe-insert-item
(fn [[num current] item]
  (if (< num sample-size)
[(inc num) (conj current item)]
(let [index (rand-int num)]
  (if (< index sample-size)
[(inc num) (assoc current index item)]
[(inc num) current]]
(second (reduce maybe-insert-item [0 []] items


It seems to work fine, but it strikes me as a little busy with ()[],
even for Lisp. Does anyone have any pointers? Will the internal
function "maybe-insert-item" be evaluated every time "random-sample"
is called, and if so, is that worth worrying about wrt. program
optimization?

Does this sort of thing belong in clojure-contrib or somewhere else?
It seems awfully short but it's a nice function to have, at least for
me.

Thanks,
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: Use of "/" to call static method in generated classes

2008-11-21 Thread pmf



On Nov 21, 10:20 pm, Craig McDaniel <[EMAIL PROTECTED]> wrote:
> I can compile and run the example, but it doesn't work with the "/"
> syntax for main, even though main is a static method:
> user> (my.hello/main (into-array ["Bizarro"]))
>
> java.lang.Exception: No such var: my.hello/main

The function is called -main (from a Clojure-POV); notice the leading
dash in front of your definition of main:

> (defn- -main [foo]
>   (println "Hello" foo "World!")
>   (let [x (my.hello. 42)]
>     (prn (.mymax x 21

So using
  (my.hello/-main (into-array ["Bizarro"]))
instead of
  (my.hello/main (into-array ["Bizarro"]))
works, but throws another error because the method is private (using
defn instead of defn- makes this error disappear, too).

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

2008-11-21 Thread Mark Volkmann

Great idea on the HTML-based documentation!

Another nice addition would be showing at least one example use of
each function/macro in the documentation. I realize that would take a
lot of time to develop, but maybe the community could gradually build
up a collection of these over time.

--~--~-~--~~~---~--~~
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: Use of "/" to call static method in generated classes

2008-11-21 Thread Rich Hickey



On Nov 21, 4:20 pm, Craig McDaniel <[EMAIL PROTECTED]> wrote:
> Testing the new (ns ... :genclass ...), I copied Rich's example 
> fromhttp://paste.lisp.org/display/70665:
>
> (ns my.hello
>   (:gen-class
>:extends javax.swing.DefaultCellEditor
>:constructors {[Integer] [javax.swing.JCheckBox]}
>:factory makeone
>:methods [[mymax [int] int]]
>:init init
>:main true
>:state myint
>:exposes {clickCountToStart {:get get-c-count :set set-c-count}})
>   )
>
> (defn- -main [foo]
>   (println "Hello" foo "World!")
>   (let [x (my.hello. 42)]
> (prn (.mymax x 21
>
> (defn- -init [myint]
>   [[(javax.swing.JCheckBox.)] myint])
>
> (defn- -mymax [this i]
>   (max i (.myint this)))
>
> (defn- -getCellEditorValue [this]
>   (prn :getCellEditorValue)
>   nil)
>
> I can compile and run the example, but it doesn't work with the "/"
> syntax for main, even though main is a static method:
>
> user> (.getProperty System "java.class.path")
> "/home/kreg/src/clojure/trunk/clojure.jar:/home/kreg/src/junk"
> user> (binding [*compile-path* "/home/kreg/src/junk"] (compile
> 'my.hello))
> #{my.hello swank ...}
> user> (.main my.hello (into-array ["Bizarro"]))
> Hello Bizarro World!
> 42
> nil
> user> (my.hello/main (into-array ["Bizarro"]))
>
> java.lang.Exception: No such var: my.hello/main
>
> Works from command line ok:
>
> [EMAIL PROTECTED] ~/src/junk
> $ java -cp .:/home/kreg/src/clojure/trunk/clojure.jar my.hello
> "Bizarro"
> Hello Bizarro World!
> 42

Right. The x/y syntax is used both for namespaces and static methods,
and namespaces win. Here you have both a namespace and a classname
called my.hello. So, for calling gen-class'ed static methods, you'll
need to use (. classname static-method) for now.

I'm not sure this is really an issue, but I'm open to feedback.

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: French translation of the Clojure rationale

2008-11-21 Thread ppierre

C’est vrai que cela se lit mieux en anglais.
Même si je peine à m’exprimer en anglais.

Et la grammaire n’est pas mon fort.
Mais si je peux, aidé à reformuler ?

« Les plates-formes de développement, telles que Java, rassurent les
clients, entreprises et institutions. Les standards offrent rapidité,
stabilité et sécurité. D’autres environnements basés sur des langages
dynamiques améliorent la productivité par leurs souplesses et
concisions ; mais ils montrent des lacunes : difficultés à tirer parti
du code existant, interopérabilité problématique et performance en
retrait. De plus, ils ne résolvent pas le nouveau défi des
architectures parallèles (multiprocesseurs). Clojure est un langage
dynamique développé pour faire face à ce défi. Il peut se substituer à
Java dans les infrastructures logicielles, tout en offrant une réponse
à la problématique moderne des traitements concourants. Il est
construit sur le constat que l’on doit renoncer à toutes modifications
concurrentes des structures de données. »

Cela dit, je ne suis pas sur de l’intérêt. Traduire la documentation
et rédiger un didacticiel serait plus pragmatique ?

Pierre.

--~--~-~--~~~---~--~~
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: writing binary values (bytes) to a file

2008-11-21 Thread prhlava


Hello Jeffrey,

> Code is located at: 
> http://github.com/jbester/cljext/tree/master/cljext%2Fbinpack.clj

Thanks for the link, more food for study on how to write a generic
library...

Basically, I am scheme/lisp noob, learning it in my spare time, the
progress is slow but rewarding...

Few observations about my own experience with starting with lisp:

1. concentrate on meaning and what fuctions do, not on the form and
""
2. name your functions well
3. use tools to have your code idented properly
4. learn ways of creating abstracions and recognising when one is
asking to be written
(this thread kickstarted 4.)

Kind regards,

Vlad
--~--~-~--~~~---~--~~
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: loss of gen-and-load-class functionality

2008-11-21 Thread Stephen Wrobleski

On Fri, Nov 21, 2008 at 03:38:01PM -0500, Stephen Wrobleski wrote:
> Now, I can see a standard way of doing something like this
> 
> (defmacro def-gen-class [name & options]
>   (let [{:keys [name bytecode]}
> (eval `(gen-class ~(str name) [EMAIL PROTECTED]))]
> (if *compile-files*
>   (.writeClassFile Compiler (.replace name "." "/")
> bytecode)
>   (.. clojure.lang.RT ROOT_CLASSLOADER
>   (defineClass (str name) bytecode)))
> 
>   '(do)))
> 
> (Haven't thought much about the proper phasing. But I used a macro so that
> nothing is left around after compile-time)
> 

heh heh, that whole approach is terrible. I must have been thinking that
eval has magical access to a macro's lexical environment.

The best we can do seems to be to generate the class, and if its not already
defined (presumably from AOT), either defineClass or writeClassFile based on
*compile-files*. I don't think its possible to error out on an already
defined class unless we can figure out that we're not in the initializer of
an AOT compiled module.


--~--~-~--~~~---~--~~
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: writing binary values (bytes) to a file

2008-11-21 Thread Graham Fawcett

Hi Vlad,

On Thu, Nov 20, 2008 at 5:36 PM, prhlava <[EMAIL PROTECTED]> wrote:
>
> Hello Graham,
>
>> Bonus question for the bored reader: write a function,
>> (byte-array-maker N), that takes a width N, and returns a function
>> that takes an Integer as input and returns an N-width byte array
>> containing the Integer in big-endian order. E.g.
>>
>> ((byte-array-maker 4) 652187261)
>> => [4-byte array: 26, df, 96, 7d]
>
> :-) writing the function thought me quite a bit :-)

Then my work here is done. ;-) I'm glad you took the challenge!

Best,
Graham



>
> Vlad
> >
>

--~--~-~--~~~---~--~~
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: Monads in Clojure

2008-11-21 Thread jan

Stuart Sierra writes:
> Rich gives out commit permission on clojure-contrib to people who are
> interested, but he doesn't dictate what goes in.  You have to sign the
> Clojure Contributor agreement, which basically says that if the
> Clojure license changes at some point, you allow your contribution to
> be released under the same license (still open-source, of course).

This paper 

http://www.rosenlaw.com/OSL3.0-explained.pdf

suggests an alternative to contributor agreements that might be worth
considering.

Here is the relevant section:

   This is also a function that can be performed by the Academic Free
   License. AFL 3.0 is identical to OSL 3.0 except that licensees are
   now free "to distribute or communicate copies of the Original Work
   and Derivative Works to the public, under any license of your choice
   that does not contradict the terms and conditions, including
   Licensor's reserved rights and remedies, in this Academic Free
   License." That makes AFL 3.0 a suitable contributor license to other
   open source projects, especially (but not only) those projects
   distributing software under OSL 3.0. The project is then free to
   revise its outgoing license in accordance with its bylaws and charter
   as the times dictate.

   Instead of a contributor agreement, then, I often recommend that
   contributors offer their contribution to a project by placing the
   following notice adjacent to their copyright notice:

   Licensed to Project XYZ under the Academic Free License (AFL 3.0).

--~--~-~--~~~---~--~~
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: offtopic - where are you come from? (poll)

2008-11-21 Thread Telman Yusupov

Toronto, Canada

--~--~-~--~~~---~--~~
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: Any style/idiom hints for this random sampling function?

2008-11-21 Thread Stuart Sierra

Hi Steve,
Although the reduce is very Lispy, in this case it might be clearer
with loop/recur:

(defn random-sample [sample-size items]
  (loop [num 0,
 current [],
 items items]
(if-let [item (first items)]
(if (< num sample-size)
  (recur (inc num) (conj current item) (rest items))
  (let [index (rand-int num)]
(if (< index sample-size)
  (recur (inc num) (assoc current index item) (rest
items))
  (recur (inc num) current (rest items)
  current)))

It could go in clojure.contrib.seq-utils.  I'll add it there if you
like.
-Stuart Sierra


On Nov 21, 5:40 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I needed a random sampling function for work and wrote this in
> Clojure.
>
> (defn random-sample
>   "Take a random sample of size `sample-size' from the `items'
> sequence.
>
> This uses Algorithm R -- random sampling with a reservoir.  It
> requires O(`sample-size') space and does not need to know the size of
> `items' ahead of time.  Described in Knuth's The Art of Computer
> Programming, volume 2."
>   [sample-size items]
>   (let [maybe-insert-item
>         (fn [[num current] item]
>           (if (< num sample-size)
>             [(inc num) (conj current item)]
>             (let [index (rand-int num)]
>               (if (< index sample-size)
>                 [(inc num) (assoc current index item)]
>                 [(inc num) current]]
>     (second (reduce maybe-insert-item [0 []] items
>
> It seems to work fine, but it strikes me as a little busy with ()[],
> even for Lisp. Does anyone have any pointers? Will the internal
> function "maybe-insert-item" be evaluated every time "random-sample"
> is called, and if so, is that worth worrying about wrt. program
> optimization?
>
> Does this sort of thing belong in clojure-contrib or somewhere else?
> It seems awfully short but it's a nice function to have, at least for
> me.
>
> Thanks,
> 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: offtopic - where are you come from? (poll)

2008-11-21 Thread Graham Fawcett

On Fri, Nov 21, 2008 at 8:14 PM, Telman Yusupov <[EMAIL PROTECTED]> wrote:
>
> Toronto, Canada

Another Canadian! The more the merrier. :-)

Just a reminder that I put up a Google map of Clojure users worldwide:

http://tinyurl.com/5kl68p

If you're so inclined, you're invited to take a moment and add
yourself to the map.

I know the map and this discussion thread aren't of any technical
value, but it's very nice to feel the size and scope of the Clojure
community.
Thank you, Rastislav Kassak, for starting the original thread.

Best,
Graham

--~--~-~--~~~---~--~~
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: offtopic - where are you come from? (poll)

2008-11-21 Thread Brian Doyle
Denver, CO

Brian Doyle

On Wed, Nov 19, 2008 at 4:09 AM, liu chang <[EMAIL PROTECTED]> wrote:

>
> Singapore +1.
>
> On Wed, Nov 19, 2008 at 5:24 PM, walterc <[EMAIL PROTECTED]> wrote:
> >
> > taipei, taiwan
> >
> > cheers,
> >
> > walter chang
> > >
> >
>
> >
>

--~--~-~--~~~---~--~~
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: universal main() with repl/script/compile

2008-11-21 Thread Stuart Sierra
Thanks, Stephen -- good feedback!  I fixed [2] and [3].  Not sure
about [1], maybe it's a line-ending thing.  Anyway, this new patch
(attached) was written on OSX, so it had better work!
-S


On Nov 21, 5:31 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> On Nov 21, 2008, at 12:34 PM, Stuart Sierra wrote:
>
> > The attached patch combines Repl, Script, and the lib compiler that
> > Stephen G. and I have worked on.
>
> Hi Stuart,
>
> I like the concept very much.
>
> I had a couple of problems in working with the patch:
>
> [1] patch on Mac OS X Leopard rejected the build.xml portion of the
> patch you posted. I'm not sure what the problem was. As a result, I
> made the changes manually to a fresh svn 1121 build.xml.
>
> [2] your clojure.lang.Main uses Arrays.copyOfRange which is apparently
> unavailable until Java SE 6. We are targeting Java 1.5 in the ant
> task. I'm unable to get this to compile even if I remove the
> "target=1.5" option. I find that a bit odd because my default java
> tools should be Java 6-based.
>
> [3] Is the example at the top of build.xml under "description" still
> correct? I would like to see the example be "java -jar clojure.jar" to
> launch a REPL.
>
> Thanks for Main! I think it's a great idea and I look forward to using
> it.
>
> --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
-~--~~~~--~~--~--~---



universal-main2.patch
Description: Binary data


Re: Any style/idiom hints for this random sampling function?

2008-11-21 Thread [EMAIL PROTECTED]



On Nov 21, 9:03 pm, Stuart Sierra <[EMAIL PROTECTED]> wrote:
> Hi Steve,
> Although the reduce is very Lispy, in this case it might be clearer
> with loop/recur:
>
Thanks for your rewrite. I don't see if-let in the website API
documentation. I suppose I should track the latest instead of using
the release.

> It could go in clojure.contrib.seq-utils.  I'll add it there if you
> like.
> -Stuart Sierra

That'd be fine. One thing that strikes me is that the (if (< num
sample-size) ...) test is unnecessary after sample-size has been
reached. It might be better to write it as two loops for that reason.

-- 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: mutability

2008-11-21 Thread islon

I added the project in google code (github kept complaining about my
public key)
http://code.google.com/p/randomrpg/

I reduced the LOC to ~900.
I'll try once more to port it to clojure (thanks for the macro Adam),
but don't know when i'll be done.

Regards.
Islon

On Nov 21, 4:27 pm, Adam Jones <[EMAIL PROTECTED]> wrote:
> On Nov 20, 12:23 pm, islon <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm porting my single thread simple mud-like rpg game from scala to
> > clojure and one thing that is annoying me is the code needed to change
> > some var.
> > In scala I do things like that:
>
> > val player = new Player(...)
>
> > player.str += 1
>
> > in clojure I have to do (player is a struct and its attributes are
> > refs):
>
> > (def player (Player ...))
>
> > (dosync (ref-set player (assoc player :str (inc (:str player)
>
> > In scala when I want mutability I just define the variable with "var"
> > instead of "val", just one letter, simple and elegant.
> > It's a game, it's full of states and mutability, the game is single
> > thread, I don't need transactions. Am I missing something?
>
> If this is really that big of a deal, you could always go the macro
> route. I'm not experienced enough to say if this is a long-term good
> decision, but here's a first pass, don't even have Clojure available
> to try it, attempt at wrapping up Chouser's suggestion (I think :=
> would be better here, but that clashes with keyword definition):
>
> (defmacro |= [target attr fun]
>   "Updates 'attr' of 'target' by passing the current value to 'fun'
> and commuting the result, all inside of a transaction"
>   `(dosync
>     (commute ~target update-in [~attr] ~fun)))
>
> With usage:
>
> (|= player :str inc)
>
> That look a little better?
>
> -Adam
--~--~-~--~~~---~--~~
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: Use of "/" to call static method in generated classes

2008-11-21 Thread Craig McDaniel

Thanks for the explanation. I just wanted to report it in case it
might be a bug.

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



Newbie: Adding metadata to a method

2008-11-21 Thread samppi

I'm trying to unit-test a mutli-function's methods without resorting
to a separate test file. I can do this:

  (defn foo
([x] (+ x 2))
{:test (fn [] (= (foo 3) 4))})

...but how do I do something like this?

  ; Does not work
  (defmethod foo :mapping
([x] (assoc x :a 5))
{:test (fn [] (= (foo {:a 3 :b 2}) {:a 5 :b 2}))})

I can't find a way to attach metadata to methods. I can't find a
function that creates a standalone method that I can define a variable
with. Is it currently possible to somehow do this another way?


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