Re: Clojure-in-CommonLisp?

2011-11-16 Thread Konrad Hinsen
On 15 nov. 2011, at 17:00, David Nolen wrote:

 Integrating with C / C++ is also possible with ClojureScript + (V8 or 
 Node.js) as well.

I never looked at those options. Is it possible to manipulate C/C++ data 
directly from ClojureScript, without bulky wrapper objects? That's what I care 
most about. I'd have to be able to iterate over a huge C array (say, 500 MB of 
floats) without converting that array to some high-level sequence object first, 
and ideally feeding each float to a Clojure function compiled to something that 
processes C floats, rather than converting each float to some high-level object.

Konrad.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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-in-CommonLisp?

2011-11-16 Thread Konrad Hinsen
On 15 nov. 2011, at 18:21, Marshall T. Vandegrift wrote:

 Integrating the JVM with C via JNA [1] is pretty straightforward.  I've
 been doing all my JNA glue in Java so far because JNA depends on a few
 features which aren't available / convenient use in Clojure [2], but a
 decent Clojure wrapper API probably wouldn't be too difficult.

It's not too hard for the programmer, but

1) it is often impossible to avoid copying data and

2) deployment for the user becomes much more difficult than pure JVM or pure 
native code.

Konrad.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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-in-CommonLisp?

2011-11-16 Thread Konrad Hinsen
On 15 nov. 2011, at 17:17, Roy Lowrance wrote:

 What not create a C implementation in which the hosted language is dynamic 
 link libraries? 

Fine with me, but that sounds like a huge effort.

Konrad.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Overused phrases in the Clojure community

2011-11-16 Thread Colin Yates
I am not sure if the OP was serious or not, but I think the desire to do
things idiomatically is just one indicator of the quality of this
community.  I am encouraged, and challenged to learn how to use Clojure
rather than bash Clojure to fit the holes/shapes I think I have.

soapboxToo many times I see (and admittedly do) google-paste coding
where developers need to get something done, so google it, copy the
relevant fragment and shove it in their code without any appreciation for
what it does or whether it is the right way./soapbox

Including the word idiomatic in your post is er, well, er, idiomatic
posting to the Clojure group :)  (grammar not withstanding)

On 16 November 2011 07:01, Ben Smith-Mannschott bsmith.o...@gmail.comwrote:

 On Wed, Nov 16, 2011 at 02:16, thenwithexpandedwingshesteershisflight
 mathn...@gmail.com wrote:
  Can we please get bored of saying idiomatic and in particular
  please ?

 It's quite useful to be able to talk about

 the-way-of-expressing-this-concept-most-in-keeping-with-established-practice
 (idiomatic), particularly when a language still sees plenty of
 newcomers.

 The Python community, found a way around the problem you seem to be
 having by inventing their own word: pythonic. Do I hear any votes for
 clojuresque?

 Ok, I think I've spent my smart-a$$ quota for the day,

 Ben

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


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

clj-time and clojure 1.3

2011-11-16 Thread Brad
Just curious what happened with getwoven and clj-time.

It seems that Sean has updated clj-time over on Clojars and this
version works fine under 1.3.

If you search on clj-time though you get links to a getwoven project.
https://github.com/getwoven/clj-time/ with 404s. This is the one I
originally used. Now when I search github I see 
https://github.com/KirinDave/clj-time.

Just wondering what is happening and where the appropriate project is?

-- 
You 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-in-CommonLisp?

2011-11-16 Thread Alessio Stalla
On 15 Nov, 16:58, Konrad Hinsen googlegro...@khinsen.fastmail.net
wrote:
 On 15 Nov, 2011, at 15:46 , Doug South wrote:

  I know a little CL and even less of Clojure, but wouldn't Clojure in CL be 
  fairly trivial? Just a DSL in CL?

 All of Clojure's persistent data structures would have to be implemented in 
 CL. Plus multimethods, protocols, and deftype, which are a bit different from 
 their closest equivalents in CL.

For some of the data structures, it might be possible to leverage the
FSet library by Scott Burson, which provides persistent seqs, sets,
and maps.
The closest way to multimethods requires hacking the CLOS
implementation, but in my opinion it's not hard to do (I know I'll
write a blog post someday about my thoughts on this...), though
maintaining all the caches that are in effect for class-based dispatch
is not feasible in general for other types of dispatch. Certainly,
though, this would step out of portable Common Lisp. The alternative
is to effectively reimplement a part of CLOS in an incompatible way...
Protocols and deftype I do not know... also there's the issue of
arithmetic in 1.3+ which has different semantics than CL, different
calling conventions... it would be more than just a DSL over CL, I
fear.

Alessio

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


adding metadata to java objects

