Clojure android activity?

2017-06-23 Thread Mike Meyer
Is there still any activity in the clojure-android space? The 
clojure-android mail list is largely inactive, seems like the developers of 
lein-droid haven't done anything in months (1.7.0-r4 is still used in the 
templates), and the numerous references If ind for an android-clojure web 
site are all dead.

That said, things do seem to mostly work for stock android. But accessing 
API's for android wear seems problematical 
(see https://github.com/clojure-android/lein-droid/issues/162 for my bug 
report).

-- 
You 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Build tool for mixed Clojure/Java projects

2011-07-13 Thread Mike Meyer
On Tue, 12 Jul 2011 22:21:39 -0400
Ken Wesson kwess...@gmail.com wrote:
  Which means it's not really case 4 at all.
 
  Well, it's very clearly not cases 1, 2 or 3.
 
 No, it's case zero: standard multi-developer, multi-computer, single
 canonical master copy on one computer/cluster somewhere. The thing
 cases 1 through 4 were *alternatives* to.

 Technically true, but meaningless. The master gets tens of zillions of
 submissions

Completely and totally wrong.  Linus developed the model used by the
Linux kernel specifically to avoid having some master copy on a
central server with tens of zillions of submissions. He wrote a SCM
that allowed the distributed, ad-hoc model to work without such a
central server. All because his experience with the kernel up to that
point was that he had reached the scalability limits of your case zero
model.

And now you're claiming it's a central server model in order to
justify your erroneous assumption that having a repository implies
having a server? I'm not sure whether that's more funny or pathetic.

   mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: Build tool for mixed Clojure/Java projects

2011-07-12 Thread Mike Meyer
On Mon, 11 Jul 2011 20:49:01 -0400
Ken Wesson kwess...@gmail.com wrote:

 On Mon, Jul 11, 2011 at 7:39 PM, Mike Meyer m...@mired.org wrote:
  On Mon, 11 Jul 2011 07:51:33 -0400
  Ken Wesson kwess...@gmail.com wrote:
 
  On Sun, Jul 10, 2011 at 2:01 AM, mike.w.me...@gmail.com m...@mired.org 
  wrote:
  [snip most of post whose sole purpose seems to be to gainsay anything I 
  write]
 
  Because in that article, you were (unusual for you) way off base.
 
 As you say, it would be unusual for me if that were the case -- good
 reason to suspect that perhaps I wasn't, but rather was
 misinterpreted, or something.

You write clearly enough that misinterpretation isn't likely. You were
simply making false statements.

  SQL doesn't have a position anything like HTTP GET/POST syntax.
 
 Sure it does. Queries are bundled into a wire protocol and sent over
 the network in pretty much every system I've seen that used a
 database. You have the web server over *here*, and it is visible to
 the internet because the gateway forwards port 80 to it *here*; it
 talks over the LAN to the DBMS over *here* to run various queries and
 build a page to serve ...
 
  HTTP's GET/POST syntax is a wire protocol.
 
 HTTP is a wire protocol. The syntax of GET/POST requests is carried on
 that protocol (as are HTML files and other files sent back to the
 client) but is not the protocol itself.
 
  Once you it, you can write code to talk to a server, and get a
  response.
 
 Not if all you know is GET /index.html. You need to speak HTTP and
 then send that.

If all you know is GET /index.html, then you don't know the syntax
of the HTTP GET statement. The terminator - a pair of line endings -
is part of the syntax. If you send that string and the terminator to
an HTTP server, it should send back the contents of index.html.

  If you know SQL, you can't use a database *at all*. You have
  to know an API for the database in question
 Just as you need to know HTTP and not just GET /index.html. The
 difference here is that the databases haven't all settled on one
 embedding, analogous to HTTP, for the SQL requests, but all the
 vendors use their own different one.

Sorry, but GET /index.html *is* HTTP. Oh, it's not all of it, by any
means - but it's enough to talk to a server.  A much closer analogy
would be that SQL is like the URL syntax in the HTTP GET/POST
request. Knowing the URL isn't enough to talk to a web server. You
have to know the wire protocol, or the API for a library that
implements it for you.

  Last time I looked, there wasn't a standard wire protocol
  for SQL servers.
 Which doesn't change much of anything. There's HTTP 1.0 and HTTP 1.1
 for web servers for that matter, though mostly you can ignore the
 differences and, indeed, these days HTTP 1.0 as a whole. It's not hard
 to imagine a world where a non-HTTP protocol became a rival to HTTP,
 either -- for instance, one with built-in support for mirroring of
 static content instead of having to fudge around with things like
 Akamai for that, perhaps even one where individual browsers made parts
 of their caches (not https stuff, though, obviously, or form contents)
 available automatically as alternative sources to take some of the
 load off central servers and possibly even maintain some availability
 when they were down. If that were to happen, would the things that
 interpret GET requests suddenly stop qualifying for being considered
 to be servers?

Only if they also stopped listening for requests on something like a
socket. Which was your objection to running a repository: you think it
means you have to have something listening on a socket. This isn't the
case. In particular, it isn't the case for the maven repository that
was being recommended as a solution to the problem.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: Build tool for mixed Clojure/Java projects

2011-07-12 Thread Mike Meyer
On Mon, 11 Jul 2011 21:12:20 -0400
Ken Wesson kwess...@gmail.com wrote:

 On Mon, Jul 11, 2011 at 7:51 PM, Mike Meyer m...@mired.org wrote:
  On Mon, 11 Jul 2011 16:21:45 -0400
  Ken Wesson kwess...@gmail.com wrote:
   So, repository does not imply server at all,
  This is getting silly. Repository is a word that brings immediately
  to mind typing checkin and checkout commands at a command prompt in
  order to work on source code that is stored remotely. And remotely
  implies server.
 
  I was with you until you said stored remotely.
 there's also a server in there, or even multiple servers. The
 alternatives I can think of are:
 
 1. One developer, one computer.
 
 2. Many developers, one computer. No remote storage and if the
 developers are co-located no server; otherwise a terminal server. The
 former is obviously not parallelizable (though edit conflicts are thus
 a non-issue -- single global lock FTW!!!1!1) and the latter is a
 throwback to the 1980s or earlier. :)

Most systems that support such a model - and yes, they're still being
both developed and used - are well enough written to avoid a single
global lock.

 3. Many computers, one developer

 4. An ad hoc, peer-to-peer system with many evolving versions of the
 codebase and patches swapped back and forth

This is the model used by the Linux kernel, among others. You might
argue that one of Linus's repositories is a master copy, as that's
the one that Linux kernel releases are cut from, but that's really the
only thing that distinguishes it from any of the others. Each
developer gets to decide where they want to take patches from and
which patches they're actually going to use in any given build, but
most can't put code in the so-called master repository.

 So, unless 4 can be made workable, 

I'd say a project with 14 million LOC and thousands of developers
using it for five years demonstrates that it's both workable and
scalable.

  mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: Build tool for mixed Clojure/Java projects

2011-07-12 Thread Mike Meyer
On Tue, 12 Jul 2011 18:13:57 -0400
Ken Wesson kwess...@gmail.com wrote:

 On Tue, Jul 12, 2011 at 2:31 PM, Mike Meyer m...@mired.org wrote:
  You write clearly enough that misinterpretation isn't likely. You were
  simply making false statements.
 
 I do not do that, and I won't tolerate being called names and
 badmouthed in public. This discussion is over.

I'm sorry, I didn't mean to imply that you were lying.  I'm sure you
thought the statements were true. You were just wrong in this case.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: Build tool for mixed Clojure/Java projects

2011-07-12 Thread Mike Meyer
On Tue, 12 Jul 2011 18:20:38 -0400
Ken Wesson kwess...@gmail.com wrote:

 On Tue, Jul 12, 2011 at 3:11 PM, Mike Meyer m...@mired.org wrote:
  On Mon, 11 Jul 2011 21:12:20 -0400
  Ken Wesson kwess...@gmail.com wrote:
  2. Many developers, one computer. No remote storage and if the
  developers are co-located no server; otherwise a terminal server. The
  former is obviously not parallelizable (though edit conflicts are thus
  a non-issue -- single global lock FTW!!!1!1) and the latter is a
  throwback to the 1980s or earlier. :)
 
  Most systems that support such a model - and yes, they're still being
  both developed and used - are well enough written to avoid a single
  global lock.
 
 Another misunderstanding. Many developers working at one physical,
 co-located computer has the keyboard and monitor as a single global
 lock. In the terminal server case there could be a finer locking
 granularity. As for still developed and used, what for? 

What makes you think a computer can have only a single
keyboard/monitor? After all, what is a terminal server but a computer
with lots of keyboard/monitors that routes the terminals out to
network servers of some kind? But this is all irrelevant - from the
point of view of an application, it doesn't make any difference if
someone is issuing commands from a device directly connected to the
hardware, from a device connected to a terminal server, or sitting at
a second computer and connected back to the single computer where the
work is being done.

Which is why such things are still being developed. There's
fundamentally no difference between many developers running commands
on the single computer to manipulate the data and many developers
running clients that talk to apache running on that single computer
and causing it to issue those commands. This lets a developer leverage
the apache networking code to create a client/server model, and most
modern SCMs can be run that way.

  4. An ad hoc, peer-to-peer system with many evolving versions of the
  codebase and patches swapped back and forth
 
  This is the model used by the Linux kernel, among others. You might
  argue that one of Linus's repositories is a master copy, as that's
  the one that Linux kernel releases are cut from, but that's really the
  only thing that distinguishes it from any of the others. Each
  developer gets to decide where they want to take patches from and
  which patches they're actually going to use in any given build, but
  most can't put code in the so-called master repository.
 
 Which means it's not really case 4 at all.

Well, it's very clearly not cases 1, 2 or 3. There are many developers
and many computers, and case 4 is the only one that allows for
that. So this is either case 4, or you need to provide another case
for it.

  So, unless 4 can be made workable,
 
  I'd say a project with 14 million LOC and thousands of developers
  using it for five years demonstrates that it's both workable and
  scalable.
 Except that it has an official build repository with more stringent
 criteria for what gets in there, so not really.

Half right. As I said, it's got one repository that the official
builds come from. Other people are free use builds from their own
repositories, and often do - I don't think any of the GNU/Linux
distributions actually use binaries built by Linus. Instead, they each
have their own master repository from which they do their official
builds.

However, the criteria for what gets into that so-called master
repository are no more stringent than for any other repository in the
project: only patches the owner wants get in.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Mike Meyer
On Mon, 11 Jul 2011 07:51:33 -0400
Ken Wesson kwess...@gmail.com wrote:

 On Sun, Jul 10, 2011 at 2:01 AM, mike.w.me...@gmail.com m...@mired.org 
 wrote:
 [snip most of post whose sole purpose seems to be to gainsay anything I write]

Because in that article, you were (unusual for you) way off base.

  The only source control system I know that uses an ACID database doesn't
  need a back end server.
 
 How exactly is this possible? Databases *are* servers. Database and
 DBMS are used more-or-less synonymously (when database isn't used
 more broadly than ACID/SQL/etc.) and the S in DBMS stands for
 server. SQL is to databases/clients as HTTP GET/POST syntax is to
 web servers/browsers. Etc.

I explained it in the part you snipped, but I'll repeat it for you: it
uses an embedded database. A database is *not* a server, it's an
API. The API may well talk to a server - and most do - but there's no
requirement that it do so. This particular embedded database is almost
certainly the most popular SQL database in the world, with hundreds of
millions of installations running worldwide.

SQL doesn't have a position anything like HTTP GET/POST syntax. HTTP's
GET/POST syntax is a wire protocol. Once you it, you can write code to
talk to a server, and get a response. If you know SQL, you can't use a
database *at all*. You have to know an API for the database in
question - and if it's a server, have an implementation that talks
it's wire protocol. ODBC provides a standard API, but not a wire
protocol. Last time I looked, there wasn't a standard wire protocol
for SQL servers.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: Build tool for mixed Clojure/Java projects

2011-07-11 Thread Mike Meyer
On Mon, 11 Jul 2011 16:21:45 -0400
Ken Wesson kwess...@gmail.com wrote:
  So, repository does not imply server at all,
 This is getting silly. Repository is a word that brings immediately
 to mind typing checkin and checkout commands at a command prompt in
 order to work on source code that is stored remotely. And remotely
 implies server.

I was with you until you said stored remotely. These days, I almost
*never* do checkins or checkouts to a remote server - and I use four
different source control systems on a regular basis: (hg, git, fossil
 perforce). The first three *cannot* do remote checkins or checkouts
- they require the repository be stored on the local disk. The last
one is the only one that behaves the way you describe - and it's a
legacy system I'm trying to get rid of.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: Learning Idiomatic Clojure

2011-05-12 Thread Mike Meyer
On Wed, 11 May 2011 19:10:13 -0700 (PDT)
J.R. Garcia mrjohngar...@gmail.com wrote:

 I'm wondering what resources would be best to learn how Clojurians
 write their code.
 
 I've been developing for about 4 years in several object-oriented
 languages (mostly C# and Ruby). I understand Clojure's syntax well and
 I'm familiar with a lot of the features of Clojure (although I'm sure
 several of you would prove me wrong). One problem I keep running into
 is how to attack a problem the Clojure way. I often find myself
 writing Clojure like I would write C# code with LINQ, only in
 Clojure's syntax.

As others have said, this sounds like you need a book on
functional/LISP programming. There are some excellent books for other
LISP dialects. Structure and Interpretation of Computer Programs
(aka SICP) would be my recommendations, but Practical Common Lisp
and On LISP are both excellent. I don't know of a book at that
quality level using Clojure. There is an effort underway to translate
SICP to clojure at http://sicpinclojure.com/.

 I'm not interested in Java interop or Clojure on the web or Clojure's
 syntax. I've had no problem finding answers for those things on the
 Internet. I'm really more interested in stuff like
 http://www.bestinclass.dk/index.clj/2010/10/taking-uncle-bob-to-school.html,
 but covering a wider range of things rather than a small example. I'm
 interested in any resource whether it's a book, a video, a blog, a
 person, etc.

This, no the other hands, is a little bit contradictory. The example
about syntax and white space than writing code the Clojure way,
though you explicitly say that's not what you're interested in. Seems
like you're asking for a community style guide. Again, I don't know
that such exists. If it does, Google didn't find it, thought it sounds
like a good idea if someone wanted to write one - maybe starting with
a LISP or Scheme style guide (there are lots of those to choose
from).

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: Learning Idiomatic Clojure

2011-05-12 Thread Mike Meyer
On Thu, 12 May 2011 07:45:50 -0700 (PDT)
Adam Burry abu...@gmail.com wrote:
 On May 12, 11:54 am, Mike Meyer m...@mired.org wrote:
  As others have said, this sounds like you need a book on
  functional/LISP programming. There are some excellent books for other
  LISP dialects. Structure and Interpretation of Computer Programs
  (aka SICP) would be my recommendations, but Practical Common Lisp
  and On LISP are both excellent. I don't know of a book at that
  quality level using Clojure. There is an effort underway to translate
  SICP to clojure athttp://sicpinclojure.com/.
 
 Obviously, these are excellent texts, but I wonder if a Haskel book
 might be better place to look. The problem is I have not looked at any
 Haskel books, but I expect it would be a better place to read about
 the joys of laziness.

SICP and On LISP both deal with lazy data structures, but as a special
case. While clojure has the same data structures, their libraries
don't seem to try and conserve it the way that Clojure libraries do,
so those are probably inadequate for people doing clojure. I think
Haskell might take you to far the other way, since everything is lazy,
which changes things radically.

The best I know of here would be Concepts, Techniques, and Models of
Computer Programming, but that takes you well away from Clojure's
mostly-functional paradigm.

I suspect that dealing properly with Clojure's laziness is a topic for
a clojure-specific book.

  mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: Reading clojure code of larger domain specific projects

2011-05-09 Thread Mike Meyer
On Mon, 9 May 2011 03:24:44 -0700 (PDT)
Chris Perkins chrisperkin...@gmail.com wrote:
 I have been thinking for while that it would be great to have
 something equivalent to book clubs for reading code. A group could
 meet weekly, all having read the same moderate-sized project, and
 discuss. I wonder if this could be made to work as a web-app, where
 you can sign up, state your areas of interest, and have a weekly
 reading assignment emailed. Then you could meet on IRC or something.
 Just a thought.

I've been thinking about a similar thing. Lists for beginners at a
language include frequent requests to evaluate my code.  I've been
wondering if there would be any interest in a forum where you could
post a bit of code and let others comment on it. It'd need some way of
picking a language (specific forums? A tag on the post?).

One thing that happens to such posts is they turn into threads of
best way to solve this problem - where best varies by author.
Similarly, programming problem set sites are popular. So maybe an
option for How would I do this might be useful.

   mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: What is the purpose of the Identity function?

2011-05-07 Thread Mike Meyer
On Sat, 7 May 2011 12:09:45 -0700
Sean Corfield seancorfi...@gmail.com wrote:
 Identity on its own isn't really useful - but in combination with
 higher-order functions, it can be very indispensible!

Bingo. An HOF accepts a function that filters/mogrifies data before
processing it in some way. Sometimes, you *don't* want to have that
extra step. There are two ways to do that: one is to have two variants
of the HOF - one which uses the function, and one which doesn't (which
may mean it's not an HOF). The other is identity.

Clojure does both, depending. You can see the first in sort and
sort-by, where sort-by uses a keyfn to extract keys from items in the
collection. You could just identity for the keyfn to sort by items,
but this case is so common it gets it's own function -
sort. Similarly, filter takes a predicate to check which items need to
be removed. If you just want to remove false values, the appropriate
predicate is identity. This case isn't very common, so there's no
second version.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/
Independent Software developer/SCM 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: dead simple compile to jar file

