Re: Dynamic gen-class

2010-06-27 Thread Meikel Brandmeyer
Hi,

On Jun 28, 5:38 am, Brian Hurt  wrote:

> This is actually something that has been bugging me for a while.  Most of
> the time this isn't a problem (being unable to generate classes in the repl,
> basically), except in one case: exceptions.  It'd be nice to be able to
> define classes that inherit from throwable, and be able to catch them, and
> have this code work the same way in the repl and compiled.

I'd like to see some unified error handling in Clojure. c.c.error-kit
could be an option. Or c.c.condition. Then you wouldn't have to
generate a exception class, but could use the pre-delivered Condition
augmented with easily accessible meta data.

Sincerely
Meikel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Life on the bleeding edge

2010-06-27 Thread Mark Engelberg
I ran mvn clean first.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Life on the bleeding edge

2010-06-27 Thread Mark Engelberg
OK, I just tried building clojure-contrib pointing at a clojure.jar
built from the current master branch.  I get the same errors (on
Windows).  Here are more details:

Testing clojure.contrib.test-io

FAIL in (test-as-url) (run-test9074812622524104689.clj:45)
expected: (= (URL. "file:/foo") (as-url (File. "/foo")))
  actual: (not (= # #))

FAIL in (test-relative-path-string) (run-test9074812622524104689.clj:45)
absolute path strings are forbidden
expected: (thrown? IllegalArgumentException (relative-path-string (str File/sepa
rator "baz")))
  actual: nil

FAIL in (test-relative-path-string) (run-test9074812622524104689.clj:45)
absolute File paths are forbidden
expected: (thrown? IllegalArgumentException (relative-path-string (File. (str Fi
le/separator "quux"
  actual: nil

Testing clojure.contrib.test-profile

FAIL in (test-print-summary) (run-test9074812622524104689.clj:45)
doesn't blow up with no data (assembla #31)
expected: (= "Name  mean   min   max count   sum\n" (with-ou
t-str (print-summary {})))
  actual: (not (= "Name  mean   min   max count   sum\n" "Na
me  mean   min   max count   sum\r\n"))

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: State of Clojure web development

2010-06-27 Thread Timothy Washington
I am using clojure to rewrite an online bookkeeping application (currently
only a test site). I have wanted to learn Lisp and functional programming
for a while now. And the emergence of Clojure, and the need to refactor my
application, gave me the opportunity.

While I'm still new to the language and functional programming, the
technical benefits of Clojure were immediately apparent to me. I think
others will give a good listing of those technical advantages that Clojure
offers. What struck me as I started to use it was how Clojure "feels".
Specifically, when I had to redo some Java code in Clojure, it was just
striking, the expressive power it gave me over Java. I haven't had this much
fun programming since I designed my first language !! Anyways, this isn't a
campfire :) The Bookkeeping's current stack is:

   - Java / Servlets ( I'm going to try Compojure here )
   - a custom DSL using http://SableCC.org ( 'proxy' macro beautifully lets
   me incrementally implement only features I need )
   - custom XML Java binding framework ( http://repo.or.cz/w/Bob.git -
   Clojure negates the need for this )
   - A native XML database, eXist, with a RESTful access service


Tim


On Wed, Jun 23, 2010 at 5:23 PM, James Reeves wrote:

> Hello there!
>
> Chas Emerick's recent "State of Clojure" survey [http://bit.ly/dtdAwb]
> indicated that a significant proportion of Clojure users are beginning
> to use Clojure for web development. A recent Hacker News posting
> [http://bit.ly/91Bu5J] seems to corroborate these results, with
> several Clojure-based web applications already out in the wild.
>
> As one of the main developers of Ring and Compojure, I'd be very
> interested to hear more about how people are using Clojure to build
> web apps. To this end, I have a few questions I'd like to quiz Clojure
> web developers about:
>
> 1. Have you written, or are you writing, a web application that uses
> Clojure? What does it do?
>
> 2. Which libraries or frameworks are you using? Which versions?
>
> 3. What made you choose Clojure to develop web applications in? What
> are the strengths of Clojure web development?
>
> 4. What do you think are the current weaknesses of web development in
> Clojure? What could be improved?
>
> 5. Anything else you want to comment on?
>
> Please reply to this thread with your answers, and thank you very much
> in advance for your time. I really appreciate any feedback you can
> provide.
>
> - James
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Life on the bleeding edge

2010-06-27 Thread Michał Marczyk
On 28 June 2010 06:11, Garth Sheldon-Coulson  wrote:
> Ah, thanks. I also see no test failures (archlinux).

After realising that the not-AOT-compiled namespaces might still break
when require'd, I went ahead and tested a couple of them. There was
about a 50/50 split between the working namespaces and the broken
namespaces in my (very) small sample. Unfortunately c.c.macro-utils
and c.c.pprint are both on the "broken" side, which I guess means no
out-of-the-box swanking. :-/

Sincerely,
Michał

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Life on the bleeding edge

2010-06-27 Thread Garth Sheldon-Coulson
Ah, thanks. I also see no test failures (archlinux).

On Sun, Jun 27, 2010 at 11:31 PM, Michał Marczyk
wrote:

> On 28 June 2010 05:11, Garth Sheldon-Coulson  wrote:
> > When I try to compile clojure-contrib with the equiv branch on archlinux,
> > maven 2.2.1, jre 1.6.0_20, I get:
>
> Be sure to run mvn clean first.
>
> Sincerely,
> Michał
>
> --
> 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
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Life on the bleeding edge

2010-06-27 Thread Michał Marczyk
On 28 June 2010 05:11, Garth Sheldon-Coulson  wrote:
> Compiling clojure.contrib.condition.Condition to
> /mnt/hgfs/sirfoobar/Documents/Eclipse/clojure-contrib/target/classes
> Exception in thread "main" java.lang.NoClassDefFoundError:
> clojure/lang/ILookupHost

Ah, sorry, it just occurred to me that I might not be checking all the
relevant places. After mvn clean, I can build clojure-contrib.jar
against equiv clojure.jar, but (require 'clojure.contrib.condition)
later throws the above mentioned exception for me at the REPL.

Also, I wasn't entirely sure if I'd uploaded the correct jars to the
drop the first time round, so I went ahead and uploaded them again.

Sincerely,
Michał

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Dynamic gen-class

2010-06-27 Thread Brian Hurt
On Sun, Jun 27, 2010 at 4:54 PM, rob levy  wrote:

> HI Michael,
>
> If I understand correctly, the proxy function might be what you are looking
> for.  I think gen-class can only be used with AOT compilation.
>
> -Rob
>
>
This is actually something that has been bugging me for a while.  Most of
the time this isn't a problem (being unable to generate classes in the repl,
basically), except in one case: exceptions.  It'd be nice to be able to
define classes that inherit from throwable, and be able to catch them, and
have this code work the same way in the repl and compiled.

Brian

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Life on the bleeding edge

2010-06-27 Thread Michał Marczyk
On 28 June 2010 05:11, Garth Sheldon-Coulson  wrote:
> When I try to compile clojure-contrib with the equiv branch on archlinux,
> maven 2.2.1, jre 1.6.0_20, I get:

Be sure to run mvn clean first.

Sincerely,
Michał

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Life on the bleeding edge

2010-06-27 Thread Garth Sheldon-Coulson
When I try to compile clojure-contrib with the equiv branch on archlinux,
maven 2.2.1, jre 1.6.0_20, I get:

Compiling clojure.contrib.condition.Condition to
/mnt/hgfs/sirfoobar/Documents/Eclipse/clojure-contrib/target/classes
Exception in thread "main" java.lang.NoClassDefFoundError:
clojure/lang/ILookupHost

Everything works fine with master.

Not that I expect contrib to work with equiv, but it's curious that it works
for Michal and not for me.

Garth


> Everything works fine for me in an Ubuntu environment.
>
>

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Life on the bleeding edge

2010-06-27 Thread Michał Marczyk
On 28 June 2010 03:23, Mark Engelberg  wrote:
> Thanks.  I had tried that, but I got further as soon as I tried:
>  mvn package -Dclojure.jar=c:/absolute/path/to/clojure.jar
>
> I'm now getting 3 failures in clojure.contrib.test_io and 1 in test_profile.
>
> Is this normal, or is something else going on here, perhaps some
> incompatibility between the equiv branch of clojure and the master
> branch of clojure-contrib?  If it is an incompatibility, what branch
> of contrib should I change to, and how do I do it (as I mentioned, I
> got an error when I tried "git checkout origin/new")?

Everything works fine for me in an Ubuntu environment.

Maybe you could try building contrib against a clojure.jar locally
built from master, just to check if it's an existing problem with
contrib builds on Windows?

Also, if you just want to play around with the equiv branch, here are
my locally compiled jars:

http://drop.io/cljequivjars

(Set to expire in a week from now.)

Sincerely,
Michał

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Life on the bleeding edge

2010-06-27 Thread Mark Engelberg
On Sun, Jun 27, 2010 at 5:33 PM, Michał Marczyk
 wrote:
> mvn package -Dclojure.jar=/absolute/path/to/clojure.jar

Thanks.  I had tried that, but I got further as soon as I tried:
 mvn package -Dclojure.jar=c:/absolute/path/to/clojure.jar

I'm now getting 3 failures in clojure.contrib.test_io and 1 in test_profile.

Is this normal, or is something else going on here, perhaps some
incompatibility between the equiv branch of clojure and the master
branch of clojure-contrib?  If it is an incompatibility, what branch
of contrib should I change to, and how do I do it (as I mentioned, I
got an error when I tried "git checkout origin/new")?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Life on the bleeding edge

2010-06-27 Thread Michał Marczyk
On 28 June 2010 01:53, Mark Engelberg  wrote:
> Ran ant.  Didn't work (no ant build file.  Why does clojure-contrib
> have a different build process than clojure?).

Good question.

> Ran "maven package" in the clojure-contrib directory.

You need to tell it where to look for clojure.jar. On Linux, this is
accomplished as follows:

mvn package -Dclojure.jar=/absolute/path/to/clojure.jar

Hopefully the Windows command accepts the same option format.

Sincerely,
Michał

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: the joys of lisp

2010-06-27 Thread rob levy
Certainly macros can be dangerous if used recklessly or clumsily, but

> isn't trusting the programmer and giving him powerful tools what Lisp
> is all about? No other language provides the same power of expression.
> A tour through the Clojure code demonstrates just how powerful this
> idea is and how easy it makes it for the language implementors to
> implement features in a few lines of code that are major bullet-point
> features in other languages.
>
>
In my opinion it is much better to empower developers and build a culture of
good taste and self-discipline, than to limit the language in an attempt to
enforce particular styles.  Python is the latter and Lisp is the former.
 And Python code is  often convoluted because of programmers working around
the limitations imposed by the language.  And don't get me started on lines
of code that begin at column 80 etc. ;)

I would argue in favor of user-defined reader macros for these same reasons,
they are rarely needed but why not maximize the power of Clojure?  I think
the last word on this from Rich Hickey was "many things that would otherwise
have
forced people to reader macros may end up in Clojure, where everyone can
benefit from a common approach".  To me this is Rich being like Guido von
Rossum, but maybe there are other good reasons behind the decision that he
has either not articulated or I just am not aware of/haven't read.

Rob

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Life on the bleeding edge

2010-06-27 Thread Mark Engelberg
I spent some time today trying unsuccessfully to get the equiv branch
up and running on Windows.  I'd appreciate some guidance.

I downloaded git, installed git.
Used git to "clone" the github repository.
Used git to "checkout origin/equiv".
Downloaded ant.
Installed ant.
Ran ant.
Seemed to work.
Used git to "clone" the clojure-contrib github repository.
Ran ant.  Didn't work (no ant build file.  Why does clojure-contrib
have a different build process than clojure?).
Installed maven.
Ran "maven package" in the clojure-contrib directory.
It churned for a while, and the reported a java exception:
"Unable to resolve symbol: flatten in this context (literals.clj:
169)" and an enormous stacktrace.

I thought maybe the contrib branch is incompatible with this new
branch of clojure.  So I tried:
"git checkout origin/new"
but got an error that I can't switch branches due to a local change in
test_math.clj (which makes no sense to me because I didn't make any
changes to any file after the initial clone).

It took me a long time to get this far, but now I feel stuck.  Any ideas?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: the joys of lisp

2010-06-27 Thread cageface
On Jun 27, 1:17 pm, Mike Meyer  wrote:
> Not quite - it's to keep the language *readable*. And if there's a use
> case for a feature that outweighs the damage done by abusing it,
> they'll add it. Witness with, list comprehensions, and those
> never-to-sufficiently-cursed augmented assignment operators. This
> implies simple only to the extent that it shouldn't get so large that
> one person can't keep the entire language in their head.

Python passed that point for me a long time ago. I'm always referring
to the docs. But that's true of most of the languages I work with now.

> So how does providing a drill press and bolt set (i.e. - macros) to
> the end user fit into this?

Certainly macros can be dangerous if used recklessly or clumsily, but
isn't trusting the programmer and giving him powerful tools what Lisp
is all about? No other language provides the same power of expression.
A tour through the Clojure code demonstrates just how powerful this
idea is and how easy it makes it for the language implementors to
implement features in a few lines of code that are major bullet-point
features in other languages.

> Well, there are already multiple OO implementations on top of
> 1.1. Most of them are more to show that you can do that if you really
> want to, and I'm not sure how much the additions to 1.2 will obsolete
> them.

I have to admit it's not entirely clear to me how to reconcile java
objects, tagged hashes, and protocols as alternative OO models in
Clojure It's probably just a lack of effort on my part in reading the
source and docs but I can't say that the ADT/OO story in Clojure is as
simple as the Python/Ruby approach, at least from the point of view of
the beginner.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Dynamic gen-class

2010-06-27 Thread rob levy
HI Michael,

If I understand correctly, the proxy function might be what you are looking
for.  I think gen-class can only be used with AOT compilation.

-Rob

On Sun, Jun 27, 2010 at 8:19 AM, Michael Jaaka  wrote:

> Hi,
>
> Is there any way to generate class in runtime and then use it?
> How far I can only generate interfaces.
>
> This works:
>
> (do
> (gen-interface  :name test.commons.Me
>:methods [[ me [ String ] void ]])
>
> (def z (reify test.commons.Me
>(me [t z] (println "hello world" z
>
> (.me z "wowo")
> )
>
>
>
> That doesn't:
>
>
>
> (do
> (gen-class :name test.commons.Mee
>:state sema
>:methods [
>[ me2 [ String ] void ]]
>:prefix "mee-"
> )
>
> (defn mee-me2[ this a ]
>(println "hello" a "had state" (.sema this)))
>
> (.me2 (test.commons.Mee. ) "world")
> )
>
>
>
> --
> 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
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: the joys of lisp

2010-06-27 Thread Mike Meyer
On Sun, 27 Jun 2010 12:41:36 -0700 (PDT)
cageface  wrote:

> Python definitely seems to be the product of a very different design
> philosophy than Lisp. I've always felt it was too prescriptive.
> Omitting features that *might* be misused in an effort to keep the
> language simple seems to have backfired on them.

Not quite - it's to keep the language *readable*. And if there's a use
case for a feature that outweighs the damage done by abusing it,
they'll add it. Witness with, list comprehensions, and those
never-to-sufficiently-cursed augmented assignment operators. This
implies simple only to the extent that it shouldn't get so large that
one person can't keep the entire language in their head.

And yes, it's gotten a bit larger than most people would like. But
that's part of the point of Python 3.0 - removing some of the bits
that have been obsoleted by more recent additions, or at least moving
them out of the language core.

> Too keep up with the
> competition they've had to add so many new features to the core
> language (list comprehensions, annotations, iterators, with statement,
> properties etc) that Python doesn't feel like a small, simple language
> to me at all anymore. Anyway, I don't mean to pick on Python because
> it's not a bad language. I think this just illustrates that it's
> better to build from a simple, flexible core than to bolt on pieces
> later.

So how does providing a drill press and bolt set (i.e. - macros) to
the end user fit into this?

> I think you can go too far in the other direction too though.
> Certainly Scheme is a very elegant language but omits so much from the
> spec that you have dozens of incompatible OO implementations floating
> around. I think at a minimum a language should provide a single,
> consistent, standard implementation of the following:
> 
> 1. a string/text type
> 2. an abstract datatype/object model
> 3. container types
> 4. concurrency primitives
> 5. ffi
> 
> Clojure covers these points well, I think, and I'm not worried about
> Clojure fracturing into a babel of incompatible macro-based dialects.

Well, there are already multiple OO implementations on top of
1.1. Most of them are more to show that you can do that if you really
want to, and I'm not sure how much the additions to 1.2 will obsolete
them.

 http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: the joys of lisp

2010-06-27 Thread cageface
Python definitely seems to be the product of a very different design
philosophy than Lisp. I've always felt it was too prescriptive.
Omitting features that *might* be misused in an effort to keep the
language simple seems to have backfired on them. Too keep up with the
competition they've had to add so many new features to the core
language (list comprehensions, annotations, iterators, with statement,
properties etc) that Python doesn't feel like a small, simple language
to me at all anymore. Anyway, I don't mean to pick on Python because
it's not a bad language. I think this just illustrates that it's
better to build from a simple, flexible core than to bolt on pieces
later.

I think you can go too far in the other direction too though.
Certainly Scheme is a very elegant language but omits so much from the
spec that you have dozens of incompatible OO implementations floating
around. I think at a minimum a language should provide a single,
consistent, standard implementation of the following:

1. a string/text type
2. an abstract datatype/object model
3. container types
4. concurrency primitives
5. ffi

Clojure covers these points well, I think, and I'm not worried about
Clojure fracturing into a babel of incompatible macro-based dialects.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: State of Clojure web development

2010-06-27 Thread Straszheim, Jeff

At Akamai we are using Clojure combined with Compojure for a project that 
involves the live transcoding of mobile content.  I can't talk about the 
details, nor mention any specific libraries or features we are using, except to 
say that we chose Clojure for the normal reasons:  its meta-programming and 
concurrency features.  We are very happy with our decision to use Clojure.

(We're hiring for this project.)



Jeffrey Straszheim 
Senior Software Engineer

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

<><><>
Office: 954.652.2243
Cell: 561.504.9913
Akamai Technologies
8 Cambridge Center
Cambridge, MA 02142

<>


On Jun 23, 2010, at 5:23 PM, James Reeves wrote:

> Hello there!
> 
> Chas Emerick's recent "State of Clojure" survey [http://bit.ly/dtdAwb]
> indicated that a significant proportion of Clojure users are beginning
> to use Clojure for web development. A recent Hacker News posting
> [http://bit.ly/91Bu5J] seems to corroborate these results, with
> several Clojure-based web applications already out in the wild.
> 
> As one of the main developers of Ring and Compojure, I'd be very
> interested to hear more about how people are using Clojure to build
> web apps. To this end, I have a few questions I'd like to quiz Clojure
> web developers about:
> 
> 1. Have you written, or are you writing, a web application that uses
> Clojure? What does it do?
> 
> 2. Which libraries or frameworks are you using? Which versions?
> 
> 3. What made you choose Clojure to develop web applications in? What
> are the strengths of Clojure web development?
> 
> 4. What do you think are the current weaknesses of web development in
> Clojure? What could be improved?
> 
> 5. Anything else you want to comment on?
> 
> Please reply to this thread with your answers, and thank you very much
> in advance for your time. I really appreciate any feedback you can
> provide.
> 
> - James
> 



Re: the joys of lisp

2010-06-27 Thread Mike Meyer
On Sun, 27 Jun 2010 11:58:16 -0700 (PDT)
cageface  wrote:

> When I read about new "features" in other languages that would be
> simple macros in Lisp I just have to smile:
> http://docs.python.org/dev/reference/compound_stmts.html#with

Many in the Python community consider this an advantage of Python. It
means semantic changes only get added to the language after proper
consideration by the community, the experts who maintain the language,
and the BDFL. Common LISP (or more accurately, the evolution from LISP
1.5 through the many and sundry dialects and thence to Common LISP) is
held up as an example of how badly wrong allowing anyone to create
statements can go.

But yeah, many people in the Python community also want LISP-like
macros, extolling the virtues of "with" so often that it was added to
the language. And a nice addition it was (seems kinda old these
days...).

http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


the joys of lisp

2010-06-27 Thread cageface
When I read about new "features" in other languages that would be
simple macros in Lisp I just have to smile:
http://docs.python.org/dev/reference/compound_stmts.html#with

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Drawable Sets

2010-06-27 Thread Garth Sheldon-Coulson
>
> I think you can solve the holes on delete by permuting the removed element
> with the last element and keeping a map from value to their index.
>

Good idea!

Thanks you very much for these suggestions.
>

You're welcome. The hashtrie is a much better idea for this situation, of
course.

Couldn't you just slightly extend Rich's PersistentHashMap? (Maybe I'm
misunderstanding what you're looking for or what PersistentHashMap is all
about.)

Just brainstorming now:

If you did extend Rich's, it would be pretty cool to build a generalized
version of Clojure's hash-map construction function ("hash-map-searchable"
or something) that took two extra arguments: a function called by a leaf
node on its value and a function called by a non-leaf node on a coll of its
subnodes. On every update, every node in the update path would call one of
these functions and store the result in the node.

(If your objects are maps with key :mass, then the first function would be
:mass, and the second function would be #(reduce + %).)

Then one could build a general function "search-map" taking a hash-map and a
search function. The search function would accept a coll of stored node
values (the values of a node's subnodes) and return the index of the subnode
to follow down the tree. The search function would be called on the root
node on down, following the returned index each time, until it hit a leaf
node, which it would return. You could implement your case really easily in
this framework, I think, and it might also make it easy to build other kinds
of more complicated search down the branches of a hash-map hashtrie.

Garth

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: New Primitive data types (equal branch) - impact on optimized code.

2010-06-27 Thread Nicolas Oury
On Sat, Jun 26, 2010 at 6:56 PM, j-g-faustus wrote:

>
> On my machine this is about 4x slower than the shootout Java
> implementation. Using Java as the baseline and comparing my local
> results to the shootout timings, it puts Clojure 1.1 on par with
> Erlang, Go and OCaml.
>
> On profiling I have a bunch of intCast(Object) and doubleCast(double)
> totaling ~9% CPU time (no screenshot yet, sorry), I'll see if I can
> eliminate them for a few percent improvement.
>

Which Hotspot and flags do you use?
You could be more idiomatic and probably faster with 1.2's (definterface
Body-ish  (x[]..). x= ...)  and the like with type annotations (or better
with protocols, but they have no annotations yet, I think)
 and (deftype Body [x y ...] Body-ish ).
Object field access are a bit faster than array access on the jvm. (as a
first try, you could mesure the difference with using the Body class from
java and the main loop in clojure, to check where the
difference comes from)

Best regards,

Nicolas.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Protocols

2010-06-27 Thread Rich Hickey


On Jun 27, 2010, at 1:09 AM, Mark Engelberg wrote:


Is there a list somewhere of all the protocols built-in to Clojure
1.2's core that are available for extension?



There are no extension points built on protocols in Clojure yet.  
Delivering protocols is step one, re-architecting the core  
abstractions in terms of protocols is still to come.


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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Converting list to Map

2010-06-27 Thread Mike Meyer
On Sat, 26 Jun 2010 15:54:34 -0700 (PDT)
hsarvell  wrote:

> I tried to find something in core / on Google to do this but didn't,
> here is what I have anyway:
> 
> (defn lst-to-map [lst]
>(reduce
>   (fn [hsh chunk]
>  (assoc hsh (first chunk) (last chunk)))
>   (hash-map)
>   (partition 2 lst)))
> 
> Is there an easier/shorter way?

(apply hash-map lst)

http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Enhanced primitive support - redux

2010-06-27 Thread Daniel
If there is some sort of new numeric tower on the plate, what would be
some desirable properties?

On Jun 25, 10:58 pm, Andrzej  wrote:
> On Sat, Jun 26, 2010 at 4:04 AM, Rich Hickey  wrote:
> > equiv, the revenge of num
>
> Has it already been decided that some sort of this new numeric tower
> will find its way into Clojure?
>
> Andrzej

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Question: pmap + number of threads + number of cpus

2010-06-27 Thread toddg
(running clojure 1.2 snapshot)

Q1: Why does pmap use the number of available processors + 2? I would
have thought it would just use the number of avail processors...

Q2: Could someone clear up my misunderstanding of pmap w/ respect to
the code snippets below? Pmap doesn't seem to be limiting the number
of threads to the number of processors + 2...

I've created an anon func that does't return, so I wouldn't expect the
pmap step function to advance beyond 4 (I have 2 processors):

#1: Limit pmap to # of processors
--

user=> (pmap #(while true (do (println "Thread: " (.getId (Thread/
currentThread)) "item: " %)(Thread/sleep 500))) (range
(.availableProcessors (Runtime/getRuntime
Thread:  12 item:  0
(Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0

--> just two threads running, as expected


#2: Limit pmap to # of processors * 10
--

user=> (pmap #(while true (do (println "Thread: " (.getId (Thread/
currentThread)) "item: " %)(Thread/sleep 500))) (range (* 10
(.availableProcessors (Runtime/getRuntime)
Thread: Thread:   12 item:  0
(Thread:  25 item:  13
Thread:  24 item:  12
Thread:  23 item:  11
Thread:  22 item:  10
Thread:  21 item:  9
Thread:  20 item:  8
Thread:  19 item:  7
Thread:  18 item:  6
Thread:  17 item:  5
Thread:  16 item:  4
Thread:  15 item:  3

--> In this short snippet, you can see > 4 threads running...expected?


toddg=> (source pmap)
(defn pmap
  "Like map, except f is applied in parallel. Semi-lazy in that the
  parallel computation stays ahead of the consumption, but doesn't
  realize the entire result unless required. Only useful for
  computationally intensive functions where the time of f dominates
  the coordination overhead."
  {:added "1.0"}
  ([f coll]
   (let [n (+ 2 (.. Runtime getRuntime availableProcessors))
 rets (map #(future (f %)) coll)
 step (fn step [[x & xs :as vs] fs]
(lazy-seq
 (if-let [s (seq fs)]
   (cons (deref x) (step xs (rest s)))
   (map deref vs]
 (step rets (drop n rets
  

-Todd

p.s. It seems that any email I send from my desktop client
(thunderbird) does not reach the clojure alias
(clojure@googlegroups.com). Only emails that I send from the
groups.google.com web page seem to make it to the list. I've sent
several thank-you to folks who have responded to me in the past, so I
apologize if these did not materialize.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Converting list to Map

2010-06-27 Thread hsarvell
I tried to find something in core / on Google to do this but didn't,
here is what I have anyway:

(defn lst-to-map [lst]
   (reduce
  (fn [hsh chunk]
 (assoc hsh (first chunk) (last chunk)))
  (hash-map)
  (partition 2 lst)))

Is there an easier/shorter 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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Question re: pmap and the number of available processors

2010-06-27 Thread Todd

(running clojure 1.2 snapshot)

Q1: Why does pmap use the number of available processors + 2? I would 
have thought it would just use the number of avail processors...


Q2: Could someone clear up my misunderstanding of pmap w/ respect to the 
code snippets below? Pmap doesn't seem to be limiting the number of 
threads to the number of processors + 2...


I've created an anon func that does't return, so I wouldn't expect the 
pmap step function to advance beyond 4 (I have 2 processors):


#1: Limit pmap to # of processors
--

user=> (pmap #(while true (do (println "Thread: " (.getId 
(Thread/currentThread)) "item: " %)(Thread/sleep 500))) (range 
(.availableProcessors (Runtime/getRuntime

Thread:  12 item:  0
(Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0
Thread:  13 item:  1
Thread:  12 item:  0

--> just two threads running, as expected


#2: Limit pmap to # of processors * 10
--

user=> (pmap #(while true (do (println "Thread: " (.getId 
(Thread/currentThread)) "item: " %)(Thread/sleep 500))) (range (* 10 
(.availableProcessors (Runtime/getRuntime)

Thread: Thread:   12 item:  0
(Thread:  25 item:  13
Thread:  24 item:  12
Thread:  23 item:  11
Thread:  22 item:  10
Thread:  21 item:  9
Thread:  20 item:  8
Thread:  19 item:  7
Thread:  18 item:  6
Thread:  17 item:  5
Thread:  16 item:  4
Thread:  15 item:  3

--> In this short snippet, you can see > 4 threads running...expected?


toddg=> (source pmap)
(defn pmap
  "Like map, except f is applied in parallel. Semi-lazy in that the
  parallel computation stays ahead of the consumption, but doesn't
  realize the entire result unless required. Only useful for
  computationally intensive functions where the time of f dominates
  the coordination overhead."
  {:added "1.0"}
  ([f coll]
   (let [n (+ 2 (.. Runtime getRuntime availableProcessors))
 rets (map #(future (f %)) coll)
 step (fn step [[x & xs :as vs] fs]
(lazy-seq
 (if-let [s (seq fs)]
   (cons (deref x) (step xs (rest s)))
   (map deref vs]
 (step rets (drop n rets
  

-Todd

--
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: New Primitive data types (equal branch) - impact on optimized code.

2010-06-27 Thread j-g-faustus
Possibly of interest here, although I've only tested it using Clojure
1.1:

I just did an implementation of the n-body problem from
http://shootout.alioth.debian.org/u32q/benchmark.php?test=nbody&lang=all

The fastest code I've managed so far is here:
http://github.com/j-g-faustus/Clojure-test-code/blob/master/shootout/nbody.clj

On my machine this is about 4x slower than the shootout Java
implementation. Using Java as the baseline and comparing my local
results to the shootout timings, it puts Clojure 1.1 on par with
Erlang, Go and OCaml.

On profiling I have a bunch of intCast(Object) and doubleCast(double)
totaling ~9% CPU time (no screenshot yet, sorry), I'll see if I can
eliminate them for a few percent improvement.

A bit more here:
http://stackoverflow.com/questions/3124344/clojure-number-crunching-performance
where I am also asking
* are there any obvious improvements to my code?
* do you consider 4x slower than Java and 10x quicker than Python/Ruby
representative for Clojure performance?

For the record, I think an order of magnitude quicker than Perl/Python/
Ruby is a quite decent result.
~4x slower than C, Java and Scala is a performance hit I can live with
in return for a more comfortable language.

If 1.2 gives even better performance, or similar performance with less
effort, so much the better.

Regards
jf

PS: If there are no obvious improvements, I'd like to submit this n-
body implementation to the shootout. Any objections? (Like "wait for
1.2"?)


On Jun 24, 11:08 pm, "Heinz N. Gies"  wrote:
> The benchmark I did was the fannkuchen-redux benchmark the code I came up 
> with was the following:
>
> http://github.com/Licenser/clj-shootout/blob/master/fannkuchen/src/pr...
>
> the scala version I used is from the alioth shootout:
>
> http://github.com/Licenser/clj-shootout/blob/master/fannkuchen/scala/...

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure Futures Docs and Functionality

2010-06-27 Thread Ryan Senior
Sounds good to me.  The first version of that function I wrote without
returning nil, but just bubbling up the exception.  I changed it because I
couldn't think of another area of the Clojure core that threw an exception
like that.  Looking through some of the agents code, I think there are some
similar scenarios that do throw an exception.

As far as the seconds/minutes etc stuff.  I just added that to not lose
anything from the Java API.  Getting rid of that, the much simpler function
looks like:

(defn future-await
  "Returns the value of the future just like a deref.  If the future has not
completed by timeout, nil is returned"
  [^java.util.concurrent.Future f timeout-in-millis]
(.get f timeout-in-millis java.util.concurrent.TimeUnit/MILLISECONDS))

Usage is same as before:

(def fut
   (future
(Thread/sleep 1)
"done"))
(future-await fut 1) ; throws java.util.concurrent.TimeoutException

(def fut
   (future
(Thread/sleep 1)
"done"))
(future-await fut 10) ; "done"

-Ryan


On Sat, Jun 26, 2010 at 12:56 AM, Meikel Brandmeyer  wrote:

> Hi,
>
> Am 25.06.2010 um 20:48 schrieb Daniel Werner:
>
> > On 25 June 2010 05:27, Ryan Senior  wrote:
> >> (future-await fut2 2 :minutes) ; => "done"
> >
> > What do others think?
>
> I agree – in particular for point 2.
>
> For point 1: I think "2 :minutes" is not very clojure-like. It sound more
> like Ruby: 2.minutes. A more clojure-like approach would be to an use
> optional keyword argument.
>
> (defn future-await
>  [fut & {:keys [timeout]}]
>  )
>
> (future-await zukunft)
> (future-await zukunft :timeout time-out-in-ms)
>
> Or of course the simple two-arg-version.
>
> Sincerely
> Meikel
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Duplicate key bug in hash-maps

2010-06-27 Thread Anton Josua
Easy to explain - absolutely, consistent - mm, not really...

I found this new behavior a bit confusing, imo it breaks principle of
least surprise.
This feature is uncommon in dynamic languages (even Scala allows
duplicate keys - Set('a,'a)/Map('a->1,'a->1)).

Also, from the practical point of view, when prototyping:
- repl: user>(some-fn #{1 ...}) ;just experiment here
- file: #{"http://xyz";  ...} ;bunch of statistical data
In both cases occasional duplicate is not critical.
However, one will be forced to spend extra time on input double-check
and/or deal with error message(s).

-anton

On Jun 25, 5:31 pm, Stuart Halloway  wrote:
> Duplicate keys in maps/sets are disallowed in literals and factory functions, 
> where data is generally literal & inline and therefore likely represents 
> coder error:
>
> ; all disallowed
> #{:a :a}
> {:a 1 :a 2}
> (hash-map :a 1 :a 2)
> (hash-set :a :a)
>
> They are allowed in other contexts, where the data could come from anywhere:
>
> ; dumb, but these forms not generally called with a literal
> (set [:a :a])
> (into #{} [:a :a])
>
> I find this behavior consistent and easy to explain, but I was involved in 
> the design conversation so maybe I have participant blindness. :-)
>
> Stu
>
>
>
> > On Fri, 25 Jun 2010 15:36:31 +0200
> > Michael Wood  wrote:
>
> >> On 25 June 2010 12:27, Tim Robinson  wrote:
> >>> I tried Clojure via Githhub today.
>
> >>> Anyone notice this bug that hadn't existed in Version 1.1
>
> >>> user=> #{:item1 {:a "A" :b "B"} :item2 {:a "A" :b "B"}}
> >>> java.lang.IllegalArgumentException: Duplicate key: {:a "A", :b "B"}
>
> >> You're trying to put duplicate values into a set.
>
> > So? Most places, putting a value that's already in a set into the set
> > is a nop. Even in clojure that exhibits the above behavior:
>
> > user=> #{:a :a}
> > java.lang.IllegalArgumentException: Duplicate key: :a
> > user=> (set [:a :a])
> > #{:a}
> > user=> (conj #{:a} :a)
> > #{:a}
> > user=>
>
> > Apparently, duplicate keys in sets are only disallowed in set
> > literals. Arguably, that must be a mistake on the users part, but
> > it sure seems to clash with the behavior of sets elsewhere.
>
> >      > --
> > Mike Meyer               
> > http://www.mired.org/consulting.html
> > Independent Network/Unix/Perforce consultant, email for more information.
>
> > O< ascii ribbon campaign - stop html mail -www.asciiribbon.org
>
> > --
> > 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
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Duplicate key bug in hash-maps

2010-06-27 Thread Mike Anderson
I agree that duplicate keys in literals are probably a coder error but
IMO this deserves some kind of compiler warning rather than an error.

You're going to get into lots of sticky situations otherwise that only
confuse people if the semantics are different between literals and
other usage. Simple is good.

On Jun 25, 3:31 pm, Stuart Halloway  wrote:
> Duplicate keys in maps/sets are disallowed in literals and factory functions, 
> where data is generally literal & inline and therefore likely represents 
> coder error:
>
> ; all disallowed
> #{:a :a}
> {:a 1 :a 2}
> (hash-map :a 1 :a 2)
> (hash-set :a :a)
>
> They are allowed in other contexts, where the data could come from anywhere:
>
> ; dumb, but these forms not generally called with a literal
> (set [:a :a])
> (into #{} [:a :a])
>
> I find this behavior consistent and easy to explain, but I was involved in 
> the design conversation so maybe I have participant blindness. :-)
>
> Stu
>
>
>
> > On Fri, 25 Jun 2010 15:36:31 +0200
> > Michael Wood  wrote:
>
> >> On 25 June 2010 12:27, Tim Robinson  wrote:
> >>> I tried Clojure via Githhub today.
>
> >>> Anyone notice this bug that hadn't existed in Version 1.1
>
> >>> user=> #{:item1 {:a "A" :b "B"} :item2 {:a "A" :b "B"}}
> >>> java.lang.IllegalArgumentException: Duplicate key: {:a "A", :b "B"}
>
> >> You're trying to put duplicate values into a set.
>
> > So? Most places, putting a value that's already in a set into the set
> > is a nop. Even in clojure that exhibits the above behavior:
>
> > user=> #{:a :a}
> > java.lang.IllegalArgumentException: Duplicate key: :a
> > user=> (set [:a :a])
> > #{:a}
> > user=> (conj #{:a} :a)
> > #{:a}
> > user=>
>
> > Apparently, duplicate keys in sets are only disallowed in set
> > literals. Arguably, that must be a mistake on the users part, but
> > it sure seems to clash with the behavior of sets elsewhere.
>
> >      > --
> > Mike Meyer               
> > http://www.mired.org/consulting.html
> > Independent Network/Unix/Perforce consultant, email for more information.
>
> > O< ascii ribbon campaign - stop html mail -www.asciiribbon.org
>
> > --
> > 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
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: How does contains? work?

2010-06-27 Thread ru
Thank you very much to all for comprehensive explanations.
As newcomer to Clojure dare to remark that this is not very consistent
semantics of "contains" :)

On 25 июн, 21:25, ataggart  wrote:
> My sense from reading Rich's writing on the subject is that 'contains?
> was named with the use of sets in mind.  There is also a pairing logic
> involved whereby if 'contains? returns true, the the value returned by
> 'get is valid (this covers cases in maps where the value actually is
> nil).
>
> As Meikel indicated, this is a well-worn path of discussion and isn't
> going to change.
>
> On Jun 25, 5:15 am, Peter Schuller 
> wrote:
>
>
>
> > > Explain me this, please:
>
> > > user=> (def x (cons 'a nil))
> > > #'user/x
> > > user=> x
> > > (a)
> > > user=> (contains? x 'a)
> > > false
> > > user=>
>
> > contains? checks whether the collection contains the *key*, not the
> > value. So for example the list [:a :b] contains keys 0 and 1, but not
> > 2 or :a:
>
> > user=> (contains? [:a :b] 0)
> > true
> > user=> (contains? [:a :b] 1)
> > true
> > user=> (contains? [:a :b] 2)
> > false
> > user=> (contains? [:a :b] :a)
> > false
>
> > That said, it was not obvious from (doc contains?) to me what the
> > semantics were for operating on lists. Checking PersistentList, it
> > seems contains() always returns false - which makes sense if you
> > consider that lists are not functions of indexes (while vectors and
> > java arrays are).
>
> > --
> > / Peter Schuller

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Enhanced primitive support - redux

2010-06-27 Thread Daniel
Thirded.

On Jun 25, 4:55 pm, Mark Engelberg  wrote:
> On Fri, Jun 25, 2010 at 2:39 PM, Garth Sheldon-Coulson  wrote:
> > Personally, I think (= 3 3M) => true and (= 3/10 0.3M) => true would be nice
> > to have, given that (= 3 3N) => true. Both are currently false in equiv. I
> > also think (= 3.0M 3.00M) => true would be nice. As Rich said, there's no
> > particular reason to have Clojure = work exactly like Java .equals(). I
> > think all it would take is a call to .stripTrailingZeros() on each =
> > comparison of a BigDecimal.
>
> Yeah, if it's technically feasible, this definitely makes the most
> mathematical sense.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Duplicate key bug in hash-maps

2010-06-27 Thread Tim Robinson
Can I change the title to:

"Duplicate key error handling feature in hash-sets" ?

I was using the '#'  thinking it was short for a hash-map, rather than
a hash-set.

Clojure has more data structures available than I'm used to working
with.
So thanks for the error handling.

Tim


On Jun 25, 9:37 am, Stuart Halloway  wrote:
> I think there are two important considerations in favor of how it works now:
>
> (1) The "common case" presumptions (which admittedly may need to be learned).
>
> (2) The need for both flavors. If there wasn't a flavor that rejected 
> duplicate keys, somebody would surely ask for it.
>
> Add to these considerations the names of the functions already in play, and 
> you get the implementation you see.
>
>
>
> > On Fri, 25 Jun 2010 10:31:57 -0400
> > Stuart Halloway  wrote:
>
> >> Duplicate keys in maps/sets are disallowed in literals and factory 
> >> functions, where data is generally literal & inline and therefore likely 
> >> represents coder error:
>
> >> ; all disallowed
> >> #{:a :a}
> >> {:a 1 :a 2}
> >> (hash-map :a 1 :a 2)
> >> (hash-set :a :a)
>
> > Maps I can see being an error - you lose data in the process.
>
> > However, since you can plug variables of unknown provenance into
> > either the constructor or the literal, that's liable to create a nasty
> > surprise for someone at some point.
>
> > user=> (def a :a)
> > #'user/b
> > user=> (def b :a)
> > #'user/b
> > user=> (hash-set a b)
> > java.lang.IllegalArgumentException: Duplicate key: :a (NO_SOURCE_FILE:6)
> > user=> #{a b}
> > java.lang.IllegalArgumentException: Duplicate key: :a (NO_SOURCE_FILE:0)
> > user=>
>
> >> They are allowed in other contexts, where the data could come from 
> >> anywhere:
>
> > It could come from anywhere in the two "forbidden" contexts as well.
>
> >> ; dumb, but these forms not generally called with a literal
> >> (set [:a :a])
> >> (into #{} [:a :a])
>
> >> I find this behavior consistent and easy to explain, but I was involved in 
> >> the design conversation so maybe I have participant blindness. :-)
>
> > My initial reaction was "that's a bit odd, but probably a good idea."
> > However, given that I can use variables inside the literal and
> > constructor, I'm leaning the other way.
>
> > Or is (set [a b c]) idiomatic usage in this case, and (hash-set a b c)
> > or #{a b c} to be avoided?
>
> >    > --
> > Mike Meyer               
> > http://www.mired.org/consulting.html
> > Independent Network/Unix/Perforce consultant, email for more information.
>
> > O< ascii ribbon campaign - stop html mail -www.asciiribbon.org

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Dynamic gen-class

2010-06-27 Thread Michael Jaaka
Hi,

Is there any way to generate class in runtime and then use it?
How far I can only generate interfaces.

This works:

(do
(gen-interface  :name test.commons.Me
:methods [[ me [ String ] void ]])

(def z (reify test.commons.Me
(me [t z] (println "hello world" z

(.me z "wowo")
)



That doesn't:



(do
(gen-class :name test.commons.Mee
:state sema
:methods [
[ me2 [ String ] void ]]
:prefix "mee-"
)

(defn mee-me2[ this a ]
(println "hello" a "had state" (.sema this)))

(.me2 (test.commons.Mee. ) "world")
)



-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Drawable Sets

2010-06-27 Thread Nicolas Oury
That's a super cool idea, but my data have no similar size. Anyway, that's
both simple and always better than what I do.(At worst it has an expected
complexity of O(n) if all the mass is in one value and the n-1 are
zero-ish).

I think you can solve the holes on delete by permuting the removed element
with the last element and keeping a map from value to their index.

Thanks you very much for these suggestions.

On Sat, Jun 26, 2010 at 10:04 PM, Garth Sheldon-Coulson wrote:

> Well, my idea involves rejection sampling. In order to sample an element
> from the set in a mass-weighted fashion, you can sample an element in a
> uniform fashion and then reject the sample with a certain probability (more
> below). If you do reject the sample, you keep drawing from the uniform
> proposal distribution until you get an acceptance. This can be quite
> efficient if the most massive element in the set is not too much more
> massive than the majority of the other elements. If, however, the elements
> have very different masses, then it can be inefficient. Regardless, my
> intuition is that you can't do better than rejection sampling in this case,
> because the probability distribution from which you're sampling is
> constantly changing and not of any particular functional form.

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Drawable Sets

2010-06-27 Thread Nicolas Oury
That more or less what I had in mind, but I was wondering if someone has
already an Open Sourced
code for HashTries in Clojure.

But I can try your idea with binary tree first. It seems simpler.
Thanks again,

Nicolas

On Sun, Jun 27, 2010 at 5:13 AM, Jules  wrote:

>
> You can use the same idea for hash tries, just maintain the total
> weight in each node and draw with this algorithm.
>

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

RAM for a Ring app

2010-06-27 Thread David Beckwith
Approximately how much RAM is required to deploy a small Ring app on
64-bit Ubuntu?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en