2011-11-16 Thread Ben Mabey

Hi,
I would like to be able to add metadata to arbitrary java objects that 
have already been instantiated.  I know that you can use proxy to add 
metadata to objects that you create but in my case the object already 
exists (i.e. it is returned from another method call outside of my control).


It seems like the best solution would be to create a delegate 
class/object that wraps the original one.  Being able to write something 
like this would be ideal:


(defn wrap-with-meta
  ([obj]
 (wrap-with-meta obj nil))
  ([obj meta]
   (delegate obj
 clojure.lang.IObj
 (withMeta [this new-meta] (wrap-with-meta 
obj  
new-meta))

 (meta [this] meta

The delegate function would operate very similar to proxy, but instead 
of taking a class it takes an object.  A class would be created that 
extends the object's class, just like a class is generated for proxy. 
However, instead of stubs being generated that call super the stubs 
would delegate to the given object.  (Also note, I am also using 
reify-like syntax since I prefer that to the syntax in proxy.)


I'm curious to hear people's thoughts on this approach.  I'd also be 
really interested to see how other people have addressed this in the 
past (I doubt I'm the first one to run into this).


I know that clojure mentality is to avoid wrappers, but I don't see this 
as being much different than what proxy already does.  Of course, I may 
be missing something... if so, please enlighten me. :)


Thanks,
Ben

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


Incanter Hack Day, London, Sunday

2011-11-16 Thread Ben Evans
Hi,

There is an Incanter Hack Day taking place on Sunday at the Royal
Festival Hall in London. We'll be on the 5th floor, Green side.

The group will begin turning up at 1000, but feel free to come a bit
later if that's too early. We'll go for some lunch somewhere close by
on Southbank when everyone gets hungry, then come back for a few more
hours hacking in the afternoon. We tend to finish about 1600 or a bit
later.

It's very laid-back and informal, and we try to be accessible to
interested developers of all levels.

Feel free to bring Incanter tasks to hack on (but we always have a
stock of open tasks if people need something to work on).

These are regular, monthly events - every 3rd Sunday of the month.

Upcoming dates are:

20th November
18th December
15th January

Hope to see you on Sunday!

Thanks,

Ben

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


Using clojure.java.shell for long running tasks

2011-11-16 Thread Matthew Boston
How can I get clojure.java.shell/sh to print to stdout while running?
Currently, it waits until `sh` returns before I can access :out and
println it.

(:use clojure.java.shell)

(defn call-maven [ args]
  (apply sh mvn args))

(defn maven-version []
  (- -v call-maven :out println))

Thanks for you help!

-- 
You 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: adding metadata to java objects

2011-11-16 Thread Ben Smith-Mannschott
On Wed, Nov 16, 2011 at 17:28, Ben Mabey b...@benmabey.com wrote:
 Hi,
 I would like to be able to add metadata to arbitrary java objects that have
 already been instantiated.  I know that you can use proxy to add metadata to
 objects that you create but in my case the object already exists (i.e. it is
 returned from another method call outside of my control).

 It seems like the best solution would be to create a delegate class/object
 that wraps the original one.  Being able to write something like this would
 be ideal:

 (defn wrap-with-meta
  ([obj]
     (wrap-with-meta obj nil))
  ([obj meta]
   (delegate obj
             clojure.lang.IObj
             (withMeta [this new-meta] (wrap-with-meta obj


  new-meta))
             (meta [this] meta

 The delegate function would operate very similar to proxy, but instead of
 taking a class it takes an object.  A class would be created that extends
 the object's class, just like a class is generated for proxy. However,
 instead of stubs being generated that call super the stubs would delegate to
 the given object.  (Also note, I am also using reify-like syntax since I
 prefer that to the syntax in proxy.)

 I'm curious to hear people's thoughts on this approach.  I'd also be really
 interested to see how other people have addressed this in the past (I doubt
 I'm the first one to run into this).

 I know that clojure mentality is to avoid wrappers, but I don't see this as
 being much different than what proxy already does.  Of course, I may be
 missing something... if so, please enlighten me. :)

 Thanks,
 Ben

Here's an approach that may be of use: don't store the metadata in a
Map instead of decorating the Object with it. This map should use
object identity, not equality and should hold its keys weakly so that
it prevent collection of  objects that otherwise would be garbage.
Safe to use concurrently would also be a plus. Conveniently, Google's
Guava library provides such a thing. Here's a sketch:

== project.clj 

(defproject pojometa 0.0.1-SNAPSHOT
  :dependencies [[org.clojure/clojure 1.3.0]
 [com.google.guava/guava 10.0.1]])

== src/pojometa/core.clj ==

(ns pojometa.core
(:import [com.google.common.collect MapMaker]))

(def meta-map
(- (MapMaker.) .weakKeys .makeMap))

(defn meta* [o]
(if (instance? clojure.lang.IMeta o)
(clojure.core/meta o)
(.get meta-map o)))

(defn with-meta* [o m]
(if (instance? clojure.lang.IMeta o)
(clojure.core/with-meta o m)
(do (.put meta-map o m)
o)))

== usage ==

pojometa.core= (def o (Object.)) ;; arbitrary java object
pojometa.core= (meta* (with-meta* o {:foo true}))
{:foo true}

;; also does the right thing for Clojure types that
;; already know how to have metadata.

pojometa.core= (meta* (with-meta* {} {:bar 1}))
{:bar 1}

== END

Hope that helps,
Ben

-- 
You 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: Using clojure.java.shell for long running tasks

2011-11-16 Thread Phil Hagelberg
On Wed, Nov 16, 2011 at 11:48 AM, Matthew Boston
matthew.bos...@gmail.com wrote:
 How can I get clojure.java.shell/sh to print to stdout while running?
 Currently, it waits until `sh` returns before I can access :out and
 println it.

I actually had to stop using clojure.java.shell/sh for this and just
used Runtime/exec directly precisely for this reason:

https://github.com/technomancy/leiningen/blob/master/src/leiningen/compile.clj#L171

I could clean this up and submit it as a patch upstream if it's
desired. Though on the other hand, the raw Runtime calls are not
horribly cumbersome.

-Phil

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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


start-process-shell-command: Spawning child process: invalid argument

2011-11-16 Thread Andrew
Having trouble setting up Clojure/Emacs on Windows again. Earlier Mark 
Rathwell helped 
mehttps://groups.google.com/d/topic/leiningen/JpkUXTLqnrE/discussionby 
pointing out a 
recipe for Windows 
http://sourceforge.net/apps/wordpress/codesounding/2011/09/29/installing-emacs-24-and-clojure-mode-on-windows-7-step-by-step/that
 
resolved an issue with sh. After having the setup work for a while, I 
botched something while trying to upgrade clojure-mode. So I tried to start 
from scratch using the same 
recipehttp://sourceforge.net/apps/wordpress/codesounding/2011/09/29/installing-emacs-24-and-clojure-mode-on-windows-7-step-by-step/and
 now I see this when I try M-x clojure-jack-in

start-process-shell-command: Spawning child process: invalid argument

Other notes: 

   - The value of inferior-lisp-program is lein repl. 
   - If I start eshell and type lein repl, I see a repl start up. 
   - If I start eshell and type sh and answer the prompt with lein repl, I 
   also see a repl start up.
   - lein is in my windows path
   - c:/emacs and c:/emacs/bin are both in my path so sh.bat can be found
   - the swank-clojure 1.3.3 plugin is installed

How do I find out what the invalid argument is?

-- 
You 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: adding metadata to java objects

2011-11-16 Thread Alan Malloy
On Nov 16, 11:53 am, Ben Smith-Mannschott bsmith.o...@gmail.com
wrote:
 On Wed, Nov 16, 2011 at 17:28, Ben Mabey b...@benmabey.com wrote:
  Hi,
  I would like to be able to add metadata to arbitrary java objects that have
  already been instantiated.  I know that you can use proxy to add metadata to
  objects that you create but in my case the object already exists (i.e. it is
  returned from another method call outside of my control).

  It seems like the best solution would be to create a delegate class/object
  that wraps the original one.  Being able to write something like this would
  be ideal:

  (defn wrap-with-meta
   ([obj]
      (wrap-with-meta obj nil))
   ([obj meta]
    (delegate obj
              clojure.lang.IObj
              (withMeta [this new-meta] (wrap-with-meta obj

   new-meta))
              (meta [this] meta

  The delegate function would operate very similar to proxy, but instead of
  taking a class it takes an object.  A class would be created that extends
  the object's class, just like a class is generated for proxy. However,
  instead of stubs being generated that call super the stubs would delegate to
  the given object.  (Also note, I am also using reify-like syntax since I
  prefer that to the syntax in proxy.)

  I'm curious to hear people's thoughts on this approach.  I'd also be really
  interested to see how other people have addressed this in the past (I doubt
  I'm the first one to run into this).

  I know that clojure mentality is to avoid wrappers, but I don't see this as
  being much different than what proxy already does.  Of course, I may be
  missing something... if so, please enlighten me. :)

  Thanks,
  Ben

 Here's an approach that may be of use: don't store the metadata in a
 Map instead of decorating the Object with it. This map should use
 object identity, not equality and should hold its keys weakly so that
 it prevent collection of  objects that otherwise would be garbage.
 Safe to use concurrently would also be a plus. Conveniently, Google's
 Guava library provides such a thing. Here's a sketch:

 == project.clj 

 (defproject pojometa 0.0.1-SNAPSHOT
   :dependencies [[org.clojure/clojure 1.3.0]
                  [com.google.guava/guava 10.0.1]])

 == src/pojometa/core.clj ==

 (ns pojometa.core
     (:import [com.google.common.collect MapMaker]))

 (def meta-map
     (- (MapMaker.) .weakKeys .makeMap))

 (defn meta* [o]
     (if (instance? clojure.lang.IMeta o)
         (clojure.core/meta o)
         (.get meta-map o)))

 (defn with-meta* [o m]
     (if (instance? clojure.lang.IMeta o)
         (clojure.core/with-meta o m)
         (do (.put meta-map o m)
             o)))

 == usage ==

 pojometa.core= (def o (Object.)) ;; arbitrary java object
 pojometa.core= (meta* (with-meta* o {:foo true}))
 {:foo true}

 ;; also does the right thing for Clojure types that
 ;; already know how to have metadata.

 pojometa.core= (meta* (with-meta* {} {:bar 1}))
 {:bar 1}

(def o (Object.))

(def om (with-meta* o {:foo true}))

(def whatever (with-meta* o {:foo false}))

(meta* om) ;= {:foo false}

Doesn't really support Clojure's concept of metadata if it's shared
global mutable state.

-- 
You 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: Using clojure.java.shell for long running tasks

2011-11-16 Thread Matthew Boston
Thanks, Phil. Works like a charm!

BTW, I'm working on the lein-mvn plugin which allows the use of maven
plugins inside leiningen projects.

On Nov 16, 2:53 pm, Phil Hagelberg p...@hagelb.org wrote:
 On Wed, Nov 16, 2011 at 11:48 AM, Matthew Boston

 matthew.bos...@gmail.com wrote:
  How can I get clojure.java.shell/sh to print to stdout while running?
  Currently, it waits until `sh` returns before I can access :out and
  println it.

 I actually had to stop using clojure.java.shell/sh for this and just
 used Runtime/exec directly precisely for this reason:

 https://github.com/technomancy/leiningen/blob/master/src/leiningen/co...

 I could clean this up and submit it as a patch upstream if it's
 desired. Though on the other hand, the raw Runtime calls are not
 horribly cumbersome.

 -Phil

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Using clojure.java.shell for long running tasks

2011-11-16 Thread Phil Hagelberg
On Wed, Nov 16, 2011 at 1:59 PM, Matthew Boston
matthew.bos...@gmail.com wrote:
 Thanks, Phil. Works like a charm!

 BTW, I'm working on the lein-mvn plugin which allows the use of maven
 plugins inside leiningen projects.

Great; looking forward to it!

-Phil

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Incanter Hack Day, London, Sunday

2011-11-16 Thread Bruce Durling
Looking forward to it. I'll be there.

On Wed, Nov 16, 2011 at 18:39, Ben Evans benjamin.john.ev...@gmail.com wrote:
 Hi,

 There is an Incanter Hack Day taking place on Sunday at the Royal
 Festival Hall in London. We'll be on the 5th floor, Green side.

-- 
You 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: Using clojure.java.shell for long running tasks

2011-11-16 Thread Hugo Duncan
I took a slightly different approach to this, in pallet.shell, and added
an :async flag that returns the streams and the process

https://github.com/pallet/pallet/blob/master/src/pallet/shell.clj

-- 
You 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: Overused phrases in the Clojure community

2011-11-16 Thread Paul Dorman
While I hope this thread dies a quick death, I'd like to offer the words
'properly' and 'well' as sometimes effective substitutes for
'idiomatically'. I am always interested in understanding how programming
challenges can be addressed idiomatically, properly, and well, though I'm
unlikely to have anything of value to add to the conversation. If however
someone were after how to use Clojure idiotamically, I've got plenty to
contribute! :)

On Thu, Nov 17, 2011 at 12:20 AM, Colin Yates colin.ya...@gmail.com wrote:

 I am not sure if the OP was serious or not, but I think the desire to do
 things idiomatically is just one indicator of the quality of this
 community.  I am encouraged, and challenged to learn how to use Clojure
 rather than bash Clojure to fit the holes/shapes I think I have.

 soapboxToo many times I see (and admittedly do) google-paste coding
 where developers need to get something done, so google it, copy the
 relevant fragment and shove it in their code without any appreciation for
 what it does or whether it is the right way./soapbox

 Including the word idiomatic in your post is er, well, er, idiomatic
 posting to the Clojure group :)  (grammar not withstanding)


 On 16 November 2011 07:01, Ben Smith-Mannschott bsmith.o...@gmail.comwrote:

 On Wed, Nov 16, 2011 at 02:16, thenwithexpandedwingshesteershisflight
 mathn...@gmail.com wrote:
  Can we please get bored of saying idiomatic and in particular
  please ?

 It's quite useful to be able to talk about

 the-way-of-expressing-this-concept-most-in-keeping-with-established-practice
 (idiomatic), particularly when a language still sees plenty of
 newcomers.

 The Python community, found a way around the problem you seem to be
 having by inventing their own word: pythonic. Do I hear any votes for
 clojuresque?

 Ok, I think I've spent my smart-a$$ quota for the day,

 Ben

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


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


-- 
You 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-process-shell-command: Spawning child process: invalid argument

2011-11-16 Thread Mark Rathwell
Andrew,

I don't have access to a Windows machine at the moment, but
sidestepping clojure-jack-in for a minute, does using 'lein swank' and
M-x slime-connect work?  (in an eshell buffer that is in the project
directory, run 'lein swank', that should start a swank server on port
4005, then M-x slime-connect should connect you and give you a repl).

 - Mark

On Wed, Nov 16, 2011 at 4:15 PM, Andrew ache...@gmail.com wrote:
 Having trouble setting up Clojure/Emacs on Windows again. Earlier Mark
 Rathwell helped me by pointing out a recipe for Windows that resolved an
 issue with sh. After having the setup work for a while, I botched something
 while trying to upgrade clojure-mode. So I tried to start from scratch using
 the same recipe and now I see this when I try M-x clojure-jack-in

 start-process-shell-command: Spawning child process: invalid argument

 Other notes:

 The value of inferior-lisp-program is lein repl.
 If I start eshell and type lein repl, I see a repl start up.
 If I start eshell and type sh and answer the prompt with lein repl, I also
 see a repl start up.
 lein is in my windows path
 c:/emacs and c:/emacs/bin are both in my path so sh.bat can be found
 the swank-clojure 1.3.3 plugin is installed

 How do I find out what the invalid argument is?

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

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


Re: Overused phrases in the Clojure community

2011-11-16 Thread Mark Hamstra
Clojed-form implementations (vs. cludged-form) is probably too cute by 
half

-- 
You 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: Overused phrases in the Clojure community

2011-11-16 Thread Carl Cotner
In general, I agree that it's annoying to continue seeing certain words
used over and over. But the use of the word idiomatic in particular seems
to be very idiomatic in the Clojure community, so I don't mind it.

:-)


On Tue, Nov 15, 2011 at 8:16 PM, thenwithexpandedwingshesteershisflight 
mathn...@gmail.com wrote:

 Can we please get bored of saying idiomatic and in particular
 please ?

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


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

Non Dev Builds

2011-11-16 Thread Andres Gomez
Inspired by Hickey's keynote at the conj, I built a proof of concept
for a program to make non dev builds (remove comments, docstrings,
line breaks)

https://github.com/fractalmedia/prod-build

It is very simple, its most important function is: (defn read-file
[name] (eval (read-string (str '( (slurp name) )
Which strips comments and line breaks.

I'm sharing this for peer reviewing, once it is confirmed that it
works nice (or modified accordingly) i will wrap it as a lein plugin.

I have 2 questions regarding this:
1. is it more efficient to leave anonymous functions on the form of:
#(something %)
or:
(fn* [p1__69#] (something p1__69#))
(because read-file leaves them on the second form.

Also, can somebody confirm if the drop-doc is missing something?


Cheers

-- 
You 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 on PyPy

2011-11-16 Thread Dax Fohl
Would Clojure have anything to gain by having something like PyPy's
JIT-generator create a custom JIT for it, a'la
http://morepypy.blogspot.com/2011/04/tutorial-part-2-adding-jit.html?
Or does the JVM already do the stuff that is mentioned in that
article?  (Or does none of that stuff apply to Clojure as a language
for whatever reason?)

-- 
You 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-in-CommonLisp?

2011-11-16 Thread NGUYEN Vu Ngoc Tung
http://riddell.us/ClojureWithEmacsSlimeSwankOnUbuntu.html

-- 
You 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: Non Dev Builds

2011-11-16 Thread Meikel Brandmeyer
Hi,

Am 16.11.2011 um 17:17 schrieb Andres Gomez:

 It is very simple, its most important function is: (defn read-file
 [name] (eval (read-string (str '( (slurp name) )

As a minor nitpick to promote robust code… Please use something like this for 
reading:

(let [eof (Object.)] (take-while (complement #{eof}) (repeatedly #(read 
file-reader false eof

(str ( ...) is so ugly and fragile. There are many files which do not end in 
a newline. And if the last line is a comment…

Sincerely
Meikel


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


Re: swank, clojure.repl and my fading sanity

2011-11-16 Thread Matthew Boston
Hey, that looks eerily similar to my gist! :)

https://gist.github.com/1324048

On Nov 15, 2:06 am, Sean Corfield seancorfi...@gmail.com wrote:
 Add the following to your ~/.lein/user.clj:

 ;; ~/.lein/user.clj
 (if (= (.compareTo (clojure-version) 1.3.0) 0)
   (do (use 'clojure.repl)
       (use 'clojure.java.javadoc)))









 On Mon, Nov 14, 2011 at 10:57 PM, Yaron ygol...@gmail.com wrote:
  So when I start a repl from the command line things like doc and
  source work just fine.

  But when I start a repl inside of aquamacs and swank clojure (1.3.3)
  (installed via lein plugin) and clojure (1.3.0) via m-x clojure-jack-
  in those function/macros don't work at all. For example, if I try (doc
  str) I get the error unable to resolve symbol: doc in this
  context [Thrown class java.lang.RuntimeException].

  I tried (ns-all) but it doesn't show clojure.repl as being available.
  (use clojure.repl) just gets me a [Thrown class
  java.lang.ClassNotFoundException].

  Note that the REPL in SWANK works in general. I can evaluate my
  functions and they work.

  So how do I get clojure.repl to load in SWANK?

      Thanks,

        Yaron

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

 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View --http://corfield.org/
 World Singles, LLC. --http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You 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 on PyPy

2011-11-16 Thread Brent Millare
The JVM is an advanced, mature JIT compiler. PyPy's generated JIT compilers 
are not as mature. As a result, the JVM does many of the things in the 
article and more. From what I see, the benefits of Clojure targetting PyPy 
would be exploring the performance advantages of very experimental work. 
Keep in mind, you'd be losing one key advantage of the JVM, which is the 
rich base of libraries written in java. I believe a main motivation to 
target different platforms would be because you want to leverage resources 
available only while on those platforms.

-- 
You 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: Overused phrases in the Clojure community

2011-11-16 Thread Larry Johnson
On Tue, Nov 15, 2011 at 11:05 PM, Carl Cotner carl.cot...@gmail.com wrote:

 In general, I agree that it's annoying to continue seeing certain words
 used over and over. But the use of the word idiomatic in particularseems to 
 be very idiomatic in the Clojure community, so I don't mind it.

 :-)


 On Tue, Nov 15, 2011 at 8:16 PM, thenwithexpandedwingshesteershisflight 
 mathn...@gmail.com wrote:

 Can we please get bored of saying idiomatic and in particular
 please ?




I don't want to take this topic (or myself) too seriously, but the word
idiomatic is a clear and well understood word among programmers.  It's
useful and specific.  I come from a perl background, where there is more
than one way to do it, but despite the many ways to do it, there was
idiomatic perl on the one hand, and everything else on the other.  It's
useful for me to ask, when I'm learning a new language, How would this be
written in idiomatic befunge?

I'll keep the word idiomatic, just as I'll keep the overused word word.
I'll promise not to overuse it, and I'll try not to use it incorrectly.


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




-- 

*Off the Beaten Path in Technology
http://otbeatenpath.wordpress.com
*

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: swank, clojure.repl and my fading sanity

2011-11-16 Thread Sean Corfield
On Wed, Nov 16, 2011 at 3:57 PM, Matthew Boston
matthew.bos...@gmail.com wrote:
 Hey, that looks eerily similar to my gist! :)

https://twitter.com/#!/seancorfield/status/130136793210298368

Yup, again, thank you!
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You 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: clj-time and clojure 1.3

2011-11-16 Thread Sean Corfield
On Wed, Nov 16, 2011 at 6:47 AM, Brad b...@beaconhill.com wrote:
 Just curious what happened with getwoven and clj-time.

 It seems that Sean has updated clj-time over on Clojars and this
 version works fine under 1.3.

I have taken over clj-time from Mark McGranahan:

https://github.com/seancorfield/clj-time

(although github seems to be omitting the navigation bar on that repo
- I'll open a support ticket).

The getwoven repo was supposed to have a notice saying that mine is
now the definitive repo. @bradfordcross tweeted about the change. It
looks like the disappearance of getwoven's repo has left things in a
bit of a mess :(
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You 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-process-shell-command: Spawning child process: invalid argument

2011-11-16 Thread Andrew
The attempt revealed the need to install the slime package. After that, the 
two commands succeed. However, M-x clojure-jack-in still fails in a fresh 
emacs session with the same error.

-- 
You 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 on PyPy

2011-11-16 Thread Timothy Baldridge
I actually started on this at one point. I ended up scrapping the
project for several reasons. But first, I think we must clarify what
we mean by runs on pypy. There's two ways of attacking such a
project:

1) writing a Clojure interpreter in RPython, and then having PyPy
generate a JIT for you. This would, by far, create the fastest
solution. PyPy loves creating JITs for languages with immutable data
and pure functions. In fact, the JIT goes bonkers with optimization
when it comes to programs that follow this criteria. So going this
route would allow you to tell the JIT generator that all your
functions are pure, and all your data is immutable. The bad thing is,
you have no library...you have to write your entire runtime library
yourself.

2) writing a Clojure - Python translator, then run the resulting
code in PyPy (like Clojurescript does with JS). Here the JIT will be a
bit more unhappy since you could change the classes at any moment.
Now the fact that you don't change it means that the performance
impact will be lessened somewhat, but still the impact will be there.

Now both solutions will take two things from you 1) the extensive
library of the JVM. The more I work with the JVM (I'm a .NET guy), the
more I see the value of the platform. 2) you loose co-currency. Most
PyPy code is not thread safe, so there's that.

But I have to disagree with Bret on his comments about how advanced
the JVM is. True the Sun JVM is advanced, but you have to understand
how truely complex the JVM bytecode is. On top of this, no JVM I know
actually implements a tracing JIT. This is where PyPy excels. PyPy
profiles the code while it is running and does some truely insane
optimizations. For instance, PyPy will rip apart data structs. So if
Foo.x is the only member used from the Foo struct in function Bar,
PyPy will re-write a version of Bar on-the-fly so that Bar takes a
single int instead of a full struct. PyPy then also removes unneeded
allocations, etc. Basically it unboxes primitives and generates code
using those primitives while the program is running.

On top of all that, the tracing JIT of PyPy will string functions
together, finding the loops in the actual code, then JIT native code
to represent these loops.

The net effect of this is, that many functions (regex engines, string
functions, and yes even video processing) run just as fast in PyPy as
in pure C code. And in some cases, PyPy can generate code faster than
hand-written C code.

So all that to say, yes, I think there's a lot of potential in PyPy,
but translating Clojure to it is no small task. And even when you're
done, you're still in the same boat as Clojure-CLR and
ClojureScript...no matter how good you are, you're still not real
Clojure.

Timothy

-- 
You 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-process-shell-command: Spawning child process: invalid argument

2011-11-16 Thread Mark Rathwell
I think there is some path issue in your setup between Cygwin and
Windows that will take some work to diagnose.  You might try
installing everything from scratch, or maybe try a Linux vm with
VirtualBox (free) or VMWare.  Either way, you can use lein swank and
slime-connect in the meantime.

On Wed, Nov 16, 2011 at 8:55 PM, Andrew ache...@gmail.com wrote:
 The attempt revealed the need to install the slime package. After that, the
 two commands succeed. However, M-x clojure-jack-in still fails in a fresh
 emacs session with the same error.

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

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


Re: Non Dev Builds

2011-11-16 Thread Andres Gomez
Thanks for the robustness tip, Meikel.

Just a question, i dont understand what you state, i dont think it
needs to end in a newline in order to work.

On Nov 16, 5:17 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 16.11.2011 um 17:17 schrieb Andres Gomez:

  It is very simple, its most important function is: (defn read-file
  [name] (eval (read-string (str '( (slurp name) )

 As a minor nitpick to promote robust code… Please use something like this for 
 reading:

 (let [eof (Object.)] (take-while (complement #{eof}) (repeatedly #(read 
 file-reader false eof

 (str ( ...) is so ugly and fragile. There are many files which do not end 
 in a newline. And if the last line is a comment…

 Sincerely
 Meikel

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


Re: adding metadata to java objects

2011-11-16 Thread Ben Smith-Mannschott
On Wed, Nov 16, 2011 at 22:32, Alan Malloy a...@malloys.org wrote:
 On Nov 16, 11:53 am, Ben Smith-Mannschott bsmith.o...@gmail.com
 wrote:
 On Wed, Nov 16, 2011 at 17:28, Ben Mabey b...@benmabey.com wrote:
  Hi,
  I would like to be able to add metadata to arbitrary java objects that have
  already been instantiated.  I know that you can use proxy to add metadata 
  to
  objects that you create but in my case the object already exists (i.e. it 
  is
  returned from another method call outside of my control).

  It seems like the best solution would be to create a delegate class/object
  that wraps the original one.  Being able to write something like this would
  be ideal:

  (defn wrap-with-meta
   ([obj]
      (wrap-with-meta obj nil))
   ([obj meta]
    (delegate obj
              clojure.lang.IObj
              (withMeta [this new-meta] (wrap-with-meta obj

   new-meta))
              (meta [this] meta

  The delegate function would operate very similar to proxy, but instead of
  taking a class it takes an object.  A class would be created that extends
  the object's class, just like a class is generated for proxy. However,
  instead of stubs being generated that call super the stubs would delegate 
  to
  the given object.  (Also note, I am also using reify-like syntax since I
  prefer that to the syntax in proxy.)

  I'm curious to hear people's thoughts on this approach.  I'd also be really
  interested to see how other people have addressed this in the past (I doubt
  I'm the first one to run into this).

  I know that clojure mentality is to avoid wrappers, but I don't see this as
  being much different than what proxy already does.  Of course, I may be
  missing something... if so, please enlighten me. :)

  Thanks,
  Ben

 Here's an approach that may be of use: don't store the metadata in a
 Map instead of decorating the Object with it. This map should use
 object identity, not equality and should hold its keys weakly so that
 it prevent collection of  objects that otherwise would be garbage.
 Safe to use concurrently would also be a plus. Conveniently, Google's
 Guava library provides such a thing. Here's a sketch:

 == project.clj 

 (defproject pojometa 0.0.1-SNAPSHOT
   :dependencies [[org.clojure/clojure 1.3.0]
                  [com.google.guava/guava 10.0.1]])

 == src/pojometa/core.clj ==

 (ns pojometa.core
     (:import [com.google.common.collect MapMaker]))

 (def meta-map
     (- (MapMaker.) .weakKeys .makeMap))

 (defn meta* [o]
     (if (instance? clojure.lang.IMeta o)
         (clojure.core/meta o)
         (.get meta-map o)))

 (defn with-meta* [o m]
     (if (instance? clojure.lang.IMeta o)
         (clojure.core/with-meta o m)
         (do (.put meta-map o m)
             o)))

 == usage ==

 pojometa.core= (def o (Object.)) ;; arbitrary java object
 pojometa.core= (meta* (with-meta* o {:foo true}))
 {:foo true}

 ;; also does the right thing for Clojure types that
 ;; already know how to have metadata.

 pojometa.core= (meta* (with-meta* {} {:bar 1}))
 {:bar 1}

 (def o (Object.))

 (def om (with-meta* o {:foo true}))

 (def whatever (with-meta* o {:foo false}))

 (meta* om) ;= {:foo false}

 Doesn't really support Clojure's concept of metadata if it's shared
 global mutable state.

Yes, that's true. Though it wouldn't occur to me to expect some random
POJO to behave as if it were persistent WRT metadata. POJOs generally
conflate state and identity and are mutable. That's life. If that's a
problem, then you'll need to wrap it in something that supports
metadata.

// ben

-- 
You 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: Non Dev Builds

2011-11-16 Thread Ben Smith-Mannschott
== FILE ==
(def x 1) NEWLINE
; my comment
==

(str '( (slurp FILE) ) )

produces:

==
'((def x 1) NEWLINE
; my comment)
==

oops.


On Thu, Nov 17, 2011 at 05:32, Andres Gomez and...@fractalmedia.mx wrote:
 Thanks for the robustness tip, Meikel.

 Just a question, i dont understand what you state, i dont think it
 needs to end in a newline in order to work.

 On Nov 16, 5:17 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 16.11.2011 um 17:17 schrieb Andres Gomez:

  It is very simple, its most important function is: (defn read-file
  [name] (eval (read-string (str '( (slurp name) )

 As a minor nitpick to promote robust code… Please use something like this 
 for reading:

 (let [eof (Object.)] (take-while (complement #{eof}) (repeatedly #(read 
 file-reader false eof

 (str ( ...) is so ugly and fragile. There are many files which do not end 
 in a newline. And if the last line is a comment…

 Sincerely
 Meikel

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


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


Re: Non Dev Builds

2011-11-16 Thread Meikel Brandmeyer (kotarak)
Hi,

Consider this file. The * marks the not there \n.

Foo
; Bar*

And slurp and the str call, you get a string which looks like this 
(Foo\n;Bar). And this gives an error because the closing ) is in the 
comment.

Here you see the effect:

user= (with-open [w (writer x)] (binding [*out* w] (print Foo\n;Bar) 
(flush)))
nil
user= (read-string (str ( (slurp x) )))
RuntimeException EOF while reading  clojure.lang.Util.runtimeException 
(Util.java:156)
user= (with-open [r (LineNumberingPushbackReader. (reader x))]
 (let [eof (Object.)]
   (- #(read r false eof)
 repeatedly
 (take-while (complement #{eof}))
 doall)))
(Foo)
user=

Sincerely
Meikel

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