2011-04-28 Thread Mike Meyer
On Wed, 27 Apr 2011 10:45:58 -0700 (PDT)
cej38 junkerme...@gmail.com wrote:

 Hi,
   I would like the simplest method to compile a few lines of clojure
 code into a jar file that I can distribute to some fellow scientists
 that don't know much (if anything) about java or clojure.  Since I am
 not creating a huge product that I will be updating often, maven and
 Lenningen seem like overkill.  The compiled jar file should contain
 the relevant clojure and clojure.contrib stuff within it, so that the
 other users don't have to worry about downloading clojure/contrib.
 
 Also, I would rather not unpack jar files from libraries that I used,
 if possible.
 
 Clojure's compile function is tantalizing, but then everyone would
 need to have the same versions of the libraries that I used, not just
 clojure and contrib.

This is one of the holes in the Clojure/Java infrastructure - things
that should be simple aren't. So there isn't anything simpler than a
project except the bare file manipulation commands.

To use those commands, you need to compile all your clojure files to
class files (via the clojure compile command), then use the jar
command to create the uberjar (still a .jar) file that contains all
the relevant .class files, and also the contents of the .jar files
that your program depends on.

Unlike most compiled languages, there isn't a driver program
available that will take a list of files on the command line and
compile them, then put the results together to what you want. Instead,
you have to rely on project manipulation tools like ant, lein or maven
to take a file describing the project and do all that for you.

While I agree with you that things like lein are overkill for this
kind of thing, they're still probably the simplest solution you're
going to find. It's probably easier to figure out how to use lein to
build your uberjar than to figure out how to get jar to create the
same thing.

Sadly, I don't see this situation changing. Java people seem to think
this is normal, and suggest that Clojure isn't the right language
(what they mean is that Java isn't the right environment) when it gets
pointed out. So even if someone wrote a jc command that knew how to
compile Java, Clojure, Scala, Groovy, JRuby, Jython, etc. and which
jar files to add for each of them, I suspect it wouldn't get any mind
share in those communities because there isn't a lot of interest in
tools to make simple things simple.

  mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Start Clojure programs from Eclipse

2011-04-24 Thread Mike Meyer
On Sun, 24 Apr 2011 01:07:45 -0400
Ken Wesson kwess...@gmail.com wrote:
 On Sun, Apr 24, 2011 at 12:01 AM, Mike Meyer m...@mired.org wrote:
  On Sat, 23 Apr 2011 23:42:23 -0400
  Ken Wesson kwess...@gmail.com wrote:
 
  On Sat, Apr 23, 2011 at 11:35 PM, Mike Meyer m...@mired.org wrote:
   On Sat, 23 Apr 2011 23:19:53 -0400
   Ken Wesson kwess...@gmail.com wrote:
  
   On Sat, Apr 23, 2011 at 8:13 PM, Mike Meyer m...@mired.org wrote:
On Sat, 23 Apr 2011 19:41:28 -0400
Ken Wesson kwess...@gmail.com wrote:
or you live in a universe where cosmic rays can flip bits and other
sources of hardware hiccups exist.
   Software crashes caused by non-software-bug-triggered memory
   corruption seem to me to be exceedingly rare, and they could as easily
   strike critical parts of the operating system as a multithreaded
   server program (and a large batch of independent C jobs will occupy
   more memory and have a correspondingly larger cross section as a
   target for such things).
   The best recourse if the server gets hit by something like that is
   going to be to reboot it.
  
   While it might be exceedingly rare on a per-cpu-second basis, if your
   application runs 7x24 on enough cpus, you can expect to see them at
   regular intervals. In which case the best recourse - if you want a
   stable, robust application - is to restart the smallest set of
   processes that might have been affected by the problem.
  In other words, all of them, since the operating system might have
  been affected by such a problem and if it was, everything else is
  probably affected too.
  Let me guess - you're one of these people who
 Ah, I get it. You're arguing because you have some kind of *personal*
 issue, rather than for any logical reason.

Yup. Years of practical experience building and running such
systems. Logic and theory seldom survive contact with practice
unscathed.

  Sure, a hardware glitch that affects the OS means you should reboot
  the system.
 And assuming you can even detect that such a glitch has occurred at
 all (what if one hits the code doing the detecting, or the memory that
 it uses -- or the operating system, in a way that affects that code?)
 can you detect whether or not it hit the operating system?

If your hardware doesn't take a parity fault or correct the data most
of time it tries to read such data, you need better hardware. Anything
that needs the data that's corrupt needs to be killed - which means
that user process if the data is in user space. The kernel will be
fine, because it can't have used the bad data without triggering the
fault.

  Of course, if it affects some user process, it may have
  affected the OS without leaving evidence of doing so. Then again, it
  may not have. While you could reboot everything just in case, you
  could also have a hardware glitch affect the OS without leaving
  evidence in any process, so you might as well reboot even though
  nothing is wrong just in case.
 Obviously there's little point in rebooting absent *some* evidence
 that something is wrong.

Exactly. If the kernel isn't complaining about something, that's
exactly what you have - absence of evidence that something is wrong
with the kernel. Some user process failing for an unknown reason
doesn't provide any evidence that something is wrong with the kernel.

 Of course, some process segfaulting doesn't mean much if it's a
 typical C program. On the other hand, if you have a rock-solid JVM
 and kernel and various JVM bytecodes running, and the JVM faults,
 the likelihood of a problem like this is higher than if a random
 other program faulted -- indeed, either it's a JVM bug, an OS bug,
 or a glitch of the type being discussed, since arbitrary bytecode on
 a bug-free JVM shouldn't cause the JVM to fault. (Native methods
 complicate things somewhat though.)

Since neither the JVM bug nor the OS bug get fixed by restarting the
system, and the process that has glitched will most likely be fixed
equally well by restarting it as by rebooting the system, there's no
evidence to indicate a problem that would be helped in any way by
rebooting the system.

  Nah, hardware glitches are either localized, in which case restarting
  just the address spaces that failed is sufficient (and has proven so
  in practice for years), or they're systemic, in which case you'll have
  failures throughout the system. It's pretty easy to tell the
  difference between the two and deal with them appropriately.
 Easy for who? The system administrator? I thought we were considering
 automated means of recovering faulting systems here.

Easy for automated systems to deal with. Foo is failing repeatedly,
quit restarting it and escalate the issue and Multiple failures on
foo, create an escalated issue are both standard behaviors for
application monitoring tools.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM consultant, email for more

Re: Start Clojure programs from Eclipse

2011-04-23 Thread Mike Meyer
On Sat, 23 Apr 2011 19:41:28 -0400
Ken Wesson kwess...@gmail.com wrote:
  Well, Java servers probably are yes, but traditional Unix servers
  would normally fork a new process for each incoming connection.
 
 Poor man's threads. Although the insulation of each one against
 crashes in the others might be useful when you're coding in a language
 with memory management tools as primitive as C's. ;)

Or your tools for handling concurrency are as poor as C's (which is
unfortunately most popular languages), or you live in a universe where
cosmic rays can flip bits and other sources of hardware hiccups exist.

  starting a pool of processes to avoid the startup time of a new process
  when a new client connects.
 
 With small lightweight C processes and some suitable system for IPC,
 this can work. With JVMs, not so much, unless you have RAM coming out
 of your ears. JVM processes tend to be fairly large; it wouldn't take
 many 64MB java.exe jobs to start the pagefile thrashing. Even with an
 8GB server, you start paging at 128 simultaneous connections in that
 case, and you certainly can't handle thousands.

I would have expected large chunks of the JVM processes to be shared
between parent and child - especially before the first accept
returns. In particular, the VM implementation and the compiled JVM
bytecodes should all be shared. Data structures  JIT'ed code - well,
it will depend on a variety of implementation details, but they all
start on shared pages with a COW bit set.

Of course, if you're using threads in the parent for other things,
then forking to create new processes creates a bunch of interesting
things to deal with.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Start Clojure programs from Eclipse

2011-04-23 Thread Mike Meyer
On Sat, 23 Apr 2011 23:19:53 -0400
Ken Wesson kwess...@gmail.com wrote:

 On Sat, Apr 23, 2011 at 8:13 PM, Mike Meyer m...@mired.org wrote:
  On Sat, 23 Apr 2011 19:41:28 -0400
  Ken Wesson kwess...@gmail.com wrote:
  or you live in a universe where cosmic rays can flip bits and other
  sources of hardware hiccups exist.
 Software crashes caused by non-software-bug-triggered memory
 corruption seem to me to be exceedingly rare, and they could as easily
 strike critical parts of the operating system as a multithreaded
 server program (and a large batch of independent C jobs will occupy
 more memory and have a correspondingly larger cross section as a
 target for such things).
 The best recourse if the server gets hit by something like that is
 going to be to reboot it.

While it might be exceedingly rare on a per-cpu-second basis, if your
application runs 7x24 on enough cpus, you can expect to see them at
regular intervals. In which case the best recourse - if you want a
stable, robust application - is to restart the smallest set of
processes that might have been affected by the problem. In some cases,
that is the server. In others, it's a single process. In still others,
it's the set of servers participating in a distributed application.

   starting a pool of processes to avoid the startup time of a new process
   when a new client connects.
 
  With small lightweight C processes and some suitable system for IPC,
  this can work. With JVMs, not so much, unless you have RAM coming out
  of your ears. JVM processes tend to be fairly large; it wouldn't take
  many 64MB java.exe jobs to start the pagefile thrashing. Even with an
  8GB server, you start paging at 128 simultaneous connections in that
  case, and you certainly can't handle thousands.
 
  I would have expected large chunks of the JVM processes to be shared
  between parent and child - especially before the first accept
  returns.
 
 That happens forking C programs. It won't happen starting up separate,
 independent JVM processes, and I don't know how a JVM will handle it
 if a native method calls fork() but I somehow doubt it will all just
 work peachily.

Ah, good point. I don't think in Java, so forget that it doesn't
necessarily have access to all the facilities of the underlying OS.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Start Clojure programs from Eclipse

2011-04-23 Thread Mike Meyer
On Sat, 23 Apr 2011 23:42:23 -0400
Ken Wesson kwess...@gmail.com wrote:

 On Sat, Apr 23, 2011 at 11:35 PM, Mike Meyer m...@mired.org wrote:
  On Sat, 23 Apr 2011 23:19:53 -0400
  Ken Wesson kwess...@gmail.com wrote:
 
  On Sat, Apr 23, 2011 at 8:13 PM, Mike Meyer m...@mired.org wrote:
   On Sat, 23 Apr 2011 19:41:28 -0400
   Ken Wesson kwess...@gmail.com wrote:
   or you live in a universe where cosmic rays can flip bits and other
   sources of hardware hiccups exist.
  Software crashes caused by non-software-bug-triggered memory
  corruption seem to me to be exceedingly rare, and they could as easily
  strike critical parts of the operating system as a multithreaded
  server program (and a large batch of independent C jobs will occupy
  more memory and have a correspondingly larger cross section as a
  target for such things).
  The best recourse if the server gets hit by something like that is
  going to be to reboot it.
 
  While it might be exceedingly rare on a per-cpu-second basis, if your
  application runs 7x24 on enough cpus, you can expect to see them at
  regular intervals. In which case the best recourse - if you want a
  stable, robust application - is to restart the smallest set of
  processes that might have been affected by the problem.
 
 In other words, all of them, since the operating system might have
 been affected by such a problem and if it was, everything else is
 probably affected too.

Let me guess - you're one of these people who reboots systems every
couple of days just in case?

Sure, a hardware glitch that affects the OS means you should reboot
the system. Of course, if it affects some user process, it may have
affected the OS without leaving evidence of doing so. Then again, it
may not have. While you could reboot everything just in case, you
could also have a hardware glitch affect the OS without leaving
evidence in any process, so you might as well reboot even though
nothing is wrong just in case.

Nah, hardware glitches are either localized, in which case restarting
just the address spaces that failed is sufficient (and has proven so
in practice for years), or they're systemic, in which case you'll have
failures throughout the system. It's pretty easy to tell the
difference between the two and deal with them appropriately.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Shebang support for cljr

2011-04-20 Thread Mike Meyer
On Wed, 20 Apr 2011 10:16:05 -0700 (PDT)
David Jacobs develo...@allthingsprogress.com wrote:

 What's the status on this? One of the reasons I don't use Clojure everyday, 
 much as I like it, is that I want it to integrate seamlessly with Unix for 
 scripting.

Um, I've been using it with shebang scripts for a while now. You've
got to do the usual interpreted interpreter double-script dance,
though:

1) Write a shell script that launches java running the clojure main
with all your favorite libraries somewhere on CLASSPATH.

2) Start your scripts with #!/usr/bin/env scriptname where
scriptname is the clojure script you wrote in step 1.

Performance pretty much sucks - starting the jvm is just slow. You can
solve that with nailgun (or something similar), which will let you use
the nailgun binary as the interpreter (i.e. #!/usr/bin/env/clojure
where clojure is a copy/symlink to the nailgun binary), but you have
to remember to start the nailgun server.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Shebang support for cljr

2011-04-20 Thread Mike Meyer
On Thu, 21 Apr 2011 01:30:25 +0800
Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com wrote:
 On Thu, Apr 21, 2011 at 1:28 AM, Mike Meyer m...@mired.org wrote:
  Performance pretty much sucks - starting the jvm is just slow. You can
  solve that with nailgun (or something similar), which will let you use
  the nailgun binary as the interpreter (i.e. #!/usr/bin/env/clojure
  where clojure is a copy/symlink to the nailgun binary), but you have
  to remember to start the nailgun server.
 
 Jark uses a persistent JVM so it's very nice to use for this task.

Yup - it uses nailgun (though apparently nrepl is also available).
Seems like it improves nailgun for clojure users, but hides features
that would be useful if you're using other JVM-based languages with it
- which is why it requires the double-script dance even though nailgun
doesn't.

You still have to remember to start the thing. Which surprises
me. Seems like there should be an option to these things to let the
client start the server if it's not running.

   mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: help--reading keyboard input from Clojure is surprisingly difficult

2011-04-09 Thread Mike Meyer
On Sat, 9 Apr 2011 19:27:13 -0400
Lee Spector lspec...@hampshire.edu wrote:
 On Apr 9, 2011, at 6:18 PM, Sean Corfield wrote:
  On Sat, Apr 9, 2011 at 6:46 AM, Lee Spector lspec...@hampshire.edu wrote:
  But still, I will humbly submit that it's totally freakin' nutso that it 
  should be so hard to do basic user interaction.
  I'm curious as to what percentage of developers are writing
  console-based applications (in any language)?
 I don't know -- probably quite low -- but I would predict that the
 percentage of students learning Lisp-like languages who would be
 writing console-based interactive programs is quite high.

I wouldn't expect it to be quite low, but I build them regularly,
and so do most of the people I work with. On unix systems, the
predominate way to plug to programs together is still via the standard
IO pipes, which the programs - even if normally invoked from some
visual tool - can be used from the command line. And many of us work
develop on one system, then deploy on something else via SSH, so being
able to deal with things on the command line - even if it also
provides some kind of GUI - is a useful feature.

Admittedly, JVM languages don't lend themselves to such things, what
with having to either start it on every command or have some kind of
server running to avoid that.

 Code for doing this sort of thing in Common Lisp or Scheme looks
 almost identical to the simple Clojure code we've seen on this
 thread, with the most significant difference being that the Clojure
 version apparently doesn't work if you launch your REPL and run your
 code in some of the commonly recommended ways.

This sounds more like an issue with those commonly recommended ways
than with clojure or it's REPL, since it works fine running from a
shell.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: What the hell is going on with the Clojure cheat sheet?

2011-04-05 Thread Mike Meyer
On Tue, 5 Apr 2011 10:00:28 -0400
Ken Wesson kwess...@gmail.com wrote:
 And why would it come up as a page full of ads (mostly pretty scammy
 looking ads, like fake Windows messageboxes and such) instead of a
 Host Unknown error?!

Because the registrar for clojure.org chose to resolve lapsed domain
names to a page that it thinks could make it some money instead of
failing. If you look closely (assuming you can still get the page),
you're liable to find a buy this domain link somewhere on it.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Clojure Code Highlighting in Presentations

2011-04-03 Thread Mike Meyer
On Sun, 3 Apr 2011 18:15:43 +0200
Heinz N. Gies he...@licenser.net wrote:

 Hi everyone,
 not a clojure technical question but it has to do with the entire topic :). I 
 know there have been some presentations about clojure already and would like 
 to ask for some best practice experience regarding embedding Clojure code in 
 a presentation. Any advice? What tools did you people use for coloring the 
 code in slides?
 
 I'd be very thankful for some hints and pointers in the right direction so I 
 don't have to reinvebt the wheel :).

I use enscript for highlighting source code - it can generate pretty
nearly anything you'd ever want. I've got a state file for clojure
you'll need if you want to highlight clojure code.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Pointer errors?

2011-04-02 Thread Mike Meyer
On Thu, 31 Mar 2011 16:51:20 -0400
Stuart Halloway stuart.hallo...@gmail.com wrote:

  This is just *strange*. I'm working on converting a servlet that has
  hardwired vectors of values to read those values from a
  database. Given that this is simple, I'm using clojure.contrib.sql and
  an sqlite plugin. Those vectors get walked in the init code to create
  the hashmap that drives page rendering and any actions the servlet takes.
  
  The code change plan is:
  1a) Convert vector of vector of strings to vector of hashmaps from 
 keyword to strings.
  1b) Tweak processing function in walk call to use :keys to destructure
 instead of vector destructuring.
  2) Test and commit these changes.
  3) Replace reference to hardwired vectors with call to
with-query-results to read in essentially the same data.
  4) Test and commit these changes.
  
  Ok, I started with a working servlet. I started seeing oddball
  tracebacks after after doing steps 1a  1b - no new libraries
  involved. I can reproducibly but get tracebacks, but some parts of the
  servlet work fine. The tracebacks look like:
  
  java.lang.RuntimeException: java.lang.NullPointerException
 at clojure.lang.LazySeq.sval(LazySeq.java:47)
 at clojure.lang.LazySeq.seq(LazySeq.java:56)
 at clojure.lang.RT.seq(RT.java:450)
 at clojure.core$seq.invoke(core.clj:122)
 at clojure.core$r.invoke(core.clj:793)
 at clojure.core$reverse.invoke(core.clj:806)
 at clj_stacktrace.core$trim_redundant.invoke(core.clj:86)
 at clj_stacktrace.core$parse_cause_exception.invoke(core.clj:104)
 at clj_stacktrace.core$parse_exception.invoke(core.clj:122)
 at ring.middleware.stacktrace$html_ex_view.invoke(stacktrace.clj:25)
 at 
  ring.middleware.stacktrace$html_ex_response.invoke(stacktrace.clj:40)
 at ring.middleware.stacktrace$ex_response.invoke(stacktrace.clj:51)
 at 
  ring.middleware.stacktrace$wrap_stacktrace$fn__1571.invoke(stacktrace.clj:61)
 at 
  ring.util.servlet$make_service_method$fn__1842.invoke(servlet.clj:117)
 at x10.war$_service.invoke(war.clj:19)
 at x10.war.service(Unknown Source)
 at 
  org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
 at 
  org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
 at 
  org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at 
  org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 at 
  org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 at 
  org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
 at 
  org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
 at 
  org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
 at 
  org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at org.mortbay.jetty.Server.handle(Server.java:326)
 at 
  org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 at 
  org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 at 
  org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
 at 
  org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
  
[Speculation elided...]
  Ok, maybe it's a threading/agent issue. That would explain the once
  but never again behavior, if the agent got into the FAILED
  state. Could that corrupt something that might make jetty and/or ring
  fail as above? Except then why do the pages that just render HTML and
  not send work to the agent still work? Grrr.
  
  Anyone got any clue bits (any at all) I can borrow?
 Hi Mike,
 
 It appears that you aren't seeing the actual error (whatever it may be) 
 because of a bug in clj_stacktrace. 

That was enough of a hint to chase the problem down: the agent was
failing, for two reasons. One was a code bug. The other (which caused
it to be erratic) was that it is serializing access to a reusable
resource, and if I left the resource opened in the REPL, the agent
would fail. That's what caused the erratic behavior that was driving
me nuts.

   Thanks,
   mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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

Init timing for ring web servlet running on Jetty?

2011-03-31 Thread Mike Meyer
I finally got back to the web app that needed init'ing before
processing requests, and got that working (not quite as
straightforward as the various mails/docs make it look).

The problem now is that the init runs when the first request comes in
after the app has been started. While this works, it does mean that
first request takes a *long* time to process. Things after that run
pretty much instantly (as the main thread just renders the html), but
that one takes 10s of seconds.

I realize this is probably the wrong place to ask, but Google hasn't
been much help, and I have no idea what forums would be appropriate
for asking about such things (ring? jetty? Some servelet-developers
forum?), so...

Is there some way to convince Jetty (or tomcat, or ...) to run the
init methods of a servlet before the first request comes in? Or maybe
a pointer to the appropriate forum?

 Thanks,
 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Init timing for ring web servlet running on Jetty?

2011-03-31 Thread Mike Meyer
On Thu, 31 Mar 2011 06:55:08 -0400
Allen Johnson akjohnso...@gmail.com wrote:

  Is there some way to convince Jetty (or tomcat, or ...) to run the
  init methods of a servlet before the first request comes in? Or maybe
  a pointer to the appropriate forum?
 
 You can tell a servlet to init on startup with something like this in
 your web.xml:
 
 servlet
   servlet-nametest-servlet/servlet-name
   servlet-classmyapp.servlet/servlet-class
   load-on-startup1/load-on-startup
 /servlet
 
 This tells the container to initialize the servlet before any
 requests. The number is just the ordering in which the servlets are
 initialized.

Cool. Worked like a charm. Thanks.

  mike

-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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


Pointer errors?

2011-03-31 Thread Mike Meyer
 the SQL code. This is why I think the
code is irrelevant.

I'm pretty much at a loss here - got no idea what to try next. The
most relevant thing google turned up was a bug in the version of
leingingen I was using - it sometimes omitted a class file building
uber[jw]ars (except why does the same thing appear to work once and
not the second time?), so I upgraded lein, which didn't help.

Ok, maybe it's a threading/agent issue. That would explain the once
but never again behavior, if the agent got into the FAILED
state. Could that corrupt something that might make jetty and/or ring
fail as above? Except then why do the pages that just render HTML and
not send work to the agent still work? Grrr.

Anyone got any clue bits (any at all) I can borrow?

   Thanks,
   mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Leiningen capabilities (was Re: A newbie's summary - what worked, what didn't)

2011-03-30 Thread Mike Meyer
On Tue, 29 Mar 2011 16:49:48 -0700 (PDT)
Phil Hagelberg p...@hagelb.org wrote:
 On Mar 28, 10:24 pm, Andy Fingerhut andy.finger...@gmail.com wrote:
  And I should have known about this before, but had not used it.  It adds to 
  Leiningen the capability to search, and I'm not sure, but perhaps also add 
  dependencies that were found:
 
  https://github.com/Licenser/lein-search
 The part
 that modifies project.clj to insert new dependencies will probably not
 be merged because 0) abritrary code may be embedded in project.clj, so
 the :dependencies list is not necessarily a data structure you can
 just splice however you feel like and 1) it's basic text editing;
 asking Leiningen to do it for you is hardly more convenient than doing
 it yourself. It could be done in a 3rd-party plugin with caveats that
 it will not always work correctly though.

Being able to type lein add library and have it take care of
everything is a lot more convenient than typing lein search
library, selecting the appropriate stretch of text, copying it to
the clipboard (or not, if you're brave), switching to an editor,
finding the right place to insert it, pasting the clipboard, then
saving the file.

This seems to be a downside to switching from XML to Clojure. Not that
I think that was a bad idea - the upsides far outweigh this.

Maybe project.clj should be automatically merged with a project.xml
when lein runs, where project.xml is created with a for machine
editing only - humans edit project.clj comment at the top. Then tasks
could edit project.xml without running into those problems.

  mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: updating a map value

2011-03-30 Thread Mike Meyer
On Wed, 30 Mar 2011 10:21:41 -0700 (PDT)
Jeff Rose ros...@gmail.com wrote:

 Hola,
   I'm looking for a function that updates a map value by calling a
 function on it.
 
 (def foo {:a 1})
 
 So instead of this:
   (assoc foo :a (inc (:a foo))); = {:a 2}
 
 Something like this:
   (map-fn foo :a inc); = {:a 2}
 
 Does that exist somewhere, or should I be doing this in a different
 way?  If not, shouldn't it be included?

Possibly you want update-in:

(update-in foo [:a] inc); - {:a 2}

I'm not sure why there's not an update that replaces the list of
keys with a single key.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: A newbie's summary - what worked, what didn't

2011-03-28 Thread Mike Meyer
On Sun, 27 Mar 2011 21:30:54 -0700 (PDT)
ultranewb pineapple.l...@yahoo.com wrote:

 But with any other language I've ever used, at most I include a
 library I need in a directive at the top, or I include my own code in
 a similar directive. 

Question: how did you find the library you were going to use? If you
only searched your local system, then yeah, a well-designed
system/language/etc. installed by somebody competent will do that for
you And I agree with you - to the best of my knowledge, Java (and from
what I can tell, pretty much anything based on the JVM) fails at this.

But this also means you're liable to be missing a large chunk of the
tools available for the language. These days, most languages have
contributed code libraries large enough that installing them all is
impractical on most systems. Searching those for things requires
accessing a database of some sort over the network. Installing them
involves downloading the library from some network site and doing
whatever needs to be done to install it.

So, assuming you found a library you really needed that wasn't already
locally installed, how did you deal with that? If you could add a
require library to your source and your language would go find it,
download it and install it, I'd like to know about that language.

If you had to ask someone else to install it for you, then you're
probably right that someone else was paid to deal with these
issues. Having been that person, I'll let you know that you had it
*really* easy if you didn't have to specify what version of a library
you wanted as well as the name.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Jesus, how the heck to do anything?

2011-03-25 Thread Mike Meyer
On Thu, 24 Mar 2011 06:22:49 -0700 (PDT)
Meikel Brandmeyer m...@kotka.de wrote:
 On 24 Mrz., 13:09, Baishampayan Ghose b.gh...@gmail.com wrote:
 IMHO the Java bashing is overrated. Coming from a polyglot-but-non-
 java background, I didn't have much trouble getting things running. Is
 the CLASSPATH really so much different to the PYTHONPATH,
 LD_LIBRARY_PATH or even the plain old PATH itself?

Actually, that would be Java infrastructure bashing. Java-bashing
would be complaining about lack of multiple inheritance, the
protection mechanisms it inherited from C++, the variable declaration
syntax it inherited from C (anyone care to name another language with
a variable declaration syntax baroque (or broke) enough to cause
someone to write a program to translate between it and English?), etc.

There does appear to be one major difference (at least on Unix)
between CLASSPATH and your examples: the default values work for
simple scripts. In the case of PYTHONPATH  LD_LIBRARY_PATH, the
default is unset, and the infrastructure takes care of checking the
obvious places for things.

Maybe that's also true with a good Java install, and the default
clojure install just isn't java-aware enough to put the clojure jar
files in the right place.

  mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Jesus, how the heck to do anything?

2011-03-23 Thread Mike Meyer
On Wed, 23 Mar 2011 00:50:10 -0700 (PDT)
ultranewb pineapple.l...@yahoo.com wrote:

 Short version:  How do I just open an editor, type in some Clojure
 code, save it in a file, and then run it?
 
 Long version:  Okay, I'm very new to Clojure.  But I'm not a Java
 programmer (don't want to be).

I don't think you can get very far in Clojure without having to come
to grips with the Java infrastructure. It ain't Unix.

Anyway, I wrote
http://www.mired.org/writing/a-guide-to-javaless-clojure to help
people get as far as possible without having to deal with the that
infrastructure.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Jesus, how the heck to do anything?

2011-03-23 Thread Mike Meyer
On Wed, 23 Mar 2011 15:55:51 -0700 (PDT)
ultranewb pineapple.l...@yahoo.com wrote:

 On Mar 24, 1:11 am, Mike Meyer m...@mired.org wrote:
   Long version:  Okay, I'm very new to Clojure.  But I'm not a Java
   programmer (don't want to be).
 
  I don't think you can get very far in Clojure without having to come
  to grips with the Java infrastructure. It ain't Unix.
 
 Well, for me I guess it will depend on how much coming to grips I
 have to do.  If it is much more than clicking on some automation tool
 to generate boilerplate (leinengen?), or typing in java -jar blah
 blah at a command prompt, I'm outta here.  I have been offered money
 to program in java in the past.  I turned it down, turning the phrase
 you couldn't pay me to program in java into a reality.  It's fair to
 state that I hate java more than any other language.  I'd rather
 program in COBOL than java.

I tend to agree - and I've written just enough of both to give that
statement some weight. Then again, I used to say that the major
difference between programming in COBOL and digging ditches is that
programming in COBOL pays better.

The thing is, you can deal with the Java infrastructure without having
to write any Java. They use XML files for everything, so you wind up
writing lots of little and not-so-little XML files to use the
infrastructure. The Clojure community is building tools that let you
write S-expressions (as understood by Clojure) instead of those XML
files. They either replace some Java tool, or produce the XML for you.

I'm not sure going from Java to XML is a win. I *am* sure that going
from XML to S-expressions is a win. But that still leaves you with a
lot of infrastructure (when compared to a unix philosophy equivalent)
to deal with to do things that are reasonable tasks for JVM-based
tools.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: How to Sum a Sequence?

2011-03-21 Thread Mike Meyer
On Sun, 20 Mar 2011 08:47:30 -0700 (PDT)
Christian soulbea...@gmail.com wrote:

 Hello Tassilo!
 
 I've tested your code and looked at the Clojure Documentation for
 'for'. Given that, I have written
 
 (reduce +(filter even? (for [fib (fib-seq) :while ( fib 400)]
 fib)))
 
 This gives me the error 'clojure.lang.LazySeq cannot be cast to
 clojure.lang.IFn'.
 
 I think this is because fib-seq is a var, not a function (although I
 was hard-pressed finding out what IFn stood for.) When I omit the ()
 with [fib (fib-seq)...], the program works just as expected.

Since nobody answered the implied question: yes, you're right. The fix
is to just remove the ()'s from fib-seq to reference it directly, like
so:

(reduce + (for [fib fib-seq :while ( fib 400) :when (even? fib)] fib))

Note that I replaced the filter with the for loops :when test. No real
reason, it just feels more natural to use what for offers since you
started with it. Personally, I'd probably use Daniel's
filter/take-while solution.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Transforming map entries

2011-02-22 Thread Mike Meyer
On Tue, 22 Feb 2011 15:36:02 -0800 (PST)
Daniel Bell dchristianb...@gmail.com wrote:

 I can't think of anything core, but
 
 (let [f #(. % toUpperCase)]
   (zipmap (keys skills) (map f (vals skills doesn't seem too bad.

Does clojure guarantee that keys  vals return things in the proper
order for this to work? Since it doesn't guarantee that serializing
the entries of a map will always get the same order, that seems
unlikely.


thanks,
mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Transforming map entries

2011-02-22 Thread Mike Meyer
On Tue, 22 Feb 2011 16:23:00 -0800 (PST)
Alan a...@malloys.org wrote:

 Yes, it is guaranteed, and I'm dubious about your claim about
 serializing. (seq foo) will return the entries in foo in the same
 order always; but (seq (assoc foo 1 2)) may return the entries in a
 completely different order. You can treat (keys x) as if it were
 defined by (map key (seq x)):

References please?

There was a discussion a while back about why maps weren't treated as
sequences, the gist of it being that (seq somemap) wasn't guaranteed
to always return things in the same order, and requiring an explicit
conversion was a reminder of that. Given that, the fact that (keys x)
can be treated the same as (map key (seq x)) isn't sufficient to
guarantee that (keys x) and (vals x) will return things in the proper
order to zipmap them.

Given that it was an email discussion, it could well have been wrong -
or things could have changed since then. But I'd like to see a
reference to that effect, other than the fact that the current
implementation behaves that way.

  Thanks,
  mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Get digits of a number

2011-02-17 Thread Mike Meyer
On Thu, 17 Feb 2011 10:26:05 -0800 (PST)
JMatt jm...@jmatt.org wrote:
 On Feb 16, 10:29 pm, Andreas Kostler
 andreas.koestler.le...@gmail.com wrote:
  Is there an easy and idiomatic way of getting the digits of a number in 
  clojure?
 Here is my attempt at this from a few months ago:

My turn...

(defn to-digits
  Create a seq of digits from a number.
  [i]
  ^{:user/comment For Euler Problems (Specifically 16)}
  (map {\0 0 \1 1 \2 2 \3 3 \4 4 \5 5 \6 6 \7 7 \8 8 \9 9}
   (str  i)))

No assumption about representation here. But my Python background is
showing - Pythons dictionaries are used *everywhere* in the language,
and hence tuned as tightly as possible and thus blasted fast.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Get digits of a number

2011-02-17 Thread Mike Meyer
On Thu, 17 Feb 2011 15:27:47 -0600
Michael Gardner gardne...@gmail.com wrote:

 On Feb 17, 2011, at 1:36 PM, Mike Meyer wrote:
 
  My turn...
  
  (defn to-digits
   Create a seq of digits from a number.
   [i]
   ^{:user/comment For Euler Problems (Specifically 16)}
   (map {\0 0 \1 1 \2 2 \3 3 \4 4 \5 5 \6 6 \7 7 \8 8 \9 9}
(str  i)))
 Why not use Character/digit, as Saul suggested?

Because I'm not a java programmer, so my natural inclination is to use
Clojure tools (like the hashmap) rather than Java tools. Since I
hadn't seen a solutions using the hashamp - but had seen some more
complex variants - I thought this one might be of interest.

   mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: 1st script, last hurtle...

2011-02-16 Thread Mike Meyer
On Feb 16, 2:01 am, Michael Sanders bluelamp...@gmail.com wrote:
 I think I've worked out a better solution (hope this post renders properly):

 (ns topic (require [clojure.string :as s]))

 (defn load-block

 TOPIC database: prints associated blocks to stdout

     ([tag]
     (let [STATE (atom 0)
    rx (re-pattern (str (?i) tag [[:space:]]*(,|$)))]
     (loop [line (read-line)]
     (when line
     (when (and (not=  (s/trim line))
     (not= \t (subs line 0 1)))
     (if (re-find  rx line)
     (reset! STATE 1)
     (reset! STATE 0)))
     (if (= @STATE 1)
     (println line))
     (recur (read-line)))

I think this might be considered a bit more idiomatic to make state a
parameter of the loop rather than a mutable variable. 

([tag]
   (let [rx (re-pattern (str (?i) tag [[:space:]]*,(,|$)))]
  (loop [line (read-line)
 state 0]
 (when line
(let [new-state (or (when (and (not=  (s/trim line))
   (not= \t (subs line 0 1)))
   (if (re-find rx line) 1 0))
 state)]
   (if (= new-state 1)
  (println line))
   (recur (read-line) new-state))
  

   mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Tricky Macro to write.

2011-02-10 Thread Mike Meyer
On Wed, 9 Feb 2011 20:34:56 -0800 (PST)
CuppoJava patrickli_2...@hotmail.com wrote:

 Description: (bind-later bindings  body)  and (do-binding  body)
 (bind-later) is used like a let-form, except that it doesn't
 *immediately* make the bindings available.
 The bindings become available only within (do-binding).
 (do-binding) is always used within a (bind-later).
 
 Here's some sample code showing how it works.
 
 (def a outer a)
 (bind-later (a inner a)
   (println a)-- this prints out outer a still.
   (do-binding
 (println a)))  -- this will print out inner a
 
 Is such a macro possible?

Yes. It's just - as you say - tricky. You need to create a
do-binding macro for each bind-later macro, meaning it should be
part of the macros lexical space. First trick - use
clojure.contrib.macro-utils/macrolet to do that sanely. Then comes the
really tricky part - figuring out the correct unquoting for everything.
But this does it:

(defmacro bind-later [bindings  body]
  `(macrolet [(~'do-binding [ body#]
`(let ~'~bindings
  ~@body#))]
 ~@body))

Oh, one thing - since let requires a vector for binding, your example
has to be written as (bind-later [a inner a]  But that's the
standard clojure idiom for bindings, so you should do it that way
anyway ;-).

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Network/Unix/SCM 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: Problems with lazy-xml

2011-02-10 Thread Mike Meyer
On Thu, 10 Feb 2011 07:22:55 -0800 (PST)
Marko Topolnik marko.topol...@gmail.com wrote:

 I am required to process a huge XML file with 300,000 records. The
 structure is like this:
 
 root
   header
 
   /header
   body
 record.../record
 record.../record
 ... 299,998 more
   /body
 /root
 
 Obviously, it is of key importance not to allocate memory for all the
 records at once.

I don't think it's obvious. Maybe I'm missing something? Like - how
big are the records? If they're less than 1K, that's at most 300 meg
in core - which is large, but not impossible on modern hardware. I've
been handling .5G data structures in core for the last few years (in
Python, anyway). I've run into at least one stupid garbage collector
that insisted on scanning such structures even though they weren't
changing, which pretty much killed performance. Maybe you have a fast
startup requirement, which building the initial data structure would
kill. Maybe something else?

  Thanks,
  mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Network/Unix/SCM 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: Any news on pull requests?

2011-02-10 Thread Mike Meyer
On Thu, 10 Feb 2011 21:57:01 -0800
Sean Corfield seancorfi...@gmail.com wrote:

 Agreement pretty much identical to the Clojure / Oracle CA (with the
 only exception to the process being that they will allow scanned,
 signed CAs to be emailed to the project team).

That exception is the major issue, assuming you don't have issues with
the terms of the CA.

 As noted elsewhere in this thread, written CAs are actually pretty
 common in large, successful open source projects...

A far more interesting statistic would be how many of those large,
successful open source projects had CAs *before* they were large and
successful.

mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Software developer/SCM 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: Any news on pull requests?

2011-02-06 Thread Mike Meyer
On Sat, 5 Feb 2011 20:42:54 -0500
Christopher Petrilli petri...@amber.org wrote:
 On Sat, Feb 5, 2011 at 1:23 PM, Mike Meyer
 mwm-keyword-googlegroups.620...@mired.org wrote:
  On Sat, 5 Feb 2011 00:09:41 -0500
  Christopher Petrilli petri...@amber.org wrote:
  For example, the following projects REQUIRE contributor agreements, in
  writing, signed and either scanned or on paper, prior to accepting any
  patches or commits:
 
  - Free Software Foundation
  - Apache, and everything under it
  - Python
  I'm sorry, I'm going to call foul on this. I've contributed to Python
  without ever signing a CA. And the current developers guide page
  doesn't have anything on it about needing to sign a CA.
 I do not know when you contributed, or whether it was before this
 period, but from

Certainly possible. My largest contributions were docs, which don't
ship with Python and would be excluded.

 http://wiki.python.org/moin/PythonSoftwareFoundationLicenseFaq:
 
  If your code is going to end up in Python or the standard library, the PSF 
  will require you to:
* License your code under an acceptable open source license. These 
  currently include only the Academic Free License and the Apache License 
  2.0, although this list may be expanded in the future. (No, the PSF License 
  is not acceptable; see below)
* Fill out and submit a contributor agreement.
 
 Perhaps they exclude some small amount of code in the form of patches,
 but it certainly applies to libraries, etc. You can find the
 contributor agreement here:
 http://www.python.org/psf/contrib-form.html It's not that different
 than the one for Clojure. Again, I'm not arguing whether it's a good
 thing or not, simply that it's actually not as unheard of as people
 think, nor is it poorly founded in US legal precedent.

I find it odd that they don't mention this on the Developers Guide at
http://www.python.org/dev/ or the developers FAQ at
http://www.python.org/dev/faq/. Possibly this is a reflection of
reality, in that most contributions will be small patches or docs that
don't ship, and they don't enforce it until they want to include a
library. Or maybe this was planned but never actually happened. I know
that it's never been talked about on any of the Python lists I've hung
out on.

  Seriously, the snail-mail requirement is the only one that's really
  objectionable. Most places are quite happy with a scanned image of the
  signed document (i.e. - the Chickasaw nation for my citizenship
  papers).
 Then perhaps someone can offer to Rich to accept the scanned copies
 and deal with them? One of the joys of an open source project is not
 just contributing code, but helping out with the administrative
 overhead of running a project.

Exactly what has to happen to a PDF that was emailed to whoever would
have gotten the snail-mail copy, beyond printing and then treating
like the snail-mail'ed one?

 mike
-- 
Mike Meyer m...@mired.org 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: Any news on pull requests?

2011-02-05 Thread Mike Meyer
On Sat, 5 Feb 2011 00:09:41 -0500
Christopher Petrilli petri...@amber.org wrote:
 For example, the following projects REQUIRE contributor agreements, in
 writing, signed and either scanned or on paper, prior to accepting any
 patches or commits:
 
 - Free Software Foundation
 - Apache, and everything under it
 - Python
 - Perl
 - Django
 - MySQL
 - Node.js
 - Fedora Linux
 - Neo4j
 - Sun (now Oracle)

I'm sorry, I'm going to call foul on this. I've contributed to Python
without ever signing a CA. And the current developers guide page
doesn't have anything on it about needing to sign a CA.

Seriously, the snail-mail requirement is the only one that's really
objectionable. Most places are quite happy with a scanned image of the
signed document (i.e. - the Chickasaw nation for my citizenship
papers).

Without that requirement, I would already have submitted one. With it?
I can submit most fixes/enhancements as patches (my most likely
contribution) via the ticketing system without having to jump through
that hoop. In the unlikely event I write something significant that
someone wants in core or contrib, I'll revisit the issue.

 mike
-- 
Mike Meyer m...@mired.org 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: Any news on pull requests?

2011-02-04 Thread Mike Meyer
On Fri, 4 Feb 2011 18:00:24 -0800
Sean Corfield seancorfi...@gmail.com wrote:

 On Fri, Feb 4, 2011 at 5:24 PM, Eugen Dück eu...@dueck.org wrote:
  Furthermore, I was really surprised to find on 
  http://clojure.org/contributing
  that I have to send a (non-e)mail around the world to be able to
  contribute
 Written acceptance of a contributor's agreement is fairly common on
 large open source projects so that there is legal clearance for
 inclusion of your contribution under the terms of the project license.

I find it funny that it takes more paper to sign up as a clojure
contributor, which apparently has no benefits to me except bragging
rights, than it did to get my Chickasaw Nation citizenship, which has
benefits like scholarships, clothing grants for my school-age
children, school  housing grants, and of course, voting in tribal
elections.

   mike
-- 
Mike Meyer m...@mired.org 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: Any news on pull requests?

2011-02-04 Thread Mike Meyer
On Fri, 4 Feb 2011 18:36:34 -0800
Sean Corfield seancorfi...@gmail.com wrote:

 On Fri, Feb 4, 2011 at 6:16 PM, Eugen Dück eu...@dueck.org wrote:
  Is it really necessary, though? We all agree to EULAs and make other
  more significant legal commitments online all the time, and in some
  cases without having proven who and where we are.
 
 There are certainly some legal transactions that do not accept
 electronic agreements and require a physical signature.
 
 IANAL so I looked up US copyright law and found this paragraph about
 transfers in Circular 1 (from here
 http://www.copyright.gov/help/faq/faq-assignment.html ):
 
 Any or all of the copyright owner’s exclusive rights or any
 subdivision of those rights may be transferred, but the trans­fer of
 exclusive rights is not valid unless that transfer is in writing and
 signed by the owner of the rights conveyed or such owner’s duly
 authorized agent. Transfer of a right on a nonexclusive basis does not
 require a written agreement.
 
 So that's why a written signature is required for the Clojure CA.

Um, read the last line in the quote, about nonexclusive basis.

The first bullet of clause two in the CA (downloaded just now) grants
Rich Hickey a ... perpetual, irrevocable, non-exclusive, worldwide
... license

Given that the license is nonexclusive transfer (and I have to wonder
if you'd get any contributors otherwise, or if any other OSS project
has an exclusive transfer), then according to that last line, it does
not require a written agreement.

IANAL either, but it sure seems like the current requirements exceeds
what the law requires.

  mike
-- 
Mike Meyer m...@mired.org 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: Getting started with Counterclockwise

2011-01-30 Thread Mike Meyer
Ken Wesson kwess...@gmail.com wrote:

On Sat, Jan 29, 2011 at 1:46 PM, Mike Meyer
mwm-keyword-googlegroups.620...@mired.org wrote:
 Ditto.  Most often, the code site is the sole project site, and
everything is there. Some larger projects may have a separate home
page, but it's always prominently mentioned on the code site. In
either case, the code site is worth checking out - especially if it's
the first link turned up by Google.

The real problem is that navigating those sites can be a pain, if you
aren't intimately familiar with how the project is organized. Ever
land at some SourceForge page, see just a brief description of what
the project's software is supposed to do and a bunch of SourceForge
infrastructure, click files, and encounter a bewildering array of
zips and binaries, none clearly labeled as, say, the Windows installer
for the current version?

Sure, Sturgeon's law is closer to 99% than 90% for the web.  But if you don't 
even look at the right page to start with because of a false assumption, then 
any suggestions for fixing it are at best futile.
-- 
Sent from my Android tablet with K-9 Mail. Please excuse my brevity.

-- 
You 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: Getting started with Counterclockwise

2011-01-30 Thread Mike Meyer
Ken Wesson kwess...@gmail.com wrote:

On Sun, Jan 30, 2011 at 12:07 PM, Mike Meyer
mwm-keyword-googlegroups.620...@mired.org wrote:
 Sure, Sturgeon's law is closer to 99% than 90% for the web.  But if
you don't even look at the right page to start with

That is why I say it behooves projects that wish to grow a large
user-base to have a highly-ranked google result be clearly the place
for prospective end-users to go for further information,
documentation, friendly download links, etc. :)


Which is exactly what the project page is for most people - if it's the #1 
Google result.

-- 
Sent from my Android tablet with K-9 Mail. Please excuse my brevity.

-- 
You 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: Getting started with Counterclockwise

2011-01-30 Thread Mike Meyer
Ken Wesson kwess...@gmail.com wrote:

On Sun, Jan 30, 2011 at 12:31 PM, Mike Meyer
mwm-keyword-googlegroups.620...@mired.org wrote:
 Ken Wesson kwess...@gmail.com wrote:
That is why I say it behooves projects that wish to grow a large
user-base to have a highly-ranked google result be clearly the place
for prospective end-users to go for further information,
documentation, friendly download links, etc. :)

 Which is exactly what the project page is for most people

Disagree.

Of course - you're not most people,  you're a developer. That means names like 
bitbucket and sourceforge mean something to you. They don't for people who 
aren't developers.

-- 
Sent from my Android tablet with K-9 Mail. Please excuse my brevity.

-- 
You 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: Getting started with Counterclockwise

2011-01-30 Thread Mike Meyer
On Sun, 30 Jan 2011 13:38:24 -0500
Ken Wesson kwess...@gmail.com wrote:

 On Sun, Jan 30, 2011 at 1:24 PM, Mike Meyer
 mwm-keyword-googlegroups.620...@mired.org wrote:
  Ken Wesson kwess...@gmail.com wrote:
 
 On Sun, Jan 30, 2011 at 12:31 PM, Mike Meyer
 mwm-keyword-googlegroups.620...@mired.org wrote:
  Ken Wesson kwess...@gmail.com wrote:
 That is why I say it behooves projects that wish to grow a large
 user-base to have a highly-ranked google result be clearly the place
 for prospective end-users to go for further information,
 documentation, friendly download links, etc. :)
 
  Which is exactly what the project page is for most people
 
 Disagree.
 
  Of course - you're not most people,  you're a developer. That means names 
  like bitbucket and sourceforge mean something to you. They don't for people 
  who aren't developers.
 
 Not until after they go there once or twice, find confusing project
 pages with no clear starting point for prospective end users, and form
 an opinion of the site. :)

Yup. Those pages are about as well organized as every other page one
finds on the internet, so they wind up forming the exact same opinion
as they do of most sites. If someone takes the time to do a good site
design, it doesn't matter who hosts it. If they don't, putting it on a
custom domain won't magically make it better. For instance, try and
figure out how to install the Cyanogenmod software based on
www.cyanogenmod.com.

mike
-- 
Mike Meyer m...@mired.org 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: Getting started with Counterclockwise

2011-01-30 Thread Mike Meyer
On Sun, 30 Jan 2011 13:51:40 -0500
Ken Wesson kwess...@gmail.com wrote:

 On Sun, Jan 30, 2011 at 1:45 PM, Mike Meyer
 mwm-keyword-googlegroups.620...@mired.org wrote:
  Not until after they go there once or twice, find confusing project
  pages with no clear starting point for prospective end users, and form
  an opinion of the site. :)
 
  Yup. Those pages are about as well organized as every other page one
  finds on the internet, so they wind up forming the exact same opinion
  as they do of most sites. If someone takes the time to do a good site
  design, it doesn't matter who hosts it. If they don't, putting it on a
  custom domain won't magically make it better. For instance, try and
  figure out how to install the Cyanogenmod software based on
  www.cyanogenmod.com.
 
 But that's neglecting a crucial biasing factor: with project-hosting
 sites it's very easy to just slap together a few text blurbs for the
 front page and carry on your business using the tracker and
 repository; with regular web hosting you need to think a bit and
 actually come up with some page content, and you probably wouldn't
 have bothered to get regular web hosting if you weren't intending to.
 So if there's a regular .com site it's got a higher probability of
 being easy for end-users to navigate versus a randomly-selected
 sourceforge page.

Disagree, and already provided a counter-example.

  mike
-- 
Mike Meyer m...@mired.org 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: Getting started with Counterclockwise

2011-01-29 Thread Mike Meyer
Laurent PETIT laurent.pe...@gmail.com wrote:

2011/1/20 Ken Wesson kwess...@gmail.com

 On Wed, Jan 19, 2011 at 9:39 AM, Rayne disciplera...@gmail.com
wrote:
  Aren't you a developer?

 I'm not a CCW developer.

  If a code.google link is the top of google results, that's what I'm
  going to click and check out first. code.google is a project
hosting
  site, not just a place to throw up code and developer discussion.

 Yes, I know, but the general pattern is that those types of project
 hosting sites tend to host developer-centric material -- that is,
 material mainly of interest to developers *working on that project*,
 not just developers *using* it to develop *something else*.


Not in my experience.

Ditto.  Most often, the code site is the sole project site, and everything is 
there. Some larger projects may have a separate home page, but it's always 
prominently mentioned on the code site. In either case, the code site is 
worth checking out - especially if it's the first link turned up by Google.
-- 
Sent from my Android tablet with K-9 Mail. Please excuse my brevity.

-- 
You 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: Funding 2011?

2011-01-04 Thread Mike Meyer
On Tue, 4 Jan 2011 09:31:13 -0500
Rich Hickey richhic...@gmail.com wrote:
 On Nov 28, 2010, at 9:07 PM, Jeremy Dunck wrote:
  In Dec 2009, Rich asked the community to step up and support core
  development -- and the community came through.
  I'm interested in clojure, but not using it professionally yet.  I was
  wondering if funding for 2011 has already been worked out, or if it is
  an open question?

 I was going to continue the funding effort, but have decided against  
 it for the reasons given here:
 
 http://clojure.org/funding
 
 Many thanks to those who participated,

That is very sad, but I do understand the problem.

Possibly an approach like that taken by FreeBSD - with a foundation
that is legally distinct from the core developers - might work for
you:

http://www.freebsdfoundation.org/about.shtml

mike
-- 
Mike Meyer m...@mired.org 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: Interesting challenge

2010-12-30 Thread Mike Meyer
On Thu, 30 Dec 2010 12:03:14 -0500
David Nolen dnolen.li...@gmail.com wrote:

 From the Qi mailing list:
 
 http://groups.google.com/group/qilang/browse_thread/thread/e4a2f534fad5032a
 
 I contend that this kind of problem cannot be solved (efficiently) in any
 pure functional programming language. You may disagree

Do you know if his C++ version available for examination?

   thanks,
   mike
-- 
Mike Meyer m...@mired.org 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: Speed of clojure hash map vs java hash map

2010-12-29 Thread Mike Meyer
On Tue, 28 Dec 2010 22:28:54 -0800
Mark Engelberg mark.engelb...@gmail.com wrote:

[Standing on soapbox]

 On Tue, Dec 28, 2010 at 10:15 PM, David Nolen dnolen.li...@gmail.com wrote:
  Even in in a single threaded context raw insert performance isn't the final
  word. What if you want to be able to deliver a snapshot for reporting?
 
 What if you don't?
 
 Seriously, I agree with you that Clojure's data structures have some
 significant advantages -- if you need those advantages.  There are
 still plenty of apps that use hash tables in a single-threaded manner,
 or use them in a multithreaded way where contention is unlikely and
 persistence is unnecessary.  In many areas, Clojure has a
 pay-for-what-you-need philosophy -- this just isn't one of those
 areas.  With respect to data structures, Clojure is very opinionated,
 with an attitude of Write it with immutable data structures -- you'll
 thank me later. :) 

And you'll do that because some things are hard enough that letting
the programmer do it themselves - or decide when they need the help -
often results in the programmer doing it wrong. I mean - you don't
*need* garbage collection for everything: you can allocate and free
things by hand, or even use a voluntary garbage collector and mix
those two approaches. Historically, those things don't work very well,
and most of the world has gone to doing GC by default for
everything. There are still cases where you need to free resources by
hand, but those tend to be obvious and can either be hooked into the
GC system (so you free them just before the GC system frees some
containing object) or easy to free properly.

Letting programmers lock/unlock shared structures is very similar
operation to allocating/freeing data structures, and (from my point of
view, anyway) historically hasn't worked very well (I've found dozens
of windows/hanging locks/etc. in large systems that had been in
*production* for years!). Going to immutable by default for
everything is the same as going to gc by default for everything -
complete with tools for dealing with the exceptions when they arise.

Such systems are still relatively new, and we're still working out the
best way to deal with things. Maybe it'll turn out there's some
compromise short of what Clojure does that actually works well. But I
don't think we'll know what well is unless something tackles doing
it full-bore the way clojure does.

   mike
-- 
Mike Meyer m...@mired.org 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: Quicksort with accumulator

2010-12-28 Thread Mike Meyer
On Tue, 28 Dec 2010 19:50:28 +0530
Baishampayan Ghose b.gh...@gmail.com wrote:

 Hello,
 
 I tried writing a naive implementation of quicksort using an
 accumulator. Right now, the code is stack-consuming and returns a
 stackoverflowerror on large lists. Is there any way to prevent it from
 consuming stack with some changes? The code is as follows -

You don't say what your test data is, but pretty much any quicksort
implementation will have some nasty test cases for which its memory
usage is nasty and its performance is worse. Given that this is a
simple implementation, data that is already sorted is the degenerate
case.

I don't think you can keep it from using any stack - a non-recursive
implementation would just have to maintain it's own stack state. You
can do some things to make it use less stack, though.

First, deal with sorted data better by picking a median value from
coll instead of the first one.

Once the sequences get small enough, change to a non-recursive sorting
method to sort them.

If you're up to serious refactoring, fix the code to generate the
partitions inside of qsort*, and then use recur for the tail call of
qsort* - and make sure that call is on longer of less and greater.

  mike

 (declare qsort qsort* partify)
 
 (defn partify
   [item coll [less equal greater] acc]
   (if (empty? coll)
 (qsort* less (concat equal (qsort* greater acc)))
 (let [[head  tail] coll]
   (cond
( head item) (recur item tail [(cons head less) equal greater] acc)
( head item) (recur item tail [less equal (cons head greater)] acc)
:else (recur item tail [less (cons head equal) greater] acc)
 
 (defn qsort*
   [coll acc]
   (if-let [coll (seq coll)]
 (partify (first coll) (rest coll) [[] [(first coll)] []] acc)
 acc))
 
 (defn qsort
   Perform Quicksort, with apologies to C.A.R. Hoare
   [coll]
   (if-let [coll (seq coll)]
 (qsort* coll [])
 []))
 
 Regards,
 BG
 


-- 
Mike Meyer m...@mired.org 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


SCA FAQ link at clojure.org/contributing....

2010-12-21 Thread Mike Meyer
The link to the SCA FAQ on the page at clojure.org/contributing now
returns a document not found page. Given that the Clojure CA is based
on the Sun Contributor Agreement and what Oracle has since done with
NotQuiteSoOpenSolaris, this would seem to be an important document to
have available.

 mike
-- 
Mike Meyer m...@mired.org 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: Ah-hah! Clojure is a Lisp

2010-12-20 Thread Mike Meyer
On Mon, 20 Dec 2010 19:26:49 +0100
Meikel Brandmeyer m...@kotka.de wrote:

 Hi,
 
 if you prefer text over talk:
 
 http://clojure.googlegroups.com/web/AreWeThereYet.pdf

Thanks for the link.

To bad it made Tufte kill a kitten. I had forgotten there was a
textual representation with a lower information density per bit than
video.

But it does get the ideas across. It seems a lot of this could have
come from other applications I'm using these days, like mercurial
(with an immutable history) or zfs (with an immutable file system).

  Thanks again,
  mike
-- 
Mike Meyer m...@mired.org 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: Ah-hah! Clojure is a Lisp

2010-12-20 Thread Mike Meyer
On Mon, 20 Dec 2010 16:27:11 -0500
Ken Wesson kwess...@gmail.com wrote:

 On Mon, Dec 20, 2010 at 3:00 PM, Mike Meyer
 mwm-keyword-googlegroups.620...@mired.org wrote:
  On Mon, 20 Dec 2010 19:26:49 +0100
  Meikel Brandmeyer m...@kotka.de wrote:
  http://clojure.googlegroups.com/web/AreWeThereYet.pdf
 
  Thanks for the link.
 
  To bad it made Tufte kill a kitten. I had forgotten there was a
  textual representation with a lower information density per bit than
  video.
 
 Did you mean a higher information density per bit?

No, I meant lower.

mike
-- 
Mike Meyer m...@mired.org 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: Ah-hah! Clojure is a Lisp

2010-12-19 Thread Mike Meyer
On Sun, 19 Dec 2010 21:24:42 -0500
Ken Wesson kwess...@gmail.com wrote:

 On Sun, Dec 19, 2010 at 8:25 PM, Tim Daly d...@axiom-developer.org wrote:
 
 
  On 12/19/2010 8:20 PM, Ken Wesson wrote:
 
  On Sun, Dec 19, 2010 at 8:18 PM, Tim Dalyd...@axiom-developer.org
   wrote:
 
   I didn't mean to imply that other people
  don't have the ah-hah! experience with
  other languages. However, I have only had
  the (before lisp)|(after lisp) experience
  with lisp.
 
  Your enlightenment might vary.
 
  Rich gave his Whitehead talk and brought
  up the fact that OO languages get several
  things wrong.
 
  Out of curiosity, which several things were these?
 
  http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey
 
 Please install Flash Player.
 
 Has everyone on this list developed a sudden allergy to plain text and
 HTML? First I get pointed to a 34-minute video, and now this. A simple
 bulleted list with a brief precis about each item would have sufficed;
 a multi-megabyte install of an executable and who knows how much
 futzing around, overkill.

Let me second that - especially since flash isn't available for my
normal mail platform, so the kludges required to run it make it even
flakier than what Jobs objects to, and tends to hose performance there
no end.

Yes, somethings may best be presented on video, but all to often
people try pass videos off as documentation (*). Even when video is
actually the best choice, the least you could do is post something in
an actual video format, and not as an executable for a poorly
documented, proprietary VM that has had more than one security issue
in the past.

   mike

* A video isn't documentation. I can leave documentation open to the
relevant page, and search it for the relevant phrases. A video may be
educational, but that doesn't make it documentation.
-- 
Mike Meyer m...@mired.org 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: about the repl

2010-12-18 Thread Mike Meyer
On Fri, 17 Dec 2010 22:45:01 -0800 (PST)
tor torgau...@gmail.com wrote:
 Is there a way to activate word completion in the repl? I find myself 
 hitting tab all the time...

Since nobody else mentioned it (or even offered a solution other than
Try my environment), you can use rlwrap (should be available in your
systems package manager) to run your repl, and get word completion -
among other goodies one wants on a command line.

The appropriate rlwrap invocation is:

rlwrap --command clojure --complete-filenames --quote-characters='' 
--prompt-colour=Red 

followed by whatever command you use to start the repl.

You'll also want to past this code into a repl running in your home
directory:

(def completions
(reduce concat (map (fn [ns] (keys (ns-publics ns))) (all-ns

(defn save-completions-to [filename]
  (with-open [f (java.io.BufferedWriter. (java.io.FileWriter. filename))]
(.write f (apply str (interleave completions (repeat \n))

(save-completions-to .clojure_completions)

to create the list of completions for rlwrap.

   mike
-- 
Mike Meyer m...@mired.org 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


Improving the documentation

2010-12-16 Thread Mike Meyer
On Thu, 16 Dec 2010 10:18:47 -0700
Terrance Davis terrance.da...@gmail.com wrote:

 *begin rant*
 
 I have yet to see anyone who posts the classic rtfm (even politely) 
 response search previous posts and realize that rtfm responses have 
 already been sent and refrain from sending the same explanation of how 
 to use a mailing list over and over and over. Simple customer service 
 experience teaches that if customers are asking the same questions 
 multiple times, then the documentation is either, hard to find, 
 incomplete, or not clear enough. Improving the docs is a healthier and 
 more productive use of time than starting yet another thread on how to 
 use a mailing list.
 
 *end rant*
 
 Sorry. Couldn't contain myself ;-)

No need to be sorry - it's a very good point.

In the past, I've contributed to open source projects by watching for
the same question to be raised multiple times, combining the data in
the best answers into one best of breed, and submitting it as a
patch for the project handbook. The clojure community doesn't have
anything as spiffy as the FreeBSD handbook - instead we have a wiki
FAQ page (from clojure.org, click wiki then 2 FAQ to get to
http://en.wikibooks.org/wiki/Clojure_Programming). While much more
painful than editing docbook, it's a good place to post things.

Unfortunately, we can't post excerpts from clojure source there
because the wiki license is incompatible with the source license - or
anything else using that same license. In particular, not being able
to use doc strings, etc.

Given that the FAQ itself suggests that such be posted to the clojure
group, this makes doing what I did rather problematical. Minimally, I
need to figure out whether or not a post contains such an excerpt in
order to be able to use it. Worst case, the license for content posted
to the group is *also* incompatible with the source license, so you
can't legally add any Frequent Answers from there to the FAQ.

Ok, I found a problem. Anyone got solutions?

  mike

PS: behavior-modification posts (i.e. - the rtfm posts) needs to be
done repeatedly because (we hope) the group keeps growing. If everyone
simply ignores improper behavior, the newcomers will assume it's
proper behavior (even if there's a covenant for the group saying
otherwise). Hence periodic reminders are called for.

-- 
Mike Meyer m...@mired.org 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: Improving the documentation

2010-12-16 Thread Mike Meyer
On Thu, 16 Dec 2010 17:50:58 -0500
Stuart Halloway stuart.hallo...@gmail.com wrote:

  On Thu, 16 Dec 2010 10:18:47 -0700
  Terrance Davis terrance.da...@gmail.com wrote:
  
  *begin rant*
  
  I have yet to see anyone who posts the classic rtfm (even politely) 
  response search previous posts and realize that rtfm responses have 
  already been sent and refrain from sending the same explanation of how 
  to use a mailing list over and over and over. Simple customer service 
  experience teaches that if customers are asking the same questions 
  multiple times, then the documentation is either, hard to find, 
  incomplete, or not clear enough. Improving the docs is a healthier and 
  more productive use of time than starting yet another thread on how to 
  use a mailing list.
  
  *end rant*
  
  Sorry. Couldn't contain myself ;-)
  
  No need to be sorry - it's a very good point.
  
  In the past, I've contributed to open source projects by watching for
  the same question to be raised multiple times, combining the data in
  the best answers into one best of breed, and submitting it as a
  patch for the project handbook. The clojure community doesn't have
  anything as spiffy as the FreeBSD handbook - instead we have a wiki
  FAQ page (from clojure.org, click wiki then 2 FAQ to get to
  http://en.wikibooks.org/wiki/Clojure_Programming). While much more
  painful than editing docbook, it's a good place to post things.
  
  Unfortunately, we can't post excerpts from clojure source there
  because the wiki license is incompatible with the source license - or
  anything else using that same license. In particular, not being able
  to use doc strings, etc.
  
  Given that the FAQ itself suggests that such be posted to the clojure
  group, this makes doing what I did rather problematical. Minimally, I
  need to figure out whether or not a post contains such an excerpt in
  order to be able to use it. Worst case, the license for content posted
  to the group is *also* incompatible with the source license, so you
  can't legally add any Frequent Answers from there to the FAQ.
  
  Ok, I found a problem. Anyone got solutions?
  
   mike
 
 The new FAQ (under construction at http://dev.clojure.org/display/doc/FAQ) 
 has edit capabilities tied to signing the CA.
 
 If you have signed a CA you can post to the FAQ, quoting from other 
 CA-governed sources (e.g. Clojure) as makes sense.
 
 Does that help?

First, that looks more like it's part of a wiki aimed at clojure
developers than at clojure users. While that's an important thing to
have, it's not what I'm looking for, and I'm pretty sure that
combining the two is bad idea.

Second, a wiki that requires you be a contributor to edit it seems to
defeat the point of having a wiki in the first place. If you're going
to require someone to be a contribute to edit the docs, why not use a
real document processing system instead, so that you can handle
documentation using the same tools (source control system, etc.) as
you're using for code, and get the added benefit of being able to
generate media-specific output (assuming you chose a good dps).

Finally, Jira needs a category for wiki bugs so that people who
haven't signed a CA can contribute fixes (patches? to a wiki?  Another
reason to use a real document processing system).

mike
-- 
Mike Meyer m...@mired.org 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: Clojure 1.3 Alpha 4

2010-12-15 Thread Mike Meyer
On Tue, 14 Dec 2010 21:04:11 -0500
Ken Wesson kwess...@gmail.com wrote:

 On Tue, Dec 14, 2010 at 8:23 PM, Benny Tsai benny.t...@gmail.com wrote:
  As Brian said, primitive math is now the default in 1.3.  If auto-
  promotion on overflow is desired, you can use the +', -', *', inc',
  dec' functions (note the single quote suffix).
 
 Why was this done? I preferred having +, -, etc. DTRT in general and
 unchecked-+, etc. for when you really needed efficient primitive math.
 My code is littered with + but has few unchecked-+s. Which means I'll
 have to go through it all adding little tick-marks everywhere and
 making the math look funny to keep its behavior the same whenever 1.3
 is released.

One of the things those of us on your side *begged* for (and
apparently also didn't get) was that the versions with correct
behavior not have second-class names. That we didn't get them means
we'll have to provide them ourselves, but it's easy. Since we're
having to fix code anyway, just use a file containing something like:

(def add +')
(def sub -')
(def mul *')
(def add1 inc')
(def sub1 dec')

when you need it.

 mike
-- 
Mike Meyer m...@mired.org 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: Clojure 1.3 Alpha 4

2010-12-15 Thread Mike Meyer
On Wed, 15 Dec 2010 13:02:13 -0500
Ken Wesson kwess...@gmail.com wrote:

 On Wed, Dec 15, 2010 at 12:51 PM, Eric Schulte schulte.e...@gmail.com wrote:
  Ken Wesson kwess...@gmail.com writes:
 
  Are you honestly suggesting I search the archives
 
  It is common courtesy on open-source lists such as this one to check if
  a question you are about to ask has already been answered.
 
 As I believe I already mentioned, if everyone spends a while searching
 some archives every time they are going to post, this list's traffic
 will drop to nearly nil. Do we really want that?

Actually, what would drop to nearly nil would be questions that have
already been answered and points that have already been debated to
death. And yes, we *do* want that. In fact, it's part of the FAQ on
asking smart questions:
http://www.catb.org/~esr/faqs/smart-questions.html.

Further, not only is it easy (the list is hosted by google groups, so
just googling for keywords will search it) but may well turn up the
answer faster than posting to the list.

Admittedly, that (or searching the archives proper) might not have
found what you're looking for in this case, because neither enhanced
nor primitive leap to mind as search terms when you get an unexpected
overflow error. But it works often enough that checking google before
asking a question is a productive habit to get into.

   mike
-- 
Mike Meyer m...@mired.org 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: Clojure 1.3 Alpha 4

2010-12-13 Thread Mike Meyer
Vagif Verdi vagif.ve...@gmail.com wrote:

Maybe clojure should adopt linux versioning scheme, where even numbers
are stable production clojure and odd numbers are development branch ?

Gods please no.
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

-- 
You 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: Moderately off-topic: installing emacs on OSX

2010-12-10 Thread Mike Meyer
On Sat, 11 Dec 2010 01:07:51 +
Alec Battles alec.batt...@gmail.com wrote:

  I don't use OS X so I can't comment on such a consensus, but while I
  appreciate the sentiment, it's actually harmful to some degree to have
  lots of blog posts scattered around everywhere that all have slightly
  different advice, especially since that advice usually becomes
  outdated within the year.
 Speak for yourself. Whenever I need to install SCIM on someone's
 computer I pull up three conflicting blog posts and just combine
 elements of all of them.

I do that as well. And then, after a couple of days trying all the
various combinations and having none of them work, I give up and ask
the on the list to get an answer that actually works with the current
versions of all the tools. Of course, if a typical howto was more
than a recipe of steps with no explanations, but actually documented
why you wanted to take each step and what it achieved, then you might
have a chance of figuring out how to mix them to be right for your
environment.

  I strongly suggest improving the docs on the
  Clojure wiki instead; that way errors can be fixed by the community.
 Why does the one preclude the other?

Much as I hate wiki's, an up-to-date wiki is *much* better than a
collection of out of date blog entries.  It makes the reading the
out-of-date blog entries that google returns a waste of time. If the
wiki isn't up to date, then it just becomes a part of the
trial-and-error process that's the norm for getting things done in the
Linux world.

 Also, if people aren't going to blog about Clojure, what future does it have?

If people can't figure out how to get Clojure installed because all
they can find on the web is out of date blog entries, what future does
it have?

There's *lots* of good thing in clojure to blog about without writing
yet another howto that's going to be out of date in a few
months. You can write about what you're doing with it: how the Java
interop helps with that, how the nifty data structures and functions
that work with them assist the process of creating a program, etc.

Basically, it's a simple choice - do you help yourself by writing an
entry for your blog, or do you help the clojure community by writing
an entry for the wiki? I claim the subject matter should determine
which: if you're documenting how to use clojure, put it on the
wiki. If you're documenting how you're using clojure, put it in your
blog.

mike
-- 
Mike Meyer m...@mired.org 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: Lots of newbie clojure questions

2010-12-07 Thread Mike Meyer
On Tue, 7 Dec 2010 02:58:11 -0500
Ken Wesson kwess...@gmail.com wrote:

 On Tue, Dec 7, 2010 at 2:15 AM, javajosh javaj...@gmail.com wrote:
  Mike and I have had a nice off-line conversation where we enumerated
  the possible things that can come after open-parens. I listed 7, he
  added 3:

That wasn't meant to be offline, but it's probably not worth
resending. However...

  1. A value (if the paren has a tick '(  )
  2. A function.
  3. A map - which is a psuedo function that takes a key as an arg.
  4. A keyword - which is a psuedo function that takes a map as an arg.
  5. A macro. This is the normal case, I think. Looking through the mailing
  list, it appears that most clojure programming questions revolve around
  which one of the hundreds of macros to invoke and in which order!
  6. The Java form: (MyClass. )
  7. The java method form (.doSomething)
  8. A function returning a function to invoke - ((find-my-function) )
  9. A loop - (recur )
  10. The anonymous function macro: #( )
 
  So, at least I know why I feel uneasy about open paren! It's super
  overloaded.
 
 Not really. (...) is a non-atomic s-expression. If it's evaluated
 unquoted, the first nested s-expression is evaluated and if it's not
 callable an exception is thrown. Macros, special forms (which are sort
 of like system-internal macros and are used to build all the other
 macros, and functions), Java constructors, Java methods, and functions
 are callable (and maps and keywords -- also vectors -- act as
 functions for this purpose).
 
 The only real overloading always involves macros:
 
 #() evaluates to a function and doesn't run its insides right away.
 Then again so does (defn foo [x] (inc x)) -- the (inc x) is run when
 foo is called, calling inc, but not when the (defn ...) is called.
 Macros can delay evaluation of their contents, and #() is a reader
 macro.
 
 '(x y z) is another reader macro and expands to (quote (x y z)).

This was pretty much what I tried to explain as well, even including
the comment that I almost never used '( ) in clojure because vectors
worked as well.

  Mike also points out that things that aren't functions (not used in
  that context) can't be aliased with def or use.
 
 Really?
 
 user= (def a 3)
 #'user/a
 user= (def b a)
 #'user/b
 user= b
 3

This one I flubbed, because my vocabulary failed me. There are three
classes of values that can work when they show up in the first
position in an executable expression:

1) Functions, which can also be passed to higher order functions.
2) Macros, which can't, but can be aliased by def or use.
3) Java interop things (#6 6  7 on his list), which can't be aliased
   by def or use.

   mike
-- 
Mike Meyer m...@mired.org 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: parameters destructuring sets?

2010-12-06 Thread Mike Meyer
On Mon, 6 Dec 2010 16:30:10 -0500
Ken Wesson kwess...@gmail.com wrote:

 On Mon, Dec 6, 2010 at 1:05 PM, Stuart Sierra
 the.stuart.sie...@gmail.com wrote:
  On Dec 6, 8:36 am, Ken Wesson kwess...@gmail.com wrote:
  Furthermore, the comment (not made by Hickey) that map order may be
  unstable is more than a little puzzling in light of the fact that the
  maps in question are immutable. :)
 
  In general, Rich has been careful not to promise things that might
  limit changes he can make in the future. Sets and maps are unordered.
  `seq` happens to be deterministic on ArrayMap and HashMap, but there
  might some day be some other kind of map or set for which `seq` cannot
  be deterministic. Therefore, Clojure does not promise anything about
  `seq` on maps, other than that it will return the key-value pairs.
 
 I confess I can't see any obvious reason ever to make seq
 nondeterministic on an immutable data structure.

I suspect you're applying immutable to everything about the data
structure, whereas it can also be applied the value without including
the implementation.  I can see wanting to change the implementation in
ways that don't change the value - triggered by something like wanting
to share parts of the value with another structure, or a garbage
collection, or ... - which could easily change the results of calling
seq on the structure.

Not that I know that anything in clojure does that, just that I can
see conditions where you might want to.

mike
-- 
Mike Meyer m...@mired.org 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: parameters destructuring sets?

2010-12-06 Thread Mike Meyer
On Mon, 6 Dec 2010 17:07:15 -0500
Ken Wesson kwess...@gmail.com wrote:

 On Mon, Dec 6, 2010 at 4:44 PM, Mike Meyer
 mwm-keyword-googlegroups.620...@mired.org wrote:
  On Mon, 6 Dec 2010 16:30:10 -0500
  Ken Wesson kwess...@gmail.com wrote:
 
  On Mon, Dec 6, 2010 at 1:05 PM, Stuart Sierra
  the.stuart.sie...@gmail.com wrote:
   On Dec 6, 8:36 am, Ken Wesson kwess...@gmail.com wrote:
   Furthermore, the comment (not made by Hickey) that map order may be
   unstable is more than a little puzzling in light of the fact that the
   maps in question are immutable. :)
  
   In general, Rich has been careful not to promise things that might
   limit changes he can make in the future. Sets and maps are unordered.
   `seq` happens to be deterministic on ArrayMap and HashMap, but there
   might some day be some other kind of map or set for which `seq` cannot
   be deterministic. Therefore, Clojure does not promise anything about
   `seq` on maps, other than that it will return the key-value pairs.
 
  I confess I can't see any obvious reason ever to make seq
  nondeterministic on an immutable data structure.
 
  I suspect you're applying immutable to everything about the data
  structure, whereas it can also be applied the value without including
  the implementation.  I can see wanting to change the implementation in
  ways that don't change the value - triggered by something like wanting
  to share parts of the value with another structure, or a garbage
  collection, or ... - which could easily change the results of calling
  seq on the structure.
 
 Perhaps. But under those circumstances seq itself has the same problem
 you're using to excuse not supporting nth, yet seq is supported.

I had some trouble figuring out what you're saying here, so let me
know if I got this wrong: I'm providing reasons for seq to not have a
guarantee of determinism when called on some structures, and that
non-determinism is the justification for nth not being supported, so
why is seq supported?

A non-deterministic nth has no value - you might as well just use
first (and in fact, you can). A non-deterministic seq, on the other
hand, *does* have a value: it provides representation of the value for
which nth (and friends) have a deterministic value.

Having nth call seq on structures for which seq is non-deterministic
would slow down nth, and possibly hide buggy code. Forcing the call to
seq be explicit means there's a chance they'll notice the
non-deterministic result, and fix the bug.

 And so is (nth (seq x)) on these things; if the implementation
 changed its innards while you were walking the seq (even with map!
 Nevermind using nth) this could trip up. You might have a set #{1 2
 3 4 5 6} and seq would produce (1 3 4 5 2 6) and then someone makes
 another set from it with disj and the structure rearranges, so seq
 would now produce (1 5 6 2 4 3). Meanwhile, another thread has
 produced a seq and is traversing it at the time and gets (1 3 4 2 4
 3). Oops.

There are a number of ways to avoid this bug. You found at least one
of them here:

 If that kind of internal rearrangement is to be done, seq will have to
 copy the structure's contents (by realizing the seq promptly; so there
 goes laziness) in order to avoid that kind of error. And once you have
 that, you will want to create AND CACHE the (immutable!) structure's
 seq-representation when it's first needed. And you can do so when nth
 is called, as well as seq. And then due to the caching both nth and
 seq will obey (if (identical? s1 s2) (identical? (f s1) (f s2))) when
 substituted for f.
 
 Even then, I'd expect internal rearrangement to be a thread-safety
 nightmare; in all likelihood a) rearranging operations, and b)
 operations like realizing the seq that will be b0rked by concurrent
 rearrangements, will require locking the structure. Locking is
 supposed to be kept to a minimum as one of Clojure's design goals,
 IIRC.
 
 This gets worse when you note that seq realization can cause the
 execution of user-supplied code (e.g. the body of a lazy-seq macro)
 during realization. If user-supplied code can end up executing with
 user-invisible monitors locked, and can in turn cause more monitors to
 be locked (say, by disjing a set thus causing one of your hypothetical
 internal rearrangements), then it can cause deadlocks that would be
 fiendishly difficult to track down and fix. And deadlock avoidance is
 *emphatically* one of Clojure's design goals.

All true. As far as I'm concerned, it's also all irrelevant. Just
because doing a thing is hard in all known examples doesn't mean you
want to give up the right to do it should you decide you need to.

 mike
-- 
Mike Meyer m...@mired.org 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

Re: Lots of newbie clojure questions

2010-12-06 Thread Mike Meyer
On Mon, 6 Dec 2010 16:50:40 -0800 (PST)
javajosh javaj...@gmail.com wrote:

 1. What is the justification for using a map as a function? I find
 this to be very confusing.

The same as using a keyword for a function - it lets you write shorter
code.

 2. In practice, I find myself wincing when needing to decide whether
 or not to type an open-paren. Is that a common thing?

I don't believe so. Hopefully it will go away soon.

 3. Is there a compendium of recursive idioms, ideally expressed in
 clojure? Including indentation conventions! (Is there an opportunity
 for a python inspired pre-processor that interprets indentation as
 parens?)

Well, I've always liked D.W. Barron's Recursive Techniques in
Programming, and found Eric S. Robert's Thinking Recursively to be
worth reading, but neither are in LISP. On the other hand, I'm not
sure that a LISP programmer would see the value in a compendium of
recursive idioms.

 4. Why don't long-running clojure programs monotonically increase in
 heap usage if all data-structures are immutable?

For the same reason that Java programs don't monotonically increase in
heap usage: the Java garbage collector recycles storage that's no
longer in use.

 5. In the REPL, isn't it redundant to always have to type the top-
 level parens?

Not really. If you don't do that, the REPL has to figure out what a
naked token on the command line is, and then decide whether or not to
add the parens to it.

That said, what you're asking about has been used in various LISP
systems dating back to the last century, and is known as an evalquote
REPL (as opposed to the more common eval REPL used by Clojure). There
are a number of CL implementations floating around the web, but I
haven't seen one for clojure.

 6. Is there a place to get guidlines on macro idioms? The feature is
 so powerful that it seems like it would be easy to misuse it and crack
 a programmers head like a nut with a badly structured macro.

Halloway's Programming Clojure has a good chapter on macros, but
it's not as comprehensive as a good CL book's coverage (ask if you
want references, but I wouldn't recommend learning CL just to help
with clojure). In particular, he doesn't talk about using macros as an
optimization technique. It does give a good set of rules for writing
macros:

1) Don't write macros.

2) Only write macros if that's the only way to encapsulate a pattern.

3) You can write a macro if it makes life easier for your callers than
   the equivalent function (my aside: write the function, then have the
   macro invoke it).

 I also have some philosophical questions:

Given that I have to live in the poor physical approximation to the
real world described by mathematics, I'm going to skip most of these.

 1. Isn't the world actually imperative? And mutable? Collaboration
 *is* a messy proposition in real life. It's hard to fix your car, and
 even harder to have lots of people fix your car. I find the it models
 the real world better justification for functional programming rather
 confusing. (Indeed, the CPU and physical memory also have an
 imperative relationship!)
 2. 'Side-effects' are treated almost as a bad word by most functional
 programming advocates. And yet, aren't ALL programs executed for their
 side-effects? Does side effect perhaps then require a qualification
 or a tighter definition? Or perhaps side-effects aren't that bad?
 3. What is the relationship between the shape of a clojure program
 and the runtime call stack? (I ask because a clojure program looks
 strikingly similar to the callstack of an ordinary program when you
 'pause' a thread.)
 4. Is it possible (and/or advisable) to introduce a typing system on
 top of clojure? E.g. a macro-form along the lines of (fnif
 type_function function args)

  mike
-- 
Mike Meyer m...@mired.org 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: How can I avoid needing this other function?

2010-12-06 Thread Mike Meyer
On Tue, 7 Dec 2010 00:44:52 -0500
Alex Baranosky alexander.barano...@gmail.com wrote:

 Here is the code I'm working on.  The first function is wanted. The second
 is not. (and the duplication is waiting to be factored out somehow...)
 
 Is there an idiomatic Clojure way to use map-of-distances on the Line of
 Note below, instead of map-of-distances* ?
 
 Thanks for all your help.
 
 (defn map-of-distances [origin  locations]
   (loop [dists {} locs locations]
 (if (seq locs)
   (let [[loc  more] locs
 dist (dist-in-miles origin loc)
 dists (assoc dists loc dist)]
 (recur dists more))
   dists)))
 
 (defn map-of-distances* [origin locations]
   (loop [dists {} locs locations]
 (if (seq locs)
   (let [[loc  more] locs
 dist (dist-in-miles origin loc)
 dists (assoc dists loc dist)]
 (recur dists more))
   dists)))
 
 (defn relative-distance
   Gives distance * frequency.
   frequencies are in days out of 365
   [origin  locations-n-frequencies]
   (let [loc-w-dists (map-of-distances* origin (take-nth 2
 locations-n-frequencies))  ;  -- Line of Note
 loc-w-freqs (apply hash-map locations-n-frequencies)]
 (multi-fmap (fn [d f] (* d f)) loc-w-dists loc-w-freqs)))

I haven't verified it, but based on the two interfaces, you want to
use apply again:

(map-of-distances* origin (take-nth 2 locations-n-frequencies))
can be written as:
(apply map-of-distances origin (take-nth 2 locations-n-frequencies))

FWIW, if you really needed them both, it'd be idiomatic to write one
in terms of the other:

(defn map-of-distances [origin  locations] 
  (map-of-distances* origin locations))

or (going the other way):

(defn map-of-distances* [origin locations] 
  (apply map-of-distances origin locations))

though this one you might not bother to write out, and just use the
apply inline as above.

  mike
-- 
Mike Meyer m...@mired.org 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


Ring startup processing?

2010-11-27 Thread Mike Meyer
My simple web app
(http://blog.mired.org/2010/11/x10-controller-in-clojure.html) has
some stuff that needs to happen just once (in this case, opening the
serial port). It's not clear how to get this to happen using ring. If
I do it inside my ring handler, then it gets run on every request, and
I have to check to make sure it's not run multiple times. If I run it
outside the handler, then it gets run when I do lein uberwar, which
is simply wrong.

When the deployment platform activates the war would seem to be the
right time to run this (war load time?). So maybe this is a question
that depends on the deployment platform, or war? However, a quick
google search didn't turn up anything that looked interesting.

Anyone got suggestions on how to set up code to be run when Jetty (or
tomcat, or ...)?

thanks,
mike
-- 
Mike Meyer m...@mired.org 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: discussing Clojure with non-CS types

2010-11-24 Thread Mike Meyer
 of
thing, but it doesn't seem quite as mature - and I believe it runs at
JVM speeds.)

 8. Every problem has been solved twice in Java.  Meaning it has been
 solved three times in clojure.

Java's a relative newcomer. If it's been solved twice in Java, it's
probably been solved twice in Python, with wrapped C and C++ solutions
available as well. This is not always a good thing...

 The underlying theme is that you can quickly write the code that you
 need to do your job, so that you can get back to doing your job.

At this stage, I suspect that Python is still the better tool for
them. The advantages Clojure has over Python are in the for computer
scientists domain, whereas Python's advantages over Clojure are
things that will matter to them: access to libraries they are familiar
with, and that it's much easier to read Python code on first exposure,
means that sharing results (an important part of the process) is much
easier.

Especially since there's a community of people willing to help them
with it at http://www.scipy.org/. Of course, if you're trying to get
them off FORTRAN, pretty much anything would be an improvement.

 mike
-- 
Mike Meyer m...@mired.org 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


Question about an idiom.....

2010-11-24 Thread Mike Meyer
On Wed, 24 Nov 2010 00:37:07 -0800 (PST)
LauJensen lau.jen...@bestinclass.dk wrote:

You just touched on an idiom I see fairly often here that bugs me. I'm
not intentionally singling you - or CQL! - out for this, but you made
a comment that sets up my question perfectly.

 (let [photo-counts (- (table :photos)
(aggregate [[:count/* :as :cnt]] [:id])))]
(- (table :users)
 (join photo-counts (= {:users.id :photos.id}))
 
 I think thats really as simple as you can express that join operation.

Um, I can see two macros that, if expanded in place, would result in a
simpler expression (assuming that CQL doesn't redefine -):

(let [photo-counts (aggregate (table :photos) [[:count/* :as :cnt]] [:id])]
   (join (table :users) photo-counts (= {:users.id :photos.id})))

I also fixed the parens - I think. I removed one after [:id], and it
seems like two were missing at the end as well.

Ok, I understand why you would use - if you're threading through
multiple forms. I don't know that I like it, but I can at least
understand it. But when it's only one form? In the best case - when
the form is a symbol, as in (- 1 inc) - it just wastes three
characters to reverse the form and argument. More often - for example
(- 1 (+ 2)) - it also adds another level of parenthesis, which I
thought most people considered a hindrance to comprehension.

Could someone explain where this urge to write (- expr (func arg))
instead of (func expr arg) comes from?

mike
-- 
Mike Meyer m...@mired.org 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: Question about an idiom.....

2010-11-24 Thread Mike Meyer
On Wed, 24 Nov 2010 22:51:09 +0100
Daniel Werner daniel.d.wer...@googlemail.com wrote:

 On 24 November 2010 21:40, Mike Meyer
 mwm-keyword-googlegroups.620...@mired.org wrote:
  Could someone explain where this urge to write (- expr (func arg))
  instead of (func expr arg) comes from?
 
 I like to use - and - because they allow me to add more steps to
 the pipeline as needed, without requiring ever more deeply nested
 parentheses. Of course, the examples you cited were intentionally
 trivial

Those cases weren't intentionally trivial, they were the
point. What's the motive for using - when there's only one form after
the expression? I get why you'd do it with two or more forms - it
reduces the nesting, and reading left-to right follows the evaluation
order. But with just one form it's liable to have the opposite effect
on nesting, and it makes the evaluation order read zig-zag.

mike
-- 
Mike Meyer m...@mired.org 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: Clojure vs Clisp...How big is the difference??

2010-11-21 Thread Mike Meyer
On Sun, 21 Nov 2010 16:26:07 -0800 (PST)
coco clasesparticulares...@gmail.com wrote:

 Hi  everybody...I'm interested in learning clojure but there're only a
 few books and more focused to advanced programmers...I found today a
 nice book about Clisp but I don't know how different is itplease
 can tell if can be recommendable learn first Clisp with a easy follow
 book..or if there are many differences about these and It's not
 recommendable

Well, learning Clisp first will make learning Clojure a lot easier if
you're not familiar with LISPs or functional programming. However,
Clisp is large enough that you could easily spend more time there than
you saved. If you really want to tackle a more established language
before Clojure, I'd recommend Scheme instead, partly because Scheme is
nice and small, but mostly because it also has some really good books
available. On the other hand, there are some good Clojure books, and
I'm tempted to say just start with those, but I haven't had the
opportunity to use them to learn functional programming, so I'm not
sure how much that opinion is worth.

 mike
-- 
Mike Meyer m...@mired.org 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: Weird result for (get max key)

2010-11-19 Thread Mike Meyer
On Fri, 19 Nov 2010 17:52:03 -0800 (PST)
Bob Shock shock...@gmail.com wrote:

 I had a bug in my code where I meant to type:
 
 (get map key)
 
 and instead typed:
 
 (get max key)
 
 It seems that any function name I put in for max always returns nil.
 
 user= (get max 3)
 nil
 user= (get min 3)
 nil
 user= (get maxx 3)
 java.lang.Exception: Unable to resolve symbol: maxx in this context
 (NO_SOURCE_FILE:10)
 user=
 
 Any ideas?

Yup. get returns nil if the key isn't in the map. Since functions
aren't maps (or anything else that fits that abstraction), they can't
contain the key, so you get nil. If you try it with pretty much any
arbitrary map value (integers, etc.) you get nil. If you provide the
third argument to get, you'll get that value back in all these cases.

  mike
-- 
Mike Meyer m...@mired.org 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: Incorrect behaviour for large s-expressions :(

2010-11-14 Thread Mike Meyer
On Sun, 14 Nov 2010 00:48:13 -0500
Robert McIntyre r...@mit.edu wrote:

 So my friend and I were screwing around, battling versions of LISP as
 nerds are wont to do, when I came across this:
 
 (eval `(clojure.core/+ ~@(take 1e4 (iterate inc 1
 Invalid method Code length 89884 in class file user$eval13607
 
 
 This is just trying to evaluate + directly on a bunch of arguments.

I'd say the first problem is using the macro-building constructs
outside a macro. I believe this is generally a bad idea. If you build
the list and apply + to it directly, it works fine

Clojure 1.2.0
user= (apply + (doall (take 1e4 (iterate inc 1
(apply + (take 1e4 (iterate inc 1)))
50005000
user= (apply + (doall (take 1e5 (iterate inc 1
(apply + (take 1e5 (iterate inc 1)))
55
user= 

But nope, you've got a real problem. It appears to be with eval:

user= (eval (cons + (take 1e4 (iterate inc 1
(eval (cons + (take 1e4 (iterate inc 1
java.lang.ClassFormatError: Invalid method Code length 89881 in class file 
user$eval26 (NO_SOURCE_FILE:8)
user= (count (cons + (take 1e4 (iterate inc 1
(count (cons + (take 1e4 (iterate inc 1
10001

Of course, eval isn't idiomatic clojure. 

 Common Lisp on my friend's 30 year old Lisp machine does the
 equivalent of this with ease, even for much larger numbers.
 
 As I'm writing this, my friend is rubbing in this in my face by also
 doing the above with C-LISP on his laptop.  (although his stack
 overflows for 1e5)

Well, the apply version works out to 1e8 for me if I leave out the
doall. If I use the doall, it runs out of heap at 1e7. I'm a little
surprised that they're different - I figured apply would instantiate
the sequence, and I'd need to use reduce instead of apply for really
large sequences.

   mike
-- 
Mike Meyer m...@mired.org 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: Incorrect behaviour for large s-expressions :(

2010-11-14 Thread Mike Meyer
On Sun, 14 Nov 2010 08:43:11 -0500
Robert McIntyre r...@mit.edu wrote:
 @Mike Meyer
 Using apply is different than what I'm doing.

Yup.

 When I use eval I'm trying to evaluate a huge s-expression.
 When you use apply you're evaluating a s-expression with three
 elements. Same thing with the count form (except with two elements).
 The problem isn't because I'm calling eval or not using idiomatic
 clojure; I just wrote it that way so it would only take one line.

I did agree that there was a problem.

The thing is, quasiquotes in clojure were designed for use in macros,
and using them outside macros sometimes generates weird results: I
wanted to make sure that wasn't the case here. My first attempt - in
idiomatic clojure - didn't recreate it. So I went a bit further afield
to do so.

 Are we really OK with having a 30 year old (Common Lisp/Lisp Machine)
 that operates at megahertz speeds do better than (clojure/JVM) here?

Yes, I'm OK that a LISP running on an architecture that's the end
result of decades of research on creating machines that run LISP well
has fewer and/or higher limits than a LISP running on a VM designed to
run Java.

I'm not even sure it's worth any effort in fixing. You're not going to
run into this limit except in machine-generated code, and there's an
easy work-around: generate (apply fun (sequence)) instead of (fun
sequence).

 mike
-- 
Mike Meyer m...@mired.org 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


Clojure vs. serial ports

2010-11-09 Thread Mike Meyer
I'm working on a clojure web app that manipulates the serial
port. Well, uses it, anyway. The basic structure is to create a map
from web-visible names to devices accessible via the serial ports. The
problem is that Clojure and the serial port drivers don't seem to get
along very well.

I'm using the RXTX package (with class names in the gnu.io. hierarchy).

If I open the serial port as part of building up my maps, everything
works fine in testing, but trying to compile the uberwar hangs.

If I wrap the port opening and connection calls in a delay and then
force them when I actually need to use it, the first call fails to do
anything - seems like the .open returns before the port is actually
ready.

Similarly, if I restructure things to open the port before use and
close it afterward, nothing ever happens at all. It's been a while
since I tried this, and I thought at the time the problem was that I
was closing the port to soon; but looking at it now I see that the
open may be failing.

When I try running multiple actions through the port in a loop, only
the first one actually happens.

Yes, I realize only the first of these is really related to Clojure
per se, but figured I'd put them all out on the chance that anyone who
could help with the first one is probably familiar enough with the
RXTX or serial port IO in Java to help with all of them.

 Thanks,
 mike
-- 
Mike Meyer m...@mired.org 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: could clojure be androids joker card

2010-11-07 Thread Mike Meyer
On Sun, 7 Nov 2010 12:42:09 +0100
Jacek Laskowski ja...@laskowski.net.pl wrote:

 On Sun, Nov 7, 2010 at 10:10 AM, Santosh Rajan santra...@gmail.com wrote:
 
  I would really like to see Clojure work on android the same way.
 
 Hi,
 
 I can hardly explain it myself and that's why I'm asking others
 whenever I stumble upon such a statement. Bear with my ignorance. I'm
 simply curious.
 
 Why is that important to you? I believe you can use Clojure as a Java
 library right now without much worries, can't you? Is merely Clojure's
 syntax so appealing?

No, its more having a REPL available, so that you can:

1) It makes a nice programmable calculator for mobile devices.

2) I can test out an idea when I have it, rather than having to make a
   note of it and test it when I'm back at my desk.

3) I can answer mail asking questions about clojure and provided
   checked answers while on the go, rather than wait until I'm back at
   my desk.

4) I can do development on all aspects of a clojure application that's
   going to run on android on the device.

And of course:

5) Java is that unappealing.

Admittedly, there are other good solutions for some of these, and
others you'd only want to do under extreme conditions - or with an
android tablet - but still, they do add up.

mike
-- 
Mike Meyer m...@mired.org 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: From jetty to war?

2010-11-05 Thread Mike Meyer
On Fri, 5 Nov 2010 13:42:44 -0700
Sean Corfield seancorfi...@gmail.com wrote:

 On Fri, Nov 5, 2010 at 12:41 PM, Michael Ossareh ossa...@gmail.com wrote:
  I've regularly found that the multi-disciplinarian programmer is far more
  adept at solving issues in a creative manner than the I've a skilled hammer
  and I'll wield it in the direction of any nail-mono-linguistic programmer.
  Perhaps that is just an artifact of working in startups though.
 
 Possibly.

His comment is generally true, at least so long as the languages are
really different. The obvious solution in one language may be
non-obvious in a second, but have advantages over the obvious solution
in the second language. A programmer skilled in both languages is more
likely to see that creative solution than one who only knows the
second language.

 I've worked in a variety of organizations from small
 startups to large corporations (such as insurance companies). In the
 smaller companies, developers have to wear more hats and it's common
 for a web developer to know HTML, JavaScript, SQL, **insert scripting
 language** and often shell scripts and / or other tools to help
 automate tasks. I don't see much difference between that and **insert
 multiple languages**.

This affect only works if the languages are sufficiently different to
have different obvious solutions for a large number of problems.
This is why people recommend learning a LISP even if you'll never use
it - it will expand the way you look at problems. In your case, you
have a markup language instead of a programming language, a database
language, and a handful of scripting languages. Depending on the
scripting languages, that's more like an expert in C++, C# and Java -
basically three iterations of the same language - than an expert in
(for example) C, Python, and Scheme.

When it comes to multi-language projects, if you project is all
Python, then someone who knows C/Python/Scheme and someone who knows
Java/Python/Clojure are probably equivalent candidates. If your
project is Java/Python, then the second one would be a good fit, and
the first somewhat questionable (at the very least, they'll need time
to come up to speed on Java). So even if you restrict yourself to
multilingual programmers, multiple implementation languages cuts down
on the pool of qualified people.

   mike
-- 
Mike Meyer m...@mired.org 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: Some questions about Clojure Protocols

2010-11-04 Thread Mike Meyer
On Thu, 4 Nov 2010 00:50:35 -0700
Paul Hobbs paul_ho...@hmc.edu wrote:

 Strong type systems make programming in the large easier. 


Paul,

Strong typing has so many definitions that your statement is nearly
meaningless. See http://www.wordiq.com/definition/Strong_typing for a
few.

Now, if you have some prove that's not just anecdotal, I'd be
interested in hearing. Likewise if someone has prove of the contrary.

   Thanks,
   mike
-- 
Mike Meyer m...@mired.org 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: Python is way faster than Clojure on this task

2010-11-04 Thread Mike Meyer
On Thu, 4 Nov 2010 22:28:12 +0100
Pepijn de Vos pepijnde...@gmail.com wrote:

 Hi all,
 
 I have written a Python script to analyze Minecraft levels and render a 
 graph. Then I did the same with Clojure. It takes Python 10 seconds to 
 analyze a map, while it takes Clojure over a minute.
 
 After having tried different options without any significant improvement, I 
 am lost as to why there is such a huge difference. I wouldn't mind an extra 
 pair of eyes/brains to look at this.
 
 I blogged about it in more detail here: 
 http://pepijndevos.nl/clojure-versus-python
 Clojure version: https://github.com/pepijndevos/Clomian/
 Python version: https://github.com/l0b0/mian
 
 Clojure spends most of its time in the freqs function, here are a couple of 
 variations: https://gist.github.com/663096
 
 If you want to run the code yourself, you'll need a Minecraft level and JNBT, 
 which is not on Maven.
 JNBT: http://jnbt.sourceforge.net/
 The level used in the blogpost: http://dl.dropbox.com/u/10094764/World2.zip

Can you check GC activity in the clojure version?

I once ran into an issue where Python was running rings around an
Eiffel version (compiled down to native code - no VM need apply). This
looks similar to what you have, in that I built a large data
structure, and then started groveling over it. Turned out that Eiffel
was doing a mark-and-sweep GC, which was spending all of it's time
marking and sweeping the large static data structure, whereas python
doing a reference count GC didn't. Given that I know nothing about
Java GCs, this is just a WAG.

Come to think of it, how about trying to run the program Jython? That
should have the same GC issues. If it's some similar environmental
problem, that would show up there as well.

 mike
-- 
Mike Meyer m...@mired.org 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


Polymorphic protocols and containers....

2010-11-04 Thread Mike Meyer
It seems like the polymorphism of protocols breaks inside the
methods. This is a problem for having a function that's polymorphic
between an object and a container of the same objects.

For instance:

user= (defprotocol Tune (tweek [this]))
Tune
user= (deftype Knob [name] Tune (tweek [this] (println Tweeked name)))
user.Knob
user= (def base (Knob. base))
#'user/base
user= (tweek base)
Tweeked base
nil
user= (def treble (Knob. treble))
#'user/treble
user= (tweek treble)
Tweeked treble
nil
user= (deftype Box [ knobs] Tune (tweek [this] (for [knob knobs] (tweek 
knob
user.Box
user= (tweek (Box. base treble))
user= (tweek (Box. base treble))
java.lang.IllegalArgumentException: Don't know how to create ISeq from: 
user.Knob
(user= 

Where what I really want to happen is to tweek all the knobs in the
box. Unfortunately, tweek inside the method seems to be wired to the
method it's in, and no longer polymorphic. I've tried various ways to
get to the variable I want, and some hinting, but nothing seems to
change what I'm getting here.

Maybe I shouldn't be trying to use protocols and types for this? Can
someone let me know what I need to do to make this happen?

Thanks,
mike
-- 
Mike Meyer m...@mired.org 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: From jetty to war?

2010-11-03 Thread Mike Meyer
Sean Corfield seancorfi...@gmail.com wrote ..
 Why are folks so insistent on monolingual systems?

We're facing that now, and with a mono-lingual system, you know
everyone can contribute to any part of the project. If different parts
are in different languages, then people working in one area won't
necessarily be able to help with other parts should they need the
help.

Of course, what you're calling insistent is just people wanting to
the frameworks to exist so they *can* do that, not really insisting
that some current system be monolingual in spite of that lack. Even
the above (admittedly minor) advantage to monolingual systems is
enough to justify wanting those frameworks even while you're building
multilingual systems.

 mike
-- 
Mike Meyer m...@mired.org 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: From jetty to war?

2010-11-03 Thread Mike Meyer
On Wed, 3 Nov 2010 16:26:13 -0700
Sean Corfield seancorfi...@gmail.com wrote:

 On Wed, Nov 3, 2010 at 3:31 PM, Mike Meyer
 mwm-keyword-googlegroups.620...@mired.org wrote:
  We're facing that now, and with a mono-lingual system, you know
  everyone can contribute to any part of the project. If different parts
  are in different languages, then people working in one area won't
  necessarily be able to help with other parts should they need the
  help.
 Solution: don't have monolingual programmers on your team :)

What, we shouldn't hire Americans? :-)

That only helps if everyone actually knows all the languages involved
(we're looking at Ruby, Python and I'm trying to make a case for
Clojure - but the critical language for my part of it is going to be
XPath and/or XQuery).

Finding good people is hard enough that wanting them to be good in
three or four languages is enough to break the camels back. If you've
got time to cross-train them - then you don't need

 I do understand the forces at play here. I've worked with a lot of
 monolingual teams and seen these same discussions about wishing we had
 framework X from language Y. I just cringe at the work invested in
 recreating all these frameworks in so many languages - especially when
 we're (nearly) all on the same JVM and we _could_ leverage these other
 languages / frameworks as-is. It just seems like so much wasted effort

Except (in least in this case) some of the languages aren't on the
JVM. In fact, I'm starting to get pressure against Jython and Clojure
because of the legal mess that's starting to embroil the Java
world. Way off topic, but anyone got any advice on *that*?

   mike
-- 
Mike Meyer m...@mired.org 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: A question regarding map destructuring

2010-11-02 Thread Mike Meyer
On Mon, 1 Nov 2010 23:41:47 -0700 (PDT)
Meikel Brandmeyer m...@kotka.de wrote:

 Hi,
 
 On 2 Nov., 03:25, Mike K mbk.li...@gmail.com wrote:
 
  (print-value-a [:b 7 :a 3])
  ; actually prints nil
 
 You have to use apply. (apply print-value-a [:b 7 :a 3]).
 
 Furthermore: how could (let [{a :a} [:b 7 :a 3]] [a]) possibly work?

The same way this one works:

 (defn foo [ {:keys [a b]}] ...)
 
 is equivalent to
 
 (defn foo [ options#] (let [{:keys [a b]} (apply hash-map
 options#)] ...))

This only happens if the rest argument destructuring is a hash map -
if I use a vector or a symbol there, then the values don't get turned
into a map. Can't that same mechanism be used in the case where some
non-rest argument is a hash-map trying to destructure a sequence?
So that:

(let [{a :a} [:b 7 :a 3]] ...)

would be equivalent to

(let [x# [:b 7 :a 3]] (let [{a :a} (apply hash-map x#)] ...)

 user= (let [{a :a} [:b 7 :a 3]] [a])
 [nil]
 user= (let [{a 2} [:b 7 :a 3]] [a])
 [:a]
 
 The map destructuring in the defn is a special case of defn, not
 destructuring itself.

Interesting. This means you can't use your second example to
destructure a rest argument:

user= ((fn [ {a 2}] [a]) :b 7 :a 3)
[nil]

But that's the same behavior as you got with 1.1. But this case:

user= ((fn [ {a 2}] [a]) 1 7 2 3)
[3] ;; 1.2 behavior; 1.1 returns [nil]

Changed between 1.1 and 1.2.

As much as I hate special cases when they aren't needed, I'm not
arguing that this should change. Handling rest arguments that way is
very useful. It's not at all clear there's a use for doing this
anywhere case, other than to scratch that consistency itch.

mike
-- 
Mike Meyer m...@mired.org 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


From jetty to war?

2010-11-01 Thread Mike Meyer
Ok, I've got a simple web application that works running on embedded
jetty using the ring jetty adapter. I would now like to deploy it in
an infrastructure that will restart it if it dies, the system reboots,
etc. I've already got tomcat doing most of that, so the obvious choice
is a WAR file. Trouble is, trying the obvious thing from the
documentation doesn't work. The examples I find on the web all either
fail the same way, don't build (given that this is all new and still
rapidly evolving software, understandable), or involve using another
level of software. I chose ring because it looked like I could use
ring handlers in a number of different web servers without that extra
level.

Ok, this is the working serlvet.clj file: It picks up the handler from
x10.core, and then runs that:

(ns x10.servlet 
  [:use [x10.core :only (handler)] 
ring.adapter.jetty
ring.middleware.reload ring.middleware.stacktrace])
  
(def app
 (- #'handler
 (wrap-reload '(x10.core))
 (wrap-stacktrace)))

(defn boot [] (run-jetty #'app {:port 8088}))

The goal is to get the same handler running in a server framework.
I'm trying tomcat via a WAR file: based on the ring documentation, I
added war.clj (this is just the latest variant):

(ns x10.war
  [:use [x10.core :only (handler)] 
ring.util.servlet])
  
(defservice handler)

Then added ring/ring-servlet to the project.clj :dependencies, an
:aout pointing x10.war, and build it using leiningen-war. Deploying
the resulting war file gets tomcat log messages about not being able
to create a SESSIONS.ser file, and a web page complaining that The
requested resource (/x10/) is not available.

I did try building/deploying the compjure war example, and that at
least shows me the static page, so I believe the tomcat install is
correct.

Anyone got pointers to how to generate a WAR file for a simple
application, or suggestions on how to fix war.clj? Anything else you
might need to see to fix this?

Alternatively, instructions for deploying the same handler on either a
stand-alone (instead of an embedded) jetty, or on httpcore?

   Thanks
   mike
-- 
Mike Meyer m...@mired.org 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: A question regarding map destructuring

2010-11-01 Thread Mike Meyer
On Mon, 1 Nov 2010 19:25:59 -0700 (PDT)
Mike K mbk.li...@gmail.com wrote:

 This question is a bit abstruse, so please bear with me :-)
[elided]
 So this can't be how it works, but I don't know how else to interpret
 the documentation.  Is this a special case meaning if there are
 optional arguments AND they are to be destructured via a map, then
 insert them pairwise into a map instead of a vector? Or does this
 behavior fall directly out of the destructuring rules without a
 special case based on something I'm missing?

My gut reaction is that you found a bug. This behavior was added in
1.2, as noted in the change log:

== 2.3 Destructuring Enhanced ==

If you associatively destructure a seq, it will be poured into a map first:

  (defn foo [ {:keys [a b c]}]
[a b c])

  (foo :c 3 :b 2)
  = [nil 2 3]

I don't see anything about optional arguments there, just that using
a map to destructure a sequence should cause it to be converted to a
map. Which to me means your second (failing) example ought to work, so
that:

user= (let [{a :a} [:a 2 :b 3]] [a])
[nil]

should return [2], not [nil]. Unfortunately, the doc at
http://clojure.org/special_forms on bindings doesn't cover this
case. Given that the doc I did found was a change log, I wouldn't put
to much credence on it - those generally aren't definitive. But I'd
like to see a definitive answer as well.

   mike
-- 
Mike Meyer m...@mired.org 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: Can't locate str_utils in classpath

2010-10-31 Thread Mike Meyer
On Sun, 31 Oct 2010 00:09:31 -0700 (PDT)
Steven Arnold thoth.amon.i...@gmail.com wrote:

 That was it.  I had to add the entire path up to and including to
 contrib jar in order for clj to work.  Merely adding the directory
 to the classpath was not sufficient, and the clj script ignored the
 value of my env variable $CLASSPATH, so I had to edit the clj script
 itself to get this working.

Hi Steve,

You ought to be able to add path/to/directory/\* to your CLASSPATH
to pick up all the jars in the directory. The * needs to be quoted
to show up in the variable, and not expanded by the shell.  This works
on Unix and Windows, so it ought to work on OSX.

If you're interested in how to work with clojure with minimal Java
infrastructure, I posted my writeup at
http://www.mired.org/home/mwm/papers/simple-clojure.html

mike

-- 
Mike Meyer m...@mired.org 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: to macro or not?

2010-10-28 Thread Mike Meyer
On Thu, 28 Oct 2010 12:55:55 -0700
Raoul Duke rao...@gmail.com wrote:

 hi,
 
 not looking to stir up a pot, looking to learn from people's
 experience. i've heard that in CL land, one is told to avoid macros as
 long as possible. i've heard other folks in the Clojure world say that
 if you aren't using macros, then sorta why bother use a Lisp since you
 are missing out on one of the most powerful differentiators. then
 reading about Conj it sounds like some folks say stay away from macros
 if you can.

Actually, these aren't really contradictory views. Macros are a
powerful feature, and tend to be noted as the thing that sets LISPs
apart from other languages. When you need them, nothing else will do
the job. But they have downsides. For instance, they aren't a
function, so aren't suitable to use as arguments to higher-order
functions (another big part of LISP). So if you can do the job with a
function, use a function instead.

 any way of teasing out when macros are ok? :-) i mean, are they only
 ok for the internals of the Clojure system?

Last time it came up, there were three basic reasons given:

1) You need to control how many times an argument is evaluated.
   Commonly, either not at all or once, but possibly more than
   once.

2) Moving what you can of the computation into the compilation
   phase. This is a performance hack, so you should be converting
   functions to macros here.

3) You need it to get the API syntax you want (most commonly, a DSL).

 mike
-- 
Mike Meyer m...@mired.org 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: to macro or not?

2010-10-28 Thread Mike Meyer
On Fri, 29 Oct 2010 06:30:27 +0530
Santosh Rajan santra...@gmail.com wrote:

 On Fri, Oct 29, 2010 at 1:58 AM, Mike Meyer 
 mwm-keyword-googlegroups.620...@mired.org
  3) You need it to get the API syntax you want (most commonly, a DSL).
 This last point is what I consider the most powerful feature of any
 language. And thats what makes Lispy languages a class apart. Use a macro
 where ever a particular type of problem, or solution to it, can be expressed
 more clearly using a macro, and the type of problem reappears more than
 once.

I disagree - but I'm a big fan of code that writes code (this would be
the second case - moving computations into the compiler). Computers
are a multiplier, in that they multiply the number computations (for
a loose definition of computation) that a single human can do by many
orders of magnitude. Macros (or code that writes code) make writing
code become the computation being multiplied.

LISP macros are the most effective way I know of writing code that
writes code. The alternatives involve multiple languages, or writing
files that are then fed back to the language processor.

 mike
-- 
Mike Meyer m...@mired.org 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: to macro or not?

2010-10-28 Thread Mike Meyer
On Thu, 28 Oct 2010 18:12:39 -0700 (PDT)
andrei andrei.zhabin...@gmail.com wrote:

 
 I'll try to extend Mike's answer by one more example. Consider `and`
 Lisp macro. It is not a function, because it must evaluate it's
 arguments lazily, and using macros is the only way to do it.

Actually, this is the first case, and a classic example of it: you
need to control how many times the arguments are evaluated.

 But try
 to apply `and` to the list of values (I know, that it's a job for a
 function `every?`, but how will you implement this function itself?):
 
 (apply and (list true true false true))   == error

And this is the issue of not being able to pass macros to higher order
functions.

 You cannot do it, since and is not a function. So, you need to use
 wrapper around `and`:
 
 (reduce #(and %1 %2) (list true true false true))  == false
 
 And this is still not the perfect solution, since it is not lazy.
 
 So you can see both advantages and disadvantages of using macros.

Which is why you only want to use them when you have to. If you don't
need the advantages, why put up with the disadvantages?

 mike
-- 
Mike Meyer m...@mired.org 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: Improving Contrib

2010-10-20 Thread Mike Meyer
On Wed, 20 Oct 2010 09:59:26 -0600
Eric Schulte schulte.e...@gmail.com wrote:

 Mike Meyer mwm-keyword-googlegroups.620...@mired.org writes:
 
  It was also more work than submitting patches looks to be for apache,
  django, gnu
 
 FWIW in gnu projects if your patch is 10 lines long then they do
 require you to go through a fairly lengthy attribution process.
 
 http://www.gnu.org/prep/maintain/html_node/Copyright-Papers.html

Two things. First, the limit is around 15 lines of code, excluding
repeated changes, and it applies over all patches, not just one:
http://www.gnu.org/prep/maintain/html_node/Legally-Significant.html

More importantly, this doesn't happen until *after* the patch has been
submitted and a contributor decides it should be included. Putting
roadblocks in front of people who want to submit patches or bugs - and
not being able to update the bug database qualifies, since you can't
report on the results of suggested fixes or at the very least add
another case to the existing ticket without a developer having to
notice the duplicate and flag it - is a bad idea.

Again, maybe it's possible to submit bugs to assembla without the CA;
but finding the assembla tickets list itself requires wading past the
verbiage about the CA. If bug reports (with or without patches)
doesn't require a CA, then it should be a lot easier to find.

mike
-- 
Mike Meyer m...@mired.org 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: getting started with clojure

2010-10-20 Thread Mike Meyer
On Wed, 20 Oct 2010 18:04:17 -0400
Eric Lavigne lavigne.e...@gmail.com wrote:

 The short answer is that it's okay to use Clojure directly. You don't
 need Leiningen.
 
 If you are familiar with C programming, the difference between the
 Clojure compiler and Leiningen is like the difference between GCC and
 Make. Using the compiler directly is fine when you have only one file
 of source code and aren't using any libraries. Using the compiler
 directly is still possible with larger projects, but it can get
 tedious. Then it is useful to have a build tool that makes it easier
 to perform an operation on the project as a whole, rather than on
 individual files.

I wrote up a guide to using clojure without having to deal with
Leiningen and other elements that seem to come from the Java
infrastructure. You can find it at
http://www.mired.org/home/mwm/papers/simple-clojure.html

mike
-- 
Mike Meyer m...@mired.org 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: Improving Contrib

2010-10-19 Thread Mike Meyer
On Tue, 19 Oct 2010 16:26:24 -0700 (PDT)
Rich Hickey richhic...@gmail.com wrote:

 
 
 On Oct 19, 7:01 pm, Mike Meyer mwm-keyword-googlegroups.
 620...@mired.org wrote:
  On Tue, 19 Oct 2010 15:51:17 -0700 (PDT)
 
  Mibu mibu.cloj...@gmail.com wrote:
   The greatest impediment for me is having to sign a contract to
   participate in an open source project. I understand Rich Hickey and
   most of you guys live in the litigious US and have to cover
   yourselves, but I feel not right about this.
 
  I've never run into a project - US-based or not - that required
  this.
 
 http://www.apache.org/licenses/
 http://openjdk.java.net/contribute/
 http://forge.mysql.com/wiki/Contributing_Code
 https://fedoraproject.org/wiki/Legal:Revised_Fedora_CLA_Draft#FPCA_Text
 http://contributing.openoffice.org/programming.html
 http://www.gnu.org/licenses/gpl-faq.html#AssignCopyright
 http://framework.zend.com/wiki/display/ZFPROP/Contributor+License+Agreement
 http://www.djangoproject.com/foundation/cla/faq/
 http://nodejs.org/cla.html
 http://www.10gen.com/contributor

The ones I've checked or am familiar with apparently define
contribute differently than the clojure project does, in that they
allow you to both subscribe to the developer list(s) and submit bug
reports - including patches - without having to sign and post a
contributor agreement.  Or maybe it's the clojure web site making
things difficult to find.

Nuts, I happened to apply for my Chickasaw Nation citizenship today -
which gives me tribal voting rights, free health care at tribal
hospitals and clinics, the ability to get grants for education,
housing, free laptops, etc, etc, etc. That was less work than being
allowed to submit a bug to the issue tracking system for clojure
(unless I just didn't find the right page).

It was also more work than submitting patches looks to be for apache,
django, gnu, fedora, or openoffice (from your list, though it sounds
like openoffice may changed for the worse) or I know to be for
FreeBSD, PostreSQL, OpenSolaris, Python, Cheetah, to name some I've
been using for a while.

Sure, many of them require you to create an account to submit any bug
report. But that's straightforward, and a not unreasonable anti-spam
measure. Some even require you to click a checkbox assigning the
rights to anything you submit to the project in question as part of
that process. But I can still contribute patches to these projects
without having to print, sign and post any kind of developer
agreement.

mike
-- 
Mike Meyer m...@mired.org 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: Pros and cons of macro versus functions

2010-10-18 Thread Mike Meyer
On Mon, 18 Oct 2010 08:58:48 -0400 (EDT)
lprefonta...@softaddicts.ca wrote:
 Choose functions over macros when you can write an equivalent function.

From the LISP community, I'd put it slightly stronger: Only use macros
when you have to. But you get the same set of reasons (with
explanations).

 I use macros when:
 
 a) I have a repetitive pattern in the code that cannot be easily turned
into a function (too much context to pass as args to a function).
You can then hide a binding form in the macro to refer to the context
or directly refer to it (global vars, ...) using form expansion.
You can wrap huge chunks of your code in the macro referring to the context
(  body) easily.

If I understand you correctly, these would be non-hygienic
macros. Yeah, those are pretty much have to.

 b) I need to evaluate the args (aka the symbols) to alter the form(s)
generated by the macro and do not want immediate evaluation.

And much of the time, this is because you're not sure you want to
evaluate the form at all, or may want to evaluate it more than
once. Again, a have to situation.

 c) I need a lighter syntax. You can marshall the symbols themselves as you 
wish to refer to other context bindings by sufixing/prefixing the synbol
names.
 
I wrote an interactive report utility used by non-lispers and that helped
remove some Clojure syntax requirements that would look obscur
to non-Lispers. The report utility can refer to global bindings while
the user uses nicknames and other syntatic sugars to simplify the calls.
This hides references to the context that would clutter the report code
and make the tool unusable for the average user.

In other words, building DSL's. This is a qualified have to: have
to to meet user requirements.

 d) I see some potential in tuning the forms later (maybe to create functions)
but do not want to embark on that journey now. Using macros you can defer
retooling of your code or hide partial retooling until you are ready
to change the top form to its definitive look.

General performance reasons? Yeah. In particular, if you can replace
run-time decisions with compile time-decisions (loop unrolling, etc.)
you can win quite a bit here. Another qualifed have to: have to to
meet performance requirements.

 mike
-- 
Mike Meyer m...@mired.org 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: precise numbers

2010-10-13 Thread Mike Meyer
On Thu, 14 Oct 2010 00:27:39 +0200
Felix H. Dahlke f...@ubercode.de wrote:

 On 13/10/10 22:28, David Sletten wrote:
  
  On Oct 12, 2010, at 5:44 PM, Brian Hurt wrote:
  
For example, in base 10, 1/3 * 3 = 0.9...  
  
  It may seem counterintuitive, but that statement is perfectly true.
  1 = 0....
  
  That's a good test of how well you understand infinity.
 
 I'm clearly not a mathematician, but doesn't 0.9... asymptotically
 approach 1, i.e. never reaching it? How is that the same as 1?

This representation implies the sum of the series (iterate #(/ % 10)
9/10), and that sum behaves as you say. However, since the series is
infinite, you can prove that the number it represents is actually
equal to one, like so:

1) a = 0.999... # define a as 0.999...
2) 10a = 9.999...   # multiply both sides by 10
3) 10a - a = 9.999... - 0.999...# subtract equation 1 from equation 2
4) 9a = 9   # simplify
5) a = 1# divide both sides by 9.

The subtraction step doesn't work unless the sequence is infinite, if
a is any finite sequence of 9s, you'll get a number whose decimal
representation is matches the re 8\.(9)*1. This relies on the property
that adding 1 to an infinite number gives you back the same infinite
number, so that:

(= (rest (map #(* % 10) (iterate #(/ % 10) 9/10)))
   (iterate #(/ % 10) 9/10))

is true, but I don't recommend typing that into a repl to check it!

Hmm. I wonder if you could represent irrationals as lazy sequences,
and do arithmetic on those?

   mike
-- 
Mike Meyer m...@mired.org 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: precise numbers

2010-10-12 Thread Mike Meyer
On Tue, 12 Oct 2010 12:35:24 -0700 (PDT)
cej38 junkerme...@gmail.com wrote:

 The more that I think about it, the more I would rather have a set of
 equalities that always work.  float= was a good try.

Then you can't use floats.

As others have explained, floats are imprecise by nature, being
limited to finite binary fractions. To make matters worse, you don't
input the numbers in binary, but in decimal, which means most of the
fractions you can input can't be represented as a float - so you get
an approximation. Given that the numbers are fuzzy, the concept of
equality also becomes fuzzy - whether two numbers are equal will
depend on the context. So you have to choose the equality that's
appropriate for the context.

If you want precise numbers, Clojure has three options:

1) If you can represent everything as integers, then BigInteger is
probably the easiest to use, with the obvious drawback that it can't
handle fractional values, nor can it represent as large a value as a
float since you run out of memory. Letting units represent 1/1000's:

user (- 123050 123049)
1


2) If you're going to stay in the world of decimal fractions, use
BigDecimal. This has some of the problems of floats, but between
allowing arbitrary precision and the input representation matching the
internal representation, they're not nearly as obnoxious.

user (- 12.305M 12.3049M)
0.0001M


3) Clojure's rationals let you represent all rational values, until
you run out of memory. If you want a decimal approximation after the
calculation is done, that's easy to get as well:

user (- 12305/1000 123049/1)
1/1
user (float (- 12305/1000 123049/1))
1.0E-4

mike
-- 
Mike Meyer m...@mired.org 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


  1   2   3   >