Re: Simple things should be simple

2010-09-10 Thread Meikel Brandmeyer
Hi,

On 9 Sep., 20:46, Mike Meyer  wrote:

> The first problem with that is that this stuff seems show up
> *everywhere* in Javaland. It's not just web apps, it's pretty much
> anything.

You just lost me completely with your argumentation. I wrote a small
desktop utility (simple problem, simple solution, simple program)
which is distributed to different locations in the company. It works
on Windows and Unix w/o adaption to the system. Download jar and
double-click / execute via java -jar. It works without library version
hell, complicated Makefiles, system differences and other shenanigans.
I'm quite willing to pay more complexity upfront to have it easier in
the end.

It is obvious that Clojure doesn't fit your needs. Then simply don't
use it.

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: Knowing in advance the complexity of count

2010-09-10 Thread Meikel Brandmeyer
Hi,

On 9 Sep., 21:01, Randy Hudson  wrote:

> Inexplicably (counted? "abcd") returns false.

Why should it? String does not implement Counted.

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: matching with wild-cards in clojure multi-methods

2010-09-10 Thread Meikel Brandmeyer
Hi,

On 9 Sep., 21:47, Daniel Werner 
wrote:

> Could this be a bug?

No. Clojure does not enforce contracts in several places. Feed wrong
things in and get undefined behaviour back. Only the contract is
guaranteed. Everything else is an implementation detail and might
change at any moment.

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: Simple things should be simple

2010-09-10 Thread Laurent PETIT
2010/9/10 Meikel Brandmeyer :
> Hi,
>
> On 9 Sep., 20:46, Mike Meyer  620...@mired.org> wrote:
>
>> The first problem with that is that this stuff seems show up
>> *everywhere* in Javaland. It's not just web apps, it's pretty much
>> anything.
>
> You just lost me completely with your argumentation. I wrote a small
> desktop utility (simple problem, simple solution, simple program)
> which is distributed to different locations in the company. It works
> on Windows and Unix w/o adaption to the system. Download jar and
> double-click / execute via java -jar. It works without library version
> hell, complicated Makefiles, system differences and other shenanigans.
> I'm quite willing to pay more complexity upfront to have it easier in
> the end.
>
> It is obvious that Clojure doesn't fit your needs. Then simply don't
> use it.

Meikel,

while I admit I haven't read *all* the answers to Meikel's question in
their entirety, what I've understood is that :

  * he's not talking about clojure the language, but its ecosystem
(the JVM host and the J2EE stuff -de facto standard for webapps)
=> so I disagree with you, clojure *may* fit its needs
  * AFAIK the state of the art for clojure hosted on the JVM is not
fixed, so I don't see why your advice to him is to not use it.

All,

Beware trying too hard to defend a position which is not defendable.

Lee said it with probably less "provocative" terms than Mike, but Mike
being a bit "provocative" doesn't mean Mike's point is wrong. And
Mike's examples being a bit (ok maybe a lot) "caricatural" (is this
the idiomatic english word for what I mean?) doesn't mean his point is
invalid.


These last few months, working on ccw has been particularly
interesting because I've had feedback from users, especially Lee. Lee
has challenged a lot of what I had considered to be "simple things" in
ccw. I can say that when you're in a position of "expert", it's hard
to change your mind, because at first, you reject the new user's
points as invalid.

I think that I finally got some points, and have implemented them in ccw.
I've learned something from this : the "It's harder to do/design
simple things than complex ones" maxim is soo true. But what I also
learned is that one point that makes it hard to follow the maxim is
when you consider that you've reached the nirvana of simplicity for
your system (either public interface or internals) and there's nothing
more to do.

Probably Apple with its iPhone is a popular example of great minds
having been able to be the first in the market to offer interfaces
simpler that what everybody else, used to "classic" user interface
ergonomics, would have imagined possible.

I guess a lot of people switch to clojure because they recognize in it
that the simpler paradigm to start with with your program (functional
programming), the better the program. By doing so they are recognizing
that Java is not a good example of "Simple things made simple".
And the same problem Java the language has, the same problem all its
ecosystem has (to some level, those are "gross" approximations, of
course).

What Matt told several posts above about conjure seem to be an
interesting step towards simplicity, without affecting incremental
addition of features/essential complexity to the growing program.

Peace my friends,

cheers,

-- 
Laurent

-- 
You 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: Knowing in advance the complexity of count

2010-09-10 Thread Laurent PETIT
2010/9/10 Meikel Brandmeyer :
> Hi,
>
> On 9 Sep., 21:01, Randy Hudson  wrote:
>
>> Inexplicably (counted? "abcd") returns false.
>
> Why should it? String does not implement Counted.

Maybe when Counted becomes a protocol and is then extended to java.lang.String ?

(Does this make sense ?)

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


Re: Simple things should be simple

2010-09-10 Thread Meikel Brandmeyer
Hi,

On 10 Sep., 10:27, Laurent PETIT  wrote:

> while I admit I haven't read *all* the answers to Meikel's question in
> their entirety, what I've understood is that :
>
>   * he's not talking about clojure the language, but its ecosystem
> (the JVM host and the J2EE stuff -de facto standard for webapps)
>     => so I disagree with you, clojure *may* fit its needs

I'm also not talking about clojure the language, but about the
ecosystem. To deploy my simply (a detail, but since we are talking
about "Hello, World"...) clojure (a detail, could written in groovy,
scala, java, ...) program I used gradle (written in Groovy, useful for
other JVM stuff), several maven repos and the JRE (part of the JVM
environment). I just packed everything in jar distributed it around
the world and it worked in a heterogeneous environment without further
support. How much simpler can it get?

What I actually wanted to point out: there is no "simple". "simple" is
highly subjective and talking about "simple" in absolute terms is a
mistake.

>   * AFAIK the state of the art for clojure hosted on the JVM is not
> fixed, so I don't see why your advice to him is to not use it.

Because it obviously doesn't fit his needs. Mike wants a simple
solution for simple problems. It seems that at the moment there is no
JVM solution that is simple enough for Mike's context. So he shouldn't
use Clojure. Or Groovy. Or Scala. Clojure being just a detail of his
problem (Mike states several times, that he talks about the JVM
environment not the language.)

When things change and complexity is reduced for his context, Mike can
re-evaluate the use of Clojure. And if the whole system fits the bill,
he might even choose to use Clojure for future projects.

Isn't that a reasonable approach?

> Beware trying too hard to defend a position which is not defendable.

I'm not defending a lost position. There are other tools which fit
Mike's needs better than clojure *at the moment*. So there is no point
trying to convince him.

That doesn't mean that we shouldn't change the situation and make
things "simpler" (for some definition of simple).

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: Knowing in advance the complexity of count

2010-09-10 Thread Meikel Brandmeyer
Hi,

On 10 Sep., 10:33, Laurent PETIT  wrote:

> Maybe when Counted becomes a protocol and is then extended to 
> java.lang.String ?
>
> (Does this make sense ?)

Hmmm... Then you can't implement count for seqs anymore. Given you
want the Counted protocol to provide a O(1) count function (really
named count and not fast-count or so). (Maybe a Good Thing(tm)?)

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: Simple things should be simple

2010-09-10 Thread Laurent PETIT
2010/9/10 Meikel Brandmeyer :
> Hi,
>
> On 10 Sep., 10:27, Laurent PETIT  wrote:
>
>> while I admit I haven't read *all* the answers to Meikel's question in
>> their entirety, what I've understood is that :
>>
>>   * he's not talking about clojure the language, but its ecosystem
>> (the JVM host and the J2EE stuff -de facto standard for webapps)
>>     => so I disagree with you, clojure *may* fit its needs
>
> I'm also not talking about clojure the language, but about the
> ecosystem. To deploy my simply (a detail, but since we are talking
> about "Hello, World"...) clojure (a detail, could written in groovy,
> scala, java, ...) program I used gradle (written in Groovy, useful for
> other JVM stuff), several maven repos and the JRE (part of the JVM
> environment). I just packed everything in jar distributed it around
> the world and it worked in a heterogeneous environment without further
> support. How much simpler can it get?
>
> What I actually wanted to point out: there is no "simple". "simple" is
> highly subjective and talking about "simple" in absolute terms is a
> mistake.
>
>>   * AFAIK the state of the art for clojure hosted on the JVM is not
>> fixed, so I don't see why your advice to him is to not use it.
>
> Because it obviously doesn't fit his needs. Mike wants a simple
> solution for simple problems. It seems that at the moment there is no
> JVM solution that is simple enough for Mike's context. So he shouldn't
> use Clojure. Or Groovy. Or Scala. Clojure being just a detail of his
> problem (Mike states several times, that he talks about the JVM
> environment not the language.)
>
> When things change and complexity is reduced for his context, Mike can
> re-evaluate the use of Clojure. And if the whole system fits the bill,
> he might even choose to use Clojure for future projects.
>
> Isn't that a reasonable approach?
>
>> Beware trying too hard to defend a position which is not defendable.
>
> I'm not defending a lost position. There are other tools which fit
> Mike's needs better than clojure *at the moment*. So there is no point
> trying to convince him.
>
> That doesn't mean that we shouldn't change the situation and make
> things "simpler" (for some definition of simple).

That's what I wanted to read, 'cause "the state of your previous
answer" seemed so negative ! :-)

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


[ANN] http.async.client v0.2.0

2010-09-10 Thread Hubert Iwaniuk
I'm happy to announce release of http.async.client v0.2.0 an Asynchronous HTTP 
Client for Clojure.

This is wrapper/adapter on top of 
http://github.com/AsyncHttpClient/async-http-client

Project: http://github.com/neotyk/http.async.client/
Documentation: http://neotyk.github.com/http.async.client/
API autodoc: http://neotyk.github.com/http.async.client/autodoc/
Changelog: http://github.com/neotyk/http.async.client/blob/master/changelog.org

Simple usage:
(ns sample (:require [http.async.client :as c]))
(let [response (c/GET "http://github.com/neotyk/http.async.client/";)]
  (c/await response)
  (c/string response))

Allows you to consume Twitter Streaming API with an ease:
http://codemeself.blogspot.com/2010/09/asynchronous-http-client-for-clojure.html
http://github.com/neotyk/http.async.client/raw/master/twitter-sample.clj

Changes in this release:
* HTTP Streams as clojure.core/seq
* Cookies support
* Authentication support (BASIC and DIGEST)
* Proxy per request
* Allowed branding User-Agent
* Keyworded arguments in API

I would love to hear from you what you think of this library,
Hubert.

-- 
You 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 Problem with Recursion

2010-09-10 Thread Stefan Rohlfing
@ Nicolas and ajuc

Thank you very much for showing me where I went wrong! With so many
parentheses it sometimes happens that I misplace one

Now the output of the function is as expected:

(defn prefix->postfix [expr]
  (if (coll? expr)
(let [ [op arg1 arg2] expr]
  [ (prefix->postfix arg1) (prefix->postfix arg2) op])  ;; <--
removed on parenthesis here
  expr))

(prefix->postfix '(+ 2 (* 3 2)))
;; --> [2 [3 2 *] +]

There is just one point I still don't quite understand. That is,
during one of the recursive calls, the expression (* 3 2) is passed as
an argument to prefix->postfix:

(prefix->postfix (* 3 2))

As prefix->postfix is a normal function and not a macro, (* 3 2)
should get evaluated BEFORE being passed to the function. However,
this is not the case here.

Could it be that because (* 3 2) is quoted, because the initial
argument to the function, '(+ 2 (* 3 2)), was quoted?

Could it be that because the initial argument to prefix->postfix, '(+
2 (* 3 2)), is quoted, (* 3 2) is also quoted and therefore does not
get evaluated?

Stefan

-- 
You 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 Problem with Recursion

2010-09-10 Thread Laurent PETIT
2010/9/10 Stefan Rohlfing :
> @ Nicolas and ajuc
>
> Thank you very much for showing me where I went wrong! With so many
> parentheses it sometimes happens that I misplace one
>
> Now the output of the function is as expected:
>
> (defn prefix->postfix [expr]
>  (if (coll? expr)
>    (let [ [op arg1 arg2] expr]
>      [ (prefix->postfix arg1) (prefix->postfix arg2) op])  ;; <--
> removed on parenthesis here
>  expr))
>
> (prefix->postfix '(+ 2 (* 3 2)))
> ;; --> [2 [3 2 *] +]
>
> There is just one point I still don't quite understand. That is,
> during one of the recursive calls, the expression (* 3 2) is passed as
> an argument to prefix->postfix:
>
> (prefix->postfix (* 3 2))
>
> As prefix->postfix is a normal function and not a macro, (* 3 2)
> should get evaluated BEFORE being passed to the function. However,
> this is not the case here.
>
> Could it be that because (* 3 2) is quoted, because the initial
> argument to the function, '(+ 2 (* 3 2)), was quoted?
>
> Could it be that because the initial argument to prefix->postfix, '(+
> 2 (* 3 2)), is quoted, (* 3 2) is also quoted and therefore does not
> get evaluated?

Yes. '(+ 2 (* 3 2)) being quoted means that the function receives a
datastructure : a list composed of the symbol +, the number 2, and
finally a list composed of the symbol *, the number 3 and the number
2.
' is a syntactic sugar for the special form named quote , whose
purpose is to not evaluate everything which is quoted, and just keep
as a datastructure what the reader has read.

And now, food for thought :-) :

user=> (quote (defn x))
(defn x)

;; => See, no macroexpansion, just what the reader read

user=> (read-string "(defn x)")
(defn x)

;; => I prove the point of above: just what the reader read

user=> (quote (defn ^{:foo :bar} x))
(defn x)

;; => but in the above ^^^, where's :foo :bar ?

user=> (meta (second (quote (defn ^{:foo :bar} x
{:foo :bar}

;; => it's there, but the reader has already interpreted the ^
(because it is a reader macro) and placed {:foo :bar} as the metadata
map for the symbol x

HTH,

-- 
Laurent

-- 
You 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 Problem with Recursion

2010-09-10 Thread Stefan Rohlfing
Hi Laurent,

Thanks for your detailed explanation! It greatly helped me understand
the usage of quoting.

Stefan

On Sep 10, 5:27 pm, Laurent PETIT  wrote:
> 2010/9/10 Stefan Rohlfing :
>
>
>
>
>
>
>
>
>
> > @ Nicolas and ajuc
>
> > Thank you very much for showing me where I went wrong! With so many
> > parentheses it sometimes happens that I misplace one
>
> > Now the output of the function is as expected:
>
> > (defn prefix->postfix [expr]
> >  (if (coll? expr)
> >    (let [ [op arg1 arg2] expr]
> >      [ (prefix->postfix arg1) (prefix->postfix arg2) op])  ;; <--
> > removed on parenthesis here
> >  expr))
>
> > (prefix->postfix '(+ 2 (* 3 2)))
> > ;; --> [2 [3 2 *] +]
>
> > There is just one point I still don't quite understand. That is,
> > during one of the recursive calls, the expression (* 3 2) is passed as
> > an argument to prefix->postfix:
>
> > (prefix->postfix (* 3 2))
>
> > As prefix->postfix is a normal function and not a macro, (* 3 2)
> > should get evaluated BEFORE being passed to the function. However,
> > this is not the case here.
>
> > Could it be that because (* 3 2) is quoted, because the initial
> > argument to the function, '(+ 2 (* 3 2)), was quoted?
>
> > Could it be that because the initial argument to prefix->postfix, '(+
> > 2 (* 3 2)), is quoted, (* 3 2) is also quoted and therefore does not
> > get evaluated?
>
> Yes. '(+ 2 (* 3 2)) being quoted means that the function receives a
> datastructure : a list composed of the symbol +, the number 2, and
> finally a list composed of the symbol *, the number 3 and the number
> 2.
> ' is a syntactic sugar for the special form named quote , whose
> purpose is to not evaluate everything which is quoted, and just keep
> as a datastructure what the reader has read.
>
> And now, food for thought :-) :
>
> user=> (quote (defn x))
> (defn x)
>
> ;; => See, no macroexpansion, just what the reader read
>
> user=> (read-string "(defn x)")
> (defn x)
>
> ;; => I prove the point of above: just what the reader read
>
> user=> (quote (defn ^{:foo :bar} x))
> (defn x)
>
> ;; => but in the above ^^^, where's :foo :bar ?
>
> user=> (meta (second (quote (defn ^{:foo :bar} x
> {:foo :bar}
>
> ;; => it's there, but the reader has already interpreted the ^
> (because it is a reader macro) and placed {:foo :bar} as the metadata
> map for the symbol x
>
> HTH,
>
> --
> Laurent

-- 
You 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 difficult Metaphor for Macros (especially for Java people)

2010-09-10 Thread Adam Burry
On Sep 9, 5:06 pm, alux  wrote:
> But, @Luc
> "pushing the advantage of Lisp
> macros to the forefront is not obvious if the audience cannot compare
> with another (good/simple) implementation they understand well."
>
> Thats why I want to use a nifty metaphor ;-)

Even your dumbest Java developer knows that javac (or ant, or maven,
or Eclipse, or *something*) converts their source to JVM byte code.
Finding a familiar example is not hard.

Compilers might not be a perfect example perhaps because maybe people
think of compilers as big, complicated, high magic. But, clearly, they
don't have to be. Any rewriting system should be a suitable analogy.

As I said before, the macro concept should be as plain as the nose on
your face. As other people have said, the cool part is that lisp
macros are written in lisp and integrate with the compiler/interpreter
in a cool way. That can only be internalized (grokked) by writing your
own macros and reading good examples.

How do you force someone to do that? You make it part of some other
goal they are trying to achieve. Right? Why did you study semi-
conductor physics? Because you had to before they'd let you do
transistors, before they'd let you do logic gates, before they'd let
you do microprocessors, before they'd let you do assembly, before
they'd let you do C, before they'd let you do algorithms, before
they'd let you do AI. Which is all you ever *really* wanted to do in
the first place!

Adam

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


Problem importing JOptionPane from a string evaluated by load-string

2010-09-10 Thread Paul D. Fernhout
I'm just trying out Clojure a bit, so this may be an obvious simple thing 
I'm misunderstanding.


This code in the test file below allows editing a Clojure function that is 
updated when an "Update Code" button is pressed, with the new value 
connected to a GUI button "Click Me!" as a proxy ActionListener.


It starts with a default function that has not been dynamically loaded from 
a string that pops up a JOptionPane that displays the text in the text pane.


Evaluating simple code like "(fn [] (println \"Hello World\"))"
with no import dependencies works.

What am I doing wrong to not have the evaluated code have access to JOptionPane?

I get:

user=> Exception in thread "AWT-EventQueue-0" java.lang.Exception: No such 
namespace: JOptionPane (NO_SOURCE_FILE:6)


when I try the "Update Code" button.

The initial text includes an import statement.

What do I misunderstand that the import does not seem to work?

Anyway, I'm new to Clojure, so I don't really get the import or ns command 
that well yet. Any suggestions would be appreciated. Feel free to treat this 
code example as if it were in the public domain.


=== guitest2.clj

(ns org.pointrel.guitest2
  ;(:require )
  ;(:use )
  ;(:import )
 )

  (import
'(javax.swing JFrame JPanel JButton JOptionPane JTextPane)
'(java.awt.event ActionListener))

(defn hookupActionPerformed [receiver function]
  (println "updating hook" receiver function)
  (let [act (proxy [ActionListener] [] (actionPerformed [event] (function)))]
(.addActionListener receiver act)
)
  )

(def initial-text "(fn []
  (println \"Hello World\")
  (println (+ 2 2))
  ;(ns org.pointrel.guitest2)
  (import '(javax.swing JOptionPane))
  (JOptionPane/showMessageDialog
  nil \"Hello from the text panel\" \"Greeting\"
  JOptionPane/INFORMATION_MESSAGE)
  )"
  )

(defn window []
  (def frame (JFrame. "Hello Frame"))

  (def panel (JPanel.))
  (.setContentPane frame panel)

  (def test-button (JButton. "Click Me!"))
  (.add panel test-button)

  (def update-button (JButton. "Update code"))
  (.add panel update-button)

  (def text (JTextPane.))
  (.setText text initial-text)
  (.add panel text)

  (defn say-hello []
(let [text-contents (.getText text)]
   (JOptionPane/showMessageDialog
  nil text-contents "Greeting"
  JOptionPane/INFORMATION_MESSAGE)))

  (hookupActionPerformed test-button say-hello)

  (defn update-code []
(let [text-contents (.getText text)
  discard (printf text-contents)
  user-function (load-string text-contents)]
  (println "update-code")
  (.removeActionListener test-button (aget (.getListeners test-button 
ActionListener) 0))

  (hookupActionPerformed test-button user-function)
   ))

  (hookupActionPerformed update-button update-code)

  (.setSize frame 200 200)
  (.setVisible frame true)
)

(window)

; (eval (read-string "(println \"Hello World\")"))
; (load-string "(fn [] (println \"Hello World\"))")
; (eval ((fn [] (println "Hello World2"

===

There's probably stylistic issue, too. :-)

By the way, the println calls don't seem to show up in NetBeans 6.9.1 with 
Enclojure after the window opens, and when I try to use code that generates 
an error I get "Repl is disconnected" that I don't know how to recover from 
without restarting NetBeans, so I am testing this with:


$ java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main
Clojure 1.2.0
user=> (load-file "guitest2.clj")

--Paul Fernhout
http://www.pdfernhout.net/

The biggest challenge of the 21st century is the irony of technologies of 
abundance in the hands of those thinking in terms of scarcity.


--
You 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: Simple things should be simple

2010-09-10 Thread Alessio Stalla
On Sep 9, 6:06 pm, Phil Hagelberg  wrote:
> On Thu, Sep 9, 2010 at 8:38 AM, Mike Meyer
>
>  wrote:
> > And two tools - lein and clojure itself.
>
> I'm not sure Clojure should be counted separately since you're not
> installing it yourself.
>
> > So we go from 3, 0, 1 to 6, 4, 2. I'm not sure that qualifies as
> > simple, but at least there's less boilerplate for the tools than there
> > is actual source code.
>
> Really I think your complaint boils down to not being able to modify
> the classpath at runtime. If the JVM had a real load-path like other
> lisps offer then this would be enough:
>
> (use 'ring.adapter.jetty 'ring.util.response)
> (run-jetty (constantly (response "hello world"))
>                {:port 8080 :join? false})
>
> ...and we're back to three lines.
>
> Now I'm not defending the fact that the classpath is fixed at
> JVM-launch time--it's an awful hack that is an embarrassment to the
> awesome engineering prowess that has gone in to other parts of the
> JVM. But we do have tools to work around that flaw, and it's good to
> recognize the root of the problem rather than its symptoms.

Except the classpath is *not* fixed at all! The concept of classpath
does not exist inside the JVM. Classloaders do. Classloaders are
objects like any other - you can create new instances of them, and
alter their state. Classpath is just an environment variable / command-
line argument to "java", used to conveniently initialize the system
classloader from the outside world. In fact, many JVM-based dynamic
languages allow the "classpath" to be changed at runtime. I know for
sure BeanShell does, and ABCL does too - I contributed the patch to
it.

As for the OP's quest for simplicity - I agree that often things are
overly complicated in the Java world. However, I think that comparing
Apache's cgi-bin with .war packaged applications is unfair, since they
do have different goals. If you want the same "drop file in
diredirectoryctory and be done with it" experience, follow these
steps:

1) download Tomcat and unzip it in $tomcat
2) put clojure.jar is $tomcat/webapps/ROOT/WEB-INF/lib

this installs the server. Then, for each "application", put a .jsp
file in $tomcat/webapps/ROOT containing:

<% out.print(clojure.lang.RT.eval("(foo bar baz)")); %>

(or whatever the right incantation is to eval from Java). done. Browse
http://localhost:8080/scriptName.jsp to run it. Of course, I'd NOT
recommend this, but you seem to know what you want.

Cheers,
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


testing local functions?

2010-09-10 Thread alux
Hello,

I always thought it to be good style to make helper functions only as
visible as needed, e.g. by using letfn.

But when I want to test my code, I just dont see a way to access these
local functions for tests.

(I've seen fogus playing with the test of functions that are namespace
private http://blog.fogus.me/2010/09/03/monkeying-with-clojures-deftest/
, but at least as far as I can see, this can't be generalised to my
problem.)

Do you know any way to test them?

Thank you, alux

-- 
You 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: testing local functions?

2010-09-10 Thread James Reeves
On 10 September 2010 12:24, alux  wrote:
> I always thought it to be good style to make helper functions only as
> visible as needed, e.g. by using letfn.
>
> But when I want to test my code, I just dont see a way to access these
> local functions for tests.

I don't believe you can. You could make them private functions, and
then test them by referring directly to their vars, e.g.

(#'your.namespace/private-function ...)

But in general, your tests should be testing your public interface,
not a specific implementation. Your tests shouldn't care what your
code does behind the scenes, so long as the publicly accessible
functions return the correct result.

- James

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


Re: testing local functions?

2010-09-10 Thread alux
Hi James,

thanks for your answer.

> your tests should be testing your public interface

Hhmmm.
Well, I tend to disagree here. I sometimes like to have tests in place
for things I want to refactor. To not inadvertently do something
foolish.

But I agree that this is not easily accomplishable.

Greetings, alux

On 10 Sep., 13:39, James Reeves  wrote:
> On 10 September 2010 12:24, alux  wrote:
>
> > I always thought it to be good style to make helper functions only as
> > visible as needed, e.g. by using letfn.
>
> > But when I want to test my code, I just dont see a way to access these
> > local functions for tests.
>
> I don't believe you can. You could make them private functions, and
> then test them by referring directly to their vars, e.g.
>
> (#'your.namespace/private-function ...)
>
> But in general, your tests should be testing your public interface,
> not a specific implementation. Your tests shouldn't care what your
> code does behind the scenes, so long as the publicly accessible
> functions return the correct result.
>
> - James

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


Re: testing local functions?

2010-09-10 Thread Christian Vest Hansen
>From someone who's window to your code is your public API, a
refactoring should make no observable change.

So if you only test on the public API, but you test it thoroughly,
then your tests will ensure that this property holds.

Tests that delve into implementation details and private things, are
more brittle because they are affected by changes in implementation
details.

On Fri, Sep 10, 2010 at 14:16, alux  wrote:
> Hi James,
>
> thanks for your answer.
>
>> your tests should be testing your public interface
>
> Hhmmm.
> Well, I tend to disagree here. I sometimes like to have tests in place
> for things I want to refactor. To not inadvertently do something
> foolish.
>
> But I agree that this is not easily accomplishable.
>
> Greetings, alux
>
> On 10 Sep., 13:39, James Reeves  wrote:
>> On 10 September 2010 12:24, alux  wrote:
>>
>> > I always thought it to be good style to make helper functions only as
>> > visible as needed, e.g. by using letfn.
>>
>> > But when I want to test my code, I just dont see a way to access these
>> > local functions for tests.
>>
>> I don't believe you can. You could make them private functions, and
>> then test them by referring directly to their vars, e.g.
>>
>> (#'your.namespace/private-function ...)
>>
>> But in general, your tests should be testing your public interface,
>> not a specific implementation. Your tests shouldn't care what your
>> code does behind the scenes, so long as the publicly accessible
>> functions return the correct result.
>>
>> - James
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



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

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

2010-09-10 Thread John Cromartie

On Sep 9, 11:47 am, Mike Meyer  wrote:
> On Thu, 9 Sep 2010 16:28:48 +0100
>
> Edmund Jackson  wrote:
> > Hi Mike,
>
> >     Could you perhaps present a counter-example of greater simplicity ?
>
> $ cat - > /usr/local/www/apache22/cgi-bin/hello-world.sh
> #!/bin/sh
>
> echo 'Content-type: text/plain\n'
> echo Hello World
> ^D
> $ chomd 755 /usr/local/www/apache22/cgi-bin/hello-world.sh
>
> Done. Three lines of source code. 0 lines of framework setup. 1 tool
> (sh). Pretty much the same thing works for python, perl, etc.  It's
> about as robust as can be asked for - that's the nature of
> apache. Performance is going to be mediocre at best. That's the
> trade-off for simplicity.
>
>        /usr/local/www/apache22/cgi-bin/hello-world

#!/usr/local/bin/clj

(println "Content-type: text/plain\n")
(println "Hello, World!")
^D

Is that simple enough?

For better startup performance, you can use Nailgun.

-John

-- 
You 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: Problem importing JOptionPane from a string evaluated by load-string

2010-09-10 Thread Sean Devlin
Try printing out the *ns* variable in the fn.  Chances are your code
is being created in a different *ns* than it is being run.  You can
also try using the fully qualified path to get to JOptionPane, that
may help too.

On Sep 9, 9:43 pm, "Paul D. Fernhout" 
wrote:
> I'm just trying out Clojure a bit, so this may be an obvious simple thing
> I'm misunderstanding.
>
> This code in the test file below allows editing a Clojure function that is
> updated when an "Update Code" button is pressed, with the new value
> connected to a GUI button "Click Me!" as a proxy ActionListener.
>
> It starts with a default function that has not been dynamically loaded from
> a string that pops up a JOptionPane that displays the text in the text pane.
>
> Evaluating simple code like "(fn [] (println \"Hello World\"))"
> with no import dependencies works.
>
> What am I doing wrong to not have the evaluated code have access to 
> JOptionPane?
>
> I get:
>
> user=> Exception in thread "AWT-EventQueue-0" java.lang.Exception: No such
> namespace: JOptionPane (NO_SOURCE_FILE:6)
>
> when I try the "Update Code" button.
>
> The initial text includes an import statement.
>
> What do I misunderstand that the import does not seem to work?
>
> Anyway, I'm new to Clojure, so I don't really get the import or ns command
> that well yet. Any suggestions would be appreciated. Feel free to treat this
> code example as if it were in the public domain.
>
> === guitest2.clj
>
> (ns org.pointrel.guitest2
>    ;(:require )
>    ;(:use )
>    ;(:import )
>   )
>
>    (import
>      '(javax.swing JFrame JPanel JButton JOptionPane JTextPane)
>      '(java.awt.event ActionListener))
>
> (defn hookupActionPerformed [receiver function]
>    (println "updating hook" receiver function)
>    (let [act (proxy [ActionListener] [] (actionPerformed [event] (function)))]
>      (.addActionListener receiver act)
>      )
>    )
>
> (def initial-text "(fn []
>    (println \"Hello World\")
>    (println (+ 2 2))
>    ;(ns org.pointrel.guitest2)
>    (import '(javax.swing JOptionPane))
>    (JOptionPane/showMessageDialog
>        nil \"Hello from the text panel\" \"Greeting\"
>        JOptionPane/INFORMATION_MESSAGE)
>    )"
>    )
>
> (defn window []
>    (def frame (JFrame. "Hello Frame"))
>
>    (def panel (JPanel.))
>    (.setContentPane frame panel)
>
>    (def test-button (JButton. "Click Me!"))
>    (.add panel test-button)
>
>    (def update-button (JButton. "Update code"))
>    (.add panel update-button)
>
>    (def text (JTextPane.))
>    (.setText text initial-text)
>    (.add panel text)
>
>    (defn say-hello []
>      (let [text-contents (.getText text)]
>     (JOptionPane/showMessageDialog
>        nil text-contents "Greeting"
>        JOptionPane/INFORMATION_MESSAGE)))
>
>    (hookupActionPerformed test-button say-hello)
>
>    (defn update-code []
>      (let [text-contents (.getText text)
>            discard (printf text-contents)
>            user-function (load-string text-contents)]
>        (println "update-code")
>        (.removeActionListener test-button (aget (.getListeners test-button
> ActionListener) 0))
>        (hookupActionPerformed test-button user-function)
>     ))
>
>    (hookupActionPerformed update-button update-code)
>
>    (.setSize frame 200 200)
>    (.setVisible frame true)
> )
>
> (window)
>
> ; (eval (read-string "(println \"Hello World\")"))
> ; (load-string "(fn [] (println \"Hello World\"))")
> ; (eval ((fn [] (println "Hello World2"
>
> ===
>
> There's probably stylistic issue, too. :-)
>
> By the way, the println calls don't seem to show up in NetBeans 6.9.1 with
> Enclojure after the window opens, and when I try to use code that generates
> an error I get "Repl is disconnected" that I don't know how to recover from
> without restarting NetBeans, so I am testing this with:
>
> $ java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main
> Clojure 1.2.0
> user=> (load-file "guitest2.clj")
>
> --Paul Fernhouthttp://www.pdfernhout.net/
> 
> The biggest challenge of the 21st century is the irony of technologies of
> abundance in the hands of those thinking in terms of scarcity.

-- 
You 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: Problem importing JOptionPane from a string evaluated by load-string

2010-09-10 Thread Laurent PETIT
Got it. You cannot invoke (import) (or (ns)) from within the function
definition. The function is already being evaluated, and it's "too
late".

This works fine for me:

(do
  (import '(javax.swing JOptionPane))
  ((fn []
(println "Hello World")
 (println (+ 2 2))
 (JOptionPane/showMessageDialog
   nil "Hello from the text panel" "Greeting"
   JOptionPane/INFORMATION_MESSAGE

So be aware that then some namespace will be changed by the call to
import (side effect on *ns*).

I would suggest either you create a temporary namespace for the code
to execute, either as Sean suggested, you write the call to
JOptionPane static methods and fields fully qualified:
(javax.swing.JOptionPane/showMessageDialog ...)

HTH,

-- 
Laurent

2010/9/10 Paul D. Fernhout :
> I'm just trying out Clojure a bit, so this may be an obvious simple thing
> I'm misunderstanding.
>
> This code in the test file below allows editing a Clojure function that is
> updated when an "Update Code" button is pressed, with the new value
> connected to a GUI button "Click Me!" as a proxy ActionListener.
>
> It starts with a default function that has not been dynamically loaded from
> a string that pops up a JOptionPane that displays the text in the text pane.
>
> Evaluating simple code like "(fn [] (println \"Hello World\"))"
> with no import dependencies works.
>
> What am I doing wrong to not have the evaluated code have access to
> JOptionPane?
>
> I get:
>
> user=> Exception in thread "AWT-EventQueue-0" java.lang.Exception: No such
> namespace: JOptionPane (NO_SOURCE_FILE:6)
>
> when I try the "Update Code" button.
>
> The initial text includes an import statement.
>
> What do I misunderstand that the import does not seem to work?
>
> Anyway, I'm new to Clojure, so I don't really get the import or ns command
> that well yet. Any suggestions would be appreciated. Feel free to treat this
> code example as if it were in the public domain.
>
> === guitest2.clj
>
> (ns org.pointrel.guitest2
>  ;(:require )
>  ;(:use )
>  ;(:import )
>  )
>
>  (import
>    '(javax.swing JFrame JPanel JButton JOptionPane JTextPane)
>    '(java.awt.event ActionListener))
>
> (defn hookupActionPerformed [receiver function]
>  (println "updating hook" receiver function)
>  (let [act (proxy [ActionListener] [] (actionPerformed [event] (function)))]
>    (.addActionListener receiver act)
>    )
>  )
>
> (def initial-text "(fn []
>  (println \"Hello World\")
>  (println (+ 2 2))
>  ;(ns org.pointrel.guitest2)
>  (import '(javax.swing JOptionPane))
>  (JOptionPane/showMessageDialog
>      nil \"Hello from the text panel\" \"Greeting\"
>      JOptionPane/INFORMATION_MESSAGE)
>  )"
>  )
>
> (defn window []
>  (def frame (JFrame. "Hello Frame"))
>
>  (def panel (JPanel.))
>  (.setContentPane frame panel)
>
>  (def test-button (JButton. "Click Me!"))
>  (.add panel test-button)
>
>  (def update-button (JButton. "Update code"))
>  (.add panel update-button)
>
>  (def text (JTextPane.))
>  (.setText text initial-text)
>  (.add panel text)
>
>  (defn say-hello []
>    (let [text-contents (.getText text)]
>   (JOptionPane/showMessageDialog
>      nil text-contents "Greeting"
>      JOptionPane/INFORMATION_MESSAGE)))
>
>  (hookupActionPerformed test-button say-hello)
>
>  (defn update-code []
>    (let [text-contents (.getText text)
>          discard (printf text-contents)
>          user-function (load-string text-contents)]
>      (println "update-code")
>      (.removeActionListener test-button (aget (.getListeners test-button
> ActionListener) 0))
>      (hookupActionPerformed test-button user-function)
>   ))
>
>  (hookupActionPerformed update-button update-code)
>
>  (.setSize frame 200 200)
>  (.setVisible frame true)
> )
>
> (window)
>
> ; (eval (read-string "(println \"Hello World\")"))
> ; (load-string "(fn [] (println \"Hello World\"))")
> ; (eval ((fn [] (println "Hello World2"
>
> ===
>
> There's probably stylistic issue, too. :-)
>
> By the way, the println calls don't seem to show up in NetBeans 6.9.1 with
> Enclojure after the window opens, and when I try to use code that generates
> an error I get "Repl is disconnected" that I don't know how to recover from
> without restarting NetBeans, so I am testing this with:
>
> $ java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main
> Clojure 1.2.0
> user=> (load-file "guitest2.clj")
>
> --Paul Fernhout
> http://www.pdfernhout.net/
> 
> The biggest challenge of the 21st century is the irony of technologies of
> abundance in the hands of those thinking in terms of scarcity.
>
> --
> You 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://grou

Re: Problem importing JOptionPane from a string evaluated by load-string

2010-09-10 Thread Sean Devlin
I've also used the with-ns package in contrib to fix this.

On Sep 10, 9:03 am, Laurent PETIT  wrote:
> Got it. You cannot invoke (import) (or (ns)) from within the function
> definition. The function is already being evaluated, and it's "too
> late".
>
> This works fine for me:
>
> (do
>   (import '(javax.swing JOptionPane))
>   ((fn []
>     (println "Hello World")
>      (println (+ 2 2))
>      (JOptionPane/showMessageDialog
>        nil "Hello from the text panel" "Greeting"
>        JOptionPane/INFORMATION_MESSAGE
>
> So be aware that then some namespace will be changed by the call to
> import (side effect on *ns*).
>
> I would suggest either you create a temporary namespace for the code
> to execute, either as Sean suggested, you write the call to
> JOptionPane static methods and fields fully qualified:
> (javax.swing.JOptionPane/showMessageDialog ...)
>
> HTH,
>
> --
> Laurent
>
> 2010/9/10 Paul D. Fernhout :
>
> > I'm just trying out Clojure a bit, so this may be an obvious simple thing
> > I'm misunderstanding.
>
> > This code in the test file below allows editing a Clojure function that is
> > updated when an "Update Code" button is pressed, with the new value
> > connected to a GUI button "Click Me!" as a proxy ActionListener.
>
> > It starts with a default function that has not been dynamically loaded from
> > a string that pops up a JOptionPane that displays the text in the text pane.
>
> > Evaluating simple code like "(fn [] (println \"Hello World\"))"
> > with no import dependencies works.
>
> > What am I doing wrong to not have the evaluated code have access to
> > JOptionPane?
>
> > I get:
>
> > user=> Exception in thread "AWT-EventQueue-0" java.lang.Exception: No such
> > namespace: JOptionPane (NO_SOURCE_FILE:6)
>
> > when I try the "Update Code" button.
>
> > The initial text includes an import statement.
>
> > What do I misunderstand that the import does not seem to work?
>
> > Anyway, I'm new to Clojure, so I don't really get the import or ns command
> > that well yet. Any suggestions would be appreciated. Feel free to treat this
> > code example as if it were in the public domain.
>
> > === guitest2.clj
>
> > (ns org.pointrel.guitest2
> >  ;(:require )
> >  ;(:use )
> >  ;(:import )
> >  )
>
> >  (import
> >    '(javax.swing JFrame JPanel JButton JOptionPane JTextPane)
> >    '(java.awt.event ActionListener))
>
> > (defn hookupActionPerformed [receiver function]
> >  (println "updating hook" receiver function)
> >  (let [act (proxy [ActionListener] [] (actionPerformed [event] (function)))]
> >    (.addActionListener receiver act)
> >    )
> >  )
>
> > (def initial-text "(fn []
> >  (println \"Hello World\")
> >  (println (+ 2 2))
> >  ;(ns org.pointrel.guitest2)
> >  (import '(javax.swing JOptionPane))
> >  (JOptionPane/showMessageDialog
> >      nil \"Hello from the text panel\" \"Greeting\"
> >      JOptionPane/INFORMATION_MESSAGE)
> >  )"
> >  )
>
> > (defn window []
> >  (def frame (JFrame. "Hello Frame"))
>
> >  (def panel (JPanel.))
> >  (.setContentPane frame panel)
>
> >  (def test-button (JButton. "Click Me!"))
> >  (.add panel test-button)
>
> >  (def update-button (JButton. "Update code"))
> >  (.add panel update-button)
>
> >  (def text (JTextPane.))
> >  (.setText text initial-text)
> >  (.add panel text)
>
> >  (defn say-hello []
> >    (let [text-contents (.getText text)]
> >   (JOptionPane/showMessageDialog
> >      nil text-contents "Greeting"
> >      JOptionPane/INFORMATION_MESSAGE)))
>
> >  (hookupActionPerformed test-button say-hello)
>
> >  (defn update-code []
> >    (let [text-contents (.getText text)
> >          discard (printf text-contents)
> >          user-function (load-string text-contents)]
> >      (println "update-code")
> >      (.removeActionListener test-button (aget (.getListeners test-button
> > ActionListener) 0))
> >      (hookupActionPerformed test-button user-function)
> >   ))
>
> >  (hookupActionPerformed update-button update-code)
>
> >  (.setSize frame 200 200)
> >  (.setVisible frame true)
> > )
>
> > (window)
>
> > ; (eval (read-string "(println \"Hello World\")"))
> > ; (load-string "(fn [] (println \"Hello World\"))")
> > ; (eval ((fn [] (println "Hello World2"
>
> > ===
>
> > There's probably stylistic issue, too. :-)
>
> > By the way, the println calls don't seem to show up in NetBeans 6.9.1 with
> > Enclojure after the window opens, and when I try to use code that generates
> > an error I get "Repl is disconnected" that I don't know how to recover from
> > without restarting NetBeans, so I am testing this with:
>
> > $ java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main
> > Clojure 1.2.0
> > user=> (load-file "guitest2.clj")
>
> > --Paul Fernhout
> >http://www.pdfernhout.net/
> > 
> > The biggest challenge of the 21st century is the irony of technologies of
> > abundance in the hands of those thinking in terms of scarcity.
>
> > --
> > You received this message because you are subsc

Re: Simple things should be simple

2010-09-10 Thread brianh
Just to be contrary ;)

A one time investment of 2 minutes (I did have to scrounge in contrib
to locate these after all):

(defn make-stupid-simple-script [f content]
  (spit f content)
  (sh "chmod" "755" (.getName f)))

for the eternal pleasure of using:

user=> (make-stupid-simple-script (File. "/usr/local/www/apache22/cgi-
bin/hello-world.sh") "#!/bin/sh\n
echo 'Content-type: text/plain\\n'
echo Hello World")

Feel free to take this and run with it :)

On Sep 9, 9:47 am, Mike Meyer  wrote:
> On Thu, 9 Sep 2010 16:28:48 +0100
>
> Edmund Jackson  wrote:
> > Hi Mike,
>
> >     Could you perhaps present a counter-example of greater simplicity ?
>
> $ cat - > /usr/local/www/apache22/cgi-bin/hello-world.sh
> #!/bin/sh
>
> echo 'Content-type: text/plain\n'
> echo Hello World
> ^D
> $ chomd 755 /usr/local/www/apache22/cgi-bin/hello-world.sh
>
> Done. Three lines of source code. 0 lines of framework setup. 1 tool
> (sh). Pretty much the same thing works for python, perl, etc.  It's
> about as robust as can be asked for - that's the nature of
> apache. Performance is going to be mediocre at best. That's the
> trade-off for simplicity.
>
>        --
> Mike Meyer           http://www.mired.org/consulting.html
> Independent Network/Unix/Perforce consultant, email for more information.
>
> O< ascii ribbon campaign - stop html mail -www.asciiribbon.org

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


Re: Simple things should be simple

2010-09-10 Thread gary ng
On Fri, Sep 10, 2010 at 4:47 AM, John Cromartie  wrote:
> #!/usr/local/bin/clj
>
> (println "Content-type: text/plain\n")
> (println "Hello, World!")
> ^D
>
> Is that simple enough?
>
That was my thought too, java/clojure console app should not be more
complex than python etc. The issue is the startup time

> For better startup performance, you can use Nailgun.

How can nailjun help here ? I am not too familiar with it.

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

2010-09-10 Thread lprefontaine
I solved my maven corruption problem. On if the m2 index folder was not
cleaned properly.

Luc P, 

lprefonta...@softaddicts.ca wrote ..
> Hi Phil,
> 
> I upgraded to 1.3.1 but started to experience some problems with 
> my our-classe-only hook. I made it return 0 since 1.3.1 expects a numeric
> return code from the compile task but then ended up with other problems
> in the jar task.
> 
> I want to revert to 1.3.0 for a few days. Any idea about the recipe
> I should follow ?
> 
> I downloaded the 1.3.0 script, cleared my local maven cache but it
> lein deps always install 1.3.1. I am missing a file to clear but
> did not figured it out yet. Any clues ?
> 
> I'll investigate my problems with 1.3.1 and the compile hook later next week.
> 
> Thank you,
> 
> Luc P.
> 
> Phil Hagelberg  wrote ..
> > I'm pleased to announce the release of Leiningen 1.3.1. This release
> > fixes a few key bugs and introduces a handful of minor features. Here
> > are the highlights.
> > 
> > Bug Fixes:
> > 
> > * Performing a standalone install (a new feature of Leiningen 1.3.0)
> > now pulls in all transitive dependencies.
> > 
> > * Unreadable input won't cause issues in the repl.
> > 
> > * Huge classpaths no longer cause slowdown on boot.
> > 
> > * Namespaces for test and help tasks are no longer skipped if their
> > first form is not a call to the ns macro.
> > 
> > * Uberjar task will not proceed if compilation fails.
> > 
> > New Features:
> > 
> > * The shell-wrapper scripts may be customized.
> > 
> > * repl task may be used outside the context of a project.
> > 
> > * If :min-lein-version is set, users of an older Leiningen version
> > will see a warning.
> > 
> > * Dependency jar types may be specified. (test, javadoc, etc.)
> > 
> > * Regexes may be used to specify namespaces in :aot list.
> > 
> > We also have improved Windows support with a zip file that should get
> > you everything you need:
> > 
> > http://github.com/downloads/technomancy/leiningen/lein-win32.zip
> > 
> > More details about the changes are at http://bit.ly/lein-news
> > 
> > I'm particularly interested in the shell-wrapper functionality since
> > right now it's quite awkward to create Clojure projects that are
> > first-class citizens when it comes to the command-line. I think
> > shell-wrappers have the potential to significantly improve the
> > situation. I'm hoping to write up some more documentation on this, but
> > you can see the basics under "Shell Wrappers" near the bottom of the
> > tutorial:
> > 
> > http://github.com/technomancy/leiningen/blob/master/TUTORIAL.md
> > 
> > As always, thanks to the contributors who submitted patches for this
> > release: Shantanu Kumar, Colin Jones, Isaac Hodes, Alan Dipert, John
> > Sanda, and Alex Ott, as well as all 47 of you who have contributed in
> > the past: http://www.ohloh.net/p/leiningen/contributors
> > 
> > If you'd like to be involved in the next release, I've started a
> > thread with a roadmap for 1.4.0 on the Leiningen mailing list:
> > 
> >
http://groups.google.com/group/leiningen/browse_thread/thread/8352bbb974034bff
> > 
> > Enjoy!
> > 
> > -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
> 
> -- 
> You 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


Leiningen-1.4.0-SNAPSHOT missing

2010-09-10 Thread Bahman Movaqar
 Hi List,

Today, trying to setup Clojure I downloaded 'leiningen.bat' from
(http://github.com/technomancy/leiningen/raw/master/bin/lein.bat) and
'self-install' fails:
  C:\Users\Bahman>lein self-install
  SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
  syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
  --2010-09-10 18:56:58-- 
http://github.com/downloads/technomancy/leiningen/leiningen-1.4.0-SNAPSHOT-standalone.jar
  Resolving github.com... 207.97.227.239
  Connecting to github.com|207.97.227.239|:80... connected.
  HTTP request sent, awaiting response... 404 Not Found
  2010-09-10 18:56:59 ERROR 404: Not Found.
  *** DOWNLOAD FAILED! Check URL/Version. ***


Also another strange thing is that when I open a command prompt and
enter 'lein self-install' it fails; I figured out I have to issue a
dummy 'lein new' first for 'self-install' to start.
  C:\Users\Bahman>lein self-install
  The syntax of the command is incorrect.

  C:\Users\Bahman>lein new t
  "C:\Applications\Leiningen\leiningen-1.4.0-SNAPSHOT-standalone.jar"
can not be found.
  You can try running "lein self-install"
  or change LEIN_JAR environment variable
  or edit lein.bat to set appropriate LEIN_JAR path.

  C:\Users\Bahman>lein self-install
  SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
  syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
  ...

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation & Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)




signature.asc
Description: OpenPGP digital signature


Re: Simple things should be simple

2010-09-10 Thread John Newman
Finally,

> cat - > /usr/local/www/apache22/cgi-bin/hello-world
>
> #!/usr/local/bin/clj
>
> (println "Content-type: text/plain\n")
> (println "Hello, World!")
> ^D

I can start using Clojure again :)

John

-- 
You 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 difficult Metaphor for Macros (especially for Java people)

2010-09-10 Thread lprefontaine
Adam Burry  wrote ..
> On Sep 9, 5:06 pm, alux  wrote:
> > But, @Luc
> > "pushing the advantage of Lisp
> > macros to the forefront is not obvious if the audience cannot compare
> > with another (good/simple) implementation they understand well."
> >
> > Thats why I want to use a nifty metaphor ;-)
> 
> Even your dumbest Java developer knows that javac (or ant, or maven,
> or Eclipse, or *something*) converts their source to JVM byte code.
> Finding a familiar example is not hard.

??? converting to byte code (machine instructions) has nothing to do with
macro processing... Macros can stand by themselves without being embedded
in a compiler (m4, ...)

Or perhaps I miss understood your statement ?

Luc P.

-- 
You 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: Simple things should be simple

2010-09-10 Thread cody koeninger


On Sep 10, 1:32 am, Mike Meyer  wrote:
> I think that Java's strength is enterprise-level, highly scalable web
> servers make people assume that every problem must be a nail for that
> hammer.

I think that Unix's strength is small independent programs
communicating over standard I/O makes you assume that every
environment must be a hammer for that nail.

The JVM environment is philosophically quite different from Unix.
Don't use a JVM language to write one-liners that have to be loaded
every time they're run.

There's not much point in people continuing to defend Clojure and/or
the java ecosystem; unix has its place and so does java.   You've
noticed a symptom of something fundamental in java, you're not
particularly happy about it, so choose a different tool.  Hashbang
script hacks, nailgun, or other workarounds aren't going to change
your mind.

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


What is ring/jetty doing with my *out*?

2010-09-10 Thread Colin Steele
It seems that when using ring/jetty, *out* is getting eaten or thrown
away.  I'm a n00b to clojure and the java world in general, but it
seems odd that (prn something) should silently fail?  I'm guessing
that I'm missing some configuration somewhere?  Help?  :)

--Colin

-- 
You 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-1.4.0-SNAPSHOT missing

2010-09-10 Thread Bahman Movaqar
 On 2010/9/10 19:07, Bahman Movaqar wrote:
>  Hi List,
>
> Today, trying to setup Clojure I downloaded 'leiningen.bat' from
> (http://github.com/technomancy/leiningen/raw/master/bin/lein.bat) and
> 'self-install' fails:
>   C:\Users\Bahman>lein self-install
>   SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
>   syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
>   --2010-09-10 18:56:58-- 
> http://github.com/downloads/technomancy/leiningen/leiningen-1.4.0-SNAPSHOT-standalone.jar
>   Resolving github.com... 207.97.227.239
>   Connecting to github.com|207.97.227.239|:80... connected.
>   HTTP request sent, awaiting response... 404 Not Found
>   2010-09-10 18:56:59 ERROR 404: Not Found.
>   *** DOWNLOAD FAILED! Check URL/Version. ***
>
>
> Also another strange thing is that when I open a command prompt and
> enter 'lein self-install' it fails; I figured out I have to issue a
> dummy 'lein new' first for 'self-install' to start.
>   C:\Users\Bahman>lein self-install
>   The syntax of the command is incorrect.
>
>   C:\Users\Bahman>lein new t
>   "C:\Applications\Leiningen\leiningen-1.4.0-SNAPSHOT-standalone.jar"
> can not be found.
>   You can try running "lein self-install"
>   or change LEIN_JAR environment variable
>   or edit lein.bat to set appropriate LEIN_JAR path.
>
>   C:\Users\Bahman>lein self-install
>   SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
>   syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
>   ...
>

Forgot to add that with some help on IRC I changed LEIN_VERSION to 1.3.1
and it worked.

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation & Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)




signature.asc
Description: OpenPGP digital signature


Re: What is ring/jetty doing with my *out*?

2010-09-10 Thread James Reeves
On 10 September 2010 15:39, Colin Steele  wrote:
> It seems that when using ring/jetty, *out* is getting eaten or thrown
> away.  I'm a n00b to clojure and the java world in general, but it
> seems odd that (prn something) should silently fail?  I'm guessing
> that I'm missing some configuration somewhere?  Help?  :)

*out* should be untouched. I regularly use prn from within the Jetty
adapter with no issue.

Can your reproduce the issue? Perhaps provide some cut-down example
that should print to *out* but doesn't?

- James

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


Re: Clojure 1.2 and the Computer Language Benchmarks Game

2010-09-10 Thread Isaac Gouy


On Sep 9, 10:15 pm, gary ng  wrote:
> On Thu, Sep 9, 2010 at 10:04 PM, Isaac Gouy  wrote:
> > Is there any point speculating about this as outsiders?
>
> > It was available - Data.HashTable seems to be copyright 2003.
>
> >http://ogi.altocumulus.org/~hallgren/Programatica/tools/pfe.cgi?Data
>
> Huh ? point ? it was just a casual comment, no point was intended. And
> I have read some comments by Don that what is in the shoutout is way
> faster than Data.HashTable


If you knew there was another option why write "I doubt there is any
choice for Haskell" ?


> >> And Data.HashTable also use some mutable array thing so it is still not
> >> the idiomatic Haskell of everything is immutable.
>
> > afaict idiomatic is everything referentially transparent not
> > everything immutable, as in - "I needed a halfway decent mutable
> > collection type – having a properly tested mutable collection that
> > actually performs well would be a godsend."
>
> how can you assure that(let's put aside the under the hood things
> where it is done in C) if you break the assumption that value can be
> changed.


Reading the first paragraph "Introduction to Uniqueness Typing" of
this paper should help you with that question -

http://www.st.cs.ru.nl/papers/2008/vrie08-IFL07-UniquenessTypingSimplified.pdf


> BTW, it seems that to verteran Haskellers, the speed of Data.HashTable
> is not a concern to them as they said they don't see the need of
> that(mutable hasktable) in their usage. There seems to be a bug(as in
> it is slow) filed for this package for quite a while but no one even
> bother to attempt to improve it.


I'm not going to speculate about what unnamed "verteran Haskellers"
have or have not said.

Read the bug report and you'll see that the root problem was GC - do
you think changing GC is a quick fix?

-- 
You 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: Macro problems with delay

2010-09-10 Thread joshua-choi
That ought to be correct, but I can't reconcile that with the error
message. Doesn't the "Can't embed object in code, maybe print-dup not
defined" error only appear in macros, when some object being spliced
into a macro's expansion is not a basic Clojure form? Yet, you are
correct, commenting out that function call in the macro does prevent
the error. I don't understand it.

Konrad Hinsen wrote:
> On 10 Sep 2010, at 03:11, joshua-choi wrote:
>
> > And here is a full macro-expansion of the call at which the error
> > happens:
> >
> > http://gist.github.com/572879
>
> If I understand the comment ("the following form is the culprit...")
> correctly, it's not the macroexpansion that fails, but the evaluation
> of the resulting expression. Is that correct? In that case, it's not
> really a macro problem, but a problem with a complex use case of alter-
> var-root.
>
> 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: A difficult Metaphor for Macros (especially for Java people)

2010-09-10 Thread Adam Burry
On Sep 10, 1:10 pm, lprefonta...@softaddicts.ca wrote:
> Adam Burry  wrote ..
>
> > On Sep 9, 5:06 pm, alux  wrote:
> > > But, @Luc
> > > "pushing the advantage of Lisp
> > > macros to the forefront is not obvious if the audience cannot compare
> > > with another (good/simple) implementation they understand well."
>
> > > Thats why I want to use a nifty metaphor ;-)
>
> > Even your dumbest Java developer knows that javac (or ant, or maven,
> > or Eclipse, or *something*) converts their source to JVM byte code.
> > Finding a familiar example is not hard.
>
> ??? converting to byte code (machine instructions) has nothing to do with
> macro processing... Macros can stand by themselves without being embedded
> in a compiler (m4, ...)
>
> Or perhaps I miss understood your statement ?

It has everything to do with macro processing. Macros convert one
expression into another. For example, depending on how your lisp is
set up:

(cond
  (case1 action1)
  (case2 action2)
  (case3 action3))

can map to:

(if case1 action1
  (if case2 action2
(if case3 action3 'nil)))

What do you think the compiler does?

Recall, the OP said:
  How do I describe what it is all about in this "Code is Data", and
"Macros let
you grow your own language towards the problem" stuff?

Well, Java is data to javac.

Adam

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

2010-09-10 Thread Stéphane Tavera
Hi everyone,

As a beginner in Clojure, I'm wondering if there is any kind of
Clojure User Group around Geneva ?
(If not, some friends of mine and I are willing to create one.)

Thanks in advance,
__
s t

-- 
You 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: Macro problems with delay

2010-09-10 Thread joshua-choi
You're right about the namespace-qualification: I accidentally
macroexpanded with syntax-quote rather than quote. My mistake; the
actual expansion is the same, but without namespace-qualification.

Using (var ~fn-name) results in the same error, unfortunately. I think
now the attempted embedding of a delay into macro code is somewhere
else, but I don't know.

Meikel Brandmeyer wrote:
> Hi,
>
> On 10 Sep., 03:11, joshua-choi  wrote:
>
> > I am running into a problem sometimes when I call a certain macro I
> > defined. This problem macro (and an associated problem function) is:
> >
> > http://gist.github.com/572875
> >
> > I run into this error (which is at a call to the macro, but *not* at
> > the *first* time it's called for some reason!):
> >
> > http://gist.github.com/572824
> >
> > And here is a full macro-expansion of the call at which the error
> > happens:
> >
> > http://gist.github.com/572879
> >
> > I *cannot* figure this out. The error seems to be that there's a delay
> > directly being embedded in some macro's form, but the delay call in
> > the function that's causing the problem…is in a function! How can the
> > delay show up at hound.clj's compile time?
>
> I must confess, I'm not sure, what's going on. However the expansion
> looks suspicious. Everything is namespace qualified.
>
> One thing core does differently to your approach is using the var
> special form. You might try:
>
> (defmacro general-defmaker
>   [def-form description rule-type-kw fn-name & forms]
>   `(do
>  (~def-form ~fn-name ~...@forms)
>  (alter-var-root (var ~fn-name) named-rule-maker ~rule-type-kw)
>  (var ~fn-name)))
>
> But this is just guessing. As I said above: everything is qualified.
> So maybe the problem is at some surrounding macro or so.
>
> 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: Leiningen-1.4.0-SNAPSHOT missing

2010-09-10 Thread Phil Hagelberg
On Fri, Sep 10, 2010 at 7:37 AM, Bahman Movaqar  wrote:
> Also another strange thing is that when I open a command prompt and
> enter 'lein self-install' it fails; I figured out I have to issue a
> dummy 'lein new' first for 'self-install' to start.
>  C:\Users\Bahman>lein self-install
>  The syntax of the command is incorrect.

I don't have Windows to test on, but the documentation for the Windows
installation was out of date; I just got a patch to fix it. Do the
current instructions work for you?

-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


clojure-test-mode elpa version still out of date?

2010-09-10 Thread User7

I'm using emacs starter kit and clojure-test-mode 1.4 installed using
elpa.  Running clojure-tests-run-tests seems to work fine, but clojure-
test-run-test seems flakey.  This blog post from May says the elpa
version is out of date.

http://otfrom.wordpress.com/2010/05/16/leiningen-clojure-1-2-and-emacs/

"However, now clojure-test-mode won’t work. The version is elpa isn’t
new enough (you are using elpa and emacs-starter-kit aren’t you?) so
we need to get it from technomancy’s github."

Does anybody know if the elpa version is still out of date?

-- 
You 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: Simple things should be simple

2010-09-10 Thread Raoul Duke
On Fri, Sep 10, 2010 at 1:27 AM, Laurent PETIT  wrote:
> These last few months, working on ccw has been particularly
> interesting because I've had feedback from users, especially Lee. Lee
> has challenged a lot of what I had considered to be "simple things" in
> ccw. I can say that when you're in a position of "expert", it's hard
> to change your mind, because at first, you reject the new user's
> points as invalid.

dang. well said, and needs to be said more!

somebody buy this man a thank you drink :)

-- 
You 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: Macro problems with delay

2010-09-10 Thread joshua-choi
I've solved the problem. I found that it only occurred when general-
defmaker was called with its forms argument containing another general-
defmaker call with def-form being defmacro. Thus, in the inner general-
defmaker call, the *result* of (NamedRule. (delay …)) was embedded
into a defmacro call, resulting in the error.

The solution was to change
(alter-var-root maker-var# named-rule-maker ~rule-type-kw)
to
(when (= '~def-form `defmacro)
  (alter-var-root maker-var# named-rule-maker ~rule-type-kw))

Thanks, everyone for your help.

joshua-choi wrote:
> That ought to be correct, but I can't reconcile that with the error
> message. Doesn't the "Can't embed object in code, maybe print-dup not
> defined" error only appear in macros, when some object being spliced
> into a macro's expansion is not a basic Clojure form? Yet, you are
> correct, commenting out that function call in the macro does prevent
> the error. I don't understand it.
>
> Konrad Hinsen wrote:
> > On 10 Sep 2010, at 03:11, joshua-choi wrote:
> >
> > > And here is a full macro-expansion of the call at which the error
> > > happens:
> > >
> > > http://gist.github.com/572879
> >
> > If I understand the comment ("the following form is the culprit...")
> > correctly, it's not the macroexpansion that fails, but the evaluation
> > of the resulting expression. Is that correct? In that case, it's not
> > really a macro problem, but a problem with a complex use case of alter-
> > var-root.
> >
> > 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: Macro problems with delay

2010-09-10 Thread joshua-choi
I've solved the problem. I found that it only occurred when general-
defmaker was called with its forms argument containing another general-
defmaker call with def-form being defmacro. Thus, in the inner general-
defmaker call, the *result* of (NamedRule. (delay …)) was embedded
into a defmacro call, resulting in the error.

The solution was to change
(alter-var-root maker-var# named-rule-maker ~rule-type-kw)
to
(when (= '~def-form `defmacro)
  (alter-var-root maker-var# named-rule-maker ~rule-type-kw))

Thanks, everyone for your help.

joshua-choi wrote:
> That ought to be correct, but I can't reconcile that with the error
> message. Doesn't the "Can't embed object in code, maybe print-dup not
> defined" error only appear in macros, when some object being spliced
> into a macro's expansion is not a basic Clojure form? Yet, you are
> correct, commenting out that function call in the macro does prevent
> the error. I don't understand it.
>
> Konrad Hinsen wrote:
> > On 10 Sep 2010, at 03:11, joshua-choi wrote:
> >
> > > And here is a full macro-expansion of the call at which the error
> > > happens:
> > >
> > > http://gist.github.com/572879
> >
> > If I understand the comment ("the following form is the culprit...")
> > correctly, it's not the macroexpansion that fails, but the evaluation
> > of the resulting expression. Is that correct? In that case, it's not
> > really a macro problem, but a problem with a complex use case of alter-
> > var-root.
> >
> > 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 1.2 and the Computer Language Benchmarks Game

2010-09-10 Thread gary ng
On Fri, Sep 10, 2010 at 8:49 AM, Isaac Gouy  wrote:
>> Huh ? point ? it was just a casual comment, no point was intended. And
>> I have read some comments by Don that what is in the shoutout is way
>> faster than Data.HashTable
>
>
> If you knew there was another option why write "I doubt there is any
> choice for Haskell" ?

That was referring to the original comment about 'making a mutable
implementation' meaning the program itself ASKED for that particular
functionality. The one in the shoutout is one implementation of it,
the one in Data.HashTable is another. When I said no choice, I was
saying no choice but to implement a mutable hash table, in respond to
the underlying message of 'why did they implement a mutable hashtable'
as if making it mutable is only for performance purpose.

>
>
>> >> And Data.HashTable also use some mutable array thing so it is still not
>> >> the idiomatic Haskell of everything is immutable.
>>
>> > afaict idiomatic is everything referentially transparent not
>> > everything immutable, as in - "I needed a halfway decent mutable
>> > collection type – having a properly tested mutable collection that
>> > actually performs well would be a godsend."
>>
>> how can you assure that(let's put aside the under the hood things
>> where it is done in C) if you break the assumption that value can be
>> changed.
>
>
> Reading the first paragraph "Introduction to Uniqueness Typing" of
> this paper should help you with that question -
>
> http://www.st.cs.ru.nl/papers/2008/vrie08-IFL07-UniquenessTypingSimplified.pdf
>
>
Would try to digest that.

> I'm not going to speculate about what unnamed "verteran Haskellers"
> have or have not said.
>
> Read the bug report and you'll see that the root problem was GC - do
> you think changing GC is a quick fix?
>
Don suggested on reddit for some fixes that tackle the GC issue(not
changing the GC, but the way to get around the performance caused by
GC), using similar approach as in the shoutout.

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


A Clojure "Scholarship": Let's send Raynes to the Conj!

2010-09-10 Thread Chas Emerick
With a huge helping hand from Relevance, the host of the Conj in  
October, I'm hoping we can make it possible for Anthony Simpson (you  
may know him as Raynes in #clojure irc) to attend the conference.


The blog post tells the story:

http://bit.ly/9dmeDe

I hope you'll check it out, and help in whatever small way you can.

Many thanks,

- Chas

--
You 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 ring/jetty doing with my *out*?

2010-09-10 Thread Colin Steele
Ahhh... I found it.  I was actually using "print" not "prn".
Switching to prn works! :) (flushing?)

On Sep 10, 11:30 am, James Reeves  wrote:
> On 10 September 2010 15:39, Colin Steele  wrote:
>
> > It seems that when using ring/jetty, *out* is getting eaten or thrown
> > away.  I'm a n00b to clojure and the java world in general, but it
> > seems odd that (prn something) should silently fail?  I'm guessing
> > that I'm missing some configuration somewhere?  Help?  :)
>
> *out* should be untouched. I regularly use prn from within the Jetty
> adapter with no issue.
>
> Can your reproduce the issue? Perhaps provide some cut-down example
> that should print to *out* but doesn't?
>
> - James

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


Re: Clojure 1.2 and the Computer Language Benchmarks Game

2010-09-10 Thread Isaac Gouy


On Sep 10, 10:35 am, gary ng  wrote:
> On Fri, Sep 10, 2010 at 8:49 AM, Isaac Gouy  wrote:
> >> Huh ? point ? it was just a casual comment, no point was intended. And
> >> I have read some comments by Don that what is in the shoutout is way
> >> faster than Data.HashTable
>
> > If you knew there was another option why write "I doubt there is any
> > choice for Haskell" ?
>
> That was referring to the original comment about 'making a mutable
> implementation' meaning the program itself ASKED for that particular
> functionality. The one in the shoutout is one implementation of it,
> the one in Data.HashTable is another. When I said no choice, I was
> saying no choice but to implement a mutable hash table, in respond to
> the underlying message of 'why did they implement a mutable hashtable'
> as if making it mutable is only for performance purpose.


Clearly, they did choose "to write all that code" "in order to get a
much faster program" - I can't tell you if Andy had noticed the
benchmark was about "Hashtable update and k-nucleotide strings" or
whether he knew about Data.HashTable.


> >> >> And Data.HashTable also use some mutable array thing so it is still not
> >> >> the idiomatic Haskell of everything is immutable.
>
> >> > afaict idiomatic is everything referentially transparent not
> >> > everything immutable, as in - "I needed a halfway decent mutable
> >> > collection type – having a properly tested mutable collection that
> >> > actually performs well would be a godsend."
>
> >> how can you assure that(let's put aside the under the hood things
> >> where it is done in C) if you break the assumption that value can be
> >> changed.
>
> > Reading the first paragraph "Introduction to Uniqueness Typing" of
> > this paper should help you with that question -
>
> >http://www.st.cs.ru.nl/papers/2008/vrie08-IFL07-UniquenessTypingSimpl...
>
> Would try to digest that.

Bite-sized:

"An important property of pure functional programming languages is
referential transparency: the same expression used twice must have the
same value twice."

"A side effect on a variable (file) is okay as long as that variable
is never used again: it is okay for a function to modify its input if
the input is not shared. Referential transparency then trivially holds
because the same expression never occurs more than once."

"Rather than just returning the read character, fgetc returns a pair
consisting of the read character and a new file, file1. Although file0
and file1 point to the same file on disk, they are conceptually and
syntactically different, and thus it is clear that a and b may have
different values."


> > I'm not going to speculate about what unnamed "verteran Haskellers"
> > have or have not said.
>
> > Read the bug report and you'll see that the root problem was GC - do
> > you think changing GC is a quick fix?
>
> Don suggested on reddit for some fixes that tackle the GC issue(not
> changing the GC, but the way to get around the performance caused by
> GC), using similar approach as in the shoutout.

-- 
You 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-1.4.0-SNAPSHOT missing

2010-09-10 Thread Bahman Movaqar
 On 2010/9/10 21:42, Phil Hagelberg wrote:
> On Fri, Sep 10, 2010 at 7:37 AM, Bahman Movaqar  wrote:
>> Also another strange thing is that when I open a command prompt and
>> enter 'lein self-install' it fails; I figured out I have to issue a
>> dummy 'lein new' first for 'self-install' to start.
>>  C:\Users\Bahman>lein self-install
>>  The syntax of the command is incorrect.
> I don't have Windows to test on, but the documentation for the Windows
> installation was out of date; I just got a patch to fix it. Do the
> current instructions work for you?
>
>

No.  I changed the file a bit to make it work and also remove the
trivial bug I earlier mentioned and it works for me.
I attach the file.

Thanks,

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation & Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)

@echo off

set LEIN_VERSION=1.3.1

rem it is possible to set LEIN_JAR variable manually
rem so we don't overwrite them
if "x%LEIN_JAR%" neq "x" goto LEIN_JAR_SET

set LEIN_DIR=%~dp0
set LEIN_JAR=%LEIN_DIR%leiningen-%LEIN_VERSION%-standalone.jar


:LEIN_JAR_SET
if "x%1" == "xself-install" goto SELF_INSTALL
if "x%1" == "xupgrade"  goto NO_UPGRADE

rem If the command is not 'self-install' or 'upgrade' then check for LEIN_JAR 
first.
if not exist "%LEIN_JAR%" goto NO_LEIN_JAR


rem ##
rem count number of command line arguments
rem
set ARGCOUNT=0
for %%a in (%*) do set /a ARGCOUNT+=1
rem ##


rem ##
rem add jars found under "lib" directory to CLASSPATH
rem

call :FIND_DIR_CONTAINING_UPWARDS project.clj

if "%DIR_CONTAINING%" neq "" cd "%DIR_CONTAINING%"

setLocal EnableDelayedExpansion
set CP="
for /R ./lib %%a in (*.jar) do (
   set CP=!CP!;%%a
)
set CP=!CP!"

set CLASSPATH="%LEIN_JAR%";%CP%;"%CLASSPATH%"
if "x%DEBUG%" == "x" goto RUN
echo CLASSPATH=%CLASSPATH%
rem ##

:RUN
if "x%1" == "xrepl" goto RUN_REPL
if "%ARGCOUNT%" == "2" goto RUN_ARG2
if "%ARGCOUNT%" == "3" goto RUN_ARG3
java -client -cp %CLASSPATH% clojure.main -e "(use 'leiningen.core) (-main 
\"%1\")"
goto EOF

:RUN_ARG2
java -client -cp %CLASSPATH% clojure.main -e "(use 'leiningen.core) (-main 
\"%1\" \"%2\")"
goto EOF

:RUN_ARG3
java -client -cp %CLASSPATH% clojure.main -e "(use 'leiningen.core) (-main 
\"%1\" \"%2\" \"%3\")"
goto EOF

:RUN_REPL
%RLWRAP% java -client %JAVA_OPTS% -cp src;classes;%CLASSPATH% clojure.main %2 
%3 %4
goto EOF

:NO_LEIN_JAR
echo.
echo "%LEIN_JAR%" can not be found.
echo You can try running "lein self-install"
echo or change LEIN_JAR environment variable
echo or edit lein.bat to set appropriate LEIN_JAR path.
echo. 
goto EOF

:SELF_INSTALL
if exist %LEIN_JAR% (
echo "15"
echo %LEIN_JAR% already exists. Delete and retry.
echo "17"
goto EOF
)
set HTTP_CLIENT=wget -O
wget>nul 2>&1
if ERRORLEVEL 9009 (
curl>nul 2>&1
if ERRORLEVEL 9009 goto NO_HTTP_CLIENT
set HTTP_CLIENT=curl -f -L -o
)
set LEIN_DIR=%~dp0
set LEIN_JAR=%LEIN_DIR%leiningen-%LEIN_VERSION%-standalone.jar
set 
LEIN_JAR_URL=http://github.com/downloads/technomancy/leiningen/leiningen-%LEIN_VERSION%-standalone.jar
%HTTP_CLIENT% %LEIN_JAR% %LEIN_JAR_URL%
if ERRORLEVEL 1 (
del %LEIN_JAR%>nul 2>&1
goto DOWNLOAD_FAILED
)
goto EOF

:DOWNLOAD_FAILED
echo.
echo *** DOWNLOAD FAILED! Check URL/Version. ***
echo.
goto EOF

:NO_HTTP_CLIENT
echo.
echo ERROR: Wget/Curl not found. Make sure at least either of Wget and Curl is
echoinstalled and is in PATH. You can get them from URLs below:
echo.
echo Wget: "http://users.ugent.be/~bpuype/wget/";
echo Curl: "http://curl.haxx.se/dlwiz/?type=bin&os=Win32&flav=-&ver=2000/XP";
echo.
goto EOF

:NO_UPGRADE
echo.
echo Upgrade feature is not available on Windows. Please edit the value of
echo variable LEIN_VERSION in file %~f0
echo then run "lein self-install".
echo.
goto EOF


rem Find directory containing filename supplied in first argument
rem looking in current directory, and looking up the parent
rem chain until we find it, or run out
rem returns result in %DIR_CONTAINING%
rem empty string if we don't find it
:FIND_DIR_CONTAINING_UPWARDS
set DIR_CONTAINING=%CD%
set LAST_DIR=

:LOOK_AGAIN
if "%DIR_CONTAINING%" == "%LAST_DIR%" (
rem didn't find it
set DIR_CONTAINING=
goto :EOF
)

if EXIST "%DIR_CONTAINING%\%1" (
rem found it - use result in DIR_CONTAINING
goto :EOF
)

set LAST_DIR=%DIR_CONTAINING%
call :GET_PARENT_PATH "%DIR_CONTAINING%\.."
set DIR_CONTAINING=%PARENT_PATH%
goto :LOOK_AGAIN

:GET_PARENT_PATH
set PARENT_PATH=%~f1
goto :EOF

:EOF


signature.asc
Description: OpenPGP digital signature


Re: Leiningen-1.4.0-SNAPSHOT missing

2010-09-10 Thread Bahman Movaqar
 On 2010/9/10 21:42, Phil Hagelberg wrote:
> On Fri, Sep 10, 2010 at 7:37 AM, Bahman Movaqar  wrote:
>> Also another strange thing is that when I open a command prompt and
>> enter 'lein self-install' it fails; I figured out I have to issue a
>> dummy 'lein new' first for 'self-install' to start.
>>  C:\Users\Bahman>lein self-install
>>  The syntax of the command is incorrect.
> I don't have Windows to test on, but the documentation for the Windows
> installation was out of date; I just got a patch to fix it. Do the
> current instructions work for you?
>
>

Once again I forgot to add that: Yes, the download section is working as
expected.  Thank you.

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation & Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)




signature.asc
Description: OpenPGP digital signature


Re: clojure-test-mode elpa version still out of date?

2010-09-10 Thread User7

I downloaded clojure-mode from http://github.com/technomancy/clojure-mode
and installed both clojure-mode.el and clojure-test-mode.el using M-x
package-install-from-buffer.  On the following set of tests, M-x
clojure-test-run-tests seems to work, but M-x clojure-test-run-test on
just the pass function seems to run against the entire file and (is
false "No tests have been written." gets highlighted red in the
buffer).

(ns test-test.test.core
  (:use [clojure.test]))

(deftest pass
  (is true "This test should pass."))

(deftest replace-me ;; FIXME: write
  (is false "No tests have been written."))

The History section in clojure-test-mode.el contains

;; 1.4: 2010-05-13
;;  * Fix jump-to-test
;;  * Update to work with Clojure 1.2.
;;  * Added next/prev problem.
;;  * Depend upon slime, not swank-clojure.
;;  * Don't move the mark when activating.



-- 
You 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.2 and the Computer Language Benchmarks Game

2010-09-10 Thread gary ng
On Fri, Sep 10, 2010 at 11:13 AM, Isaac Gouy  wrote:
> Clearly, they did choose "to write all that code" "in order to get a
> much faster program" - I can't tell you if Andy had noticed the
> benchmark was about "Hashtable update and k-nucleotide strings" or
> whether he knew about Data.HashTable.

I know they did it to get a faster program, but under the requirement of :

IT MUST BE MUTABLE HASHTABLE

If you change the requirement to something else that acheives the end
result without this specific requirement, they may not use hashtable
at all. Which is also the message I get from various place like reddit
or stackoverlow about this same issue. That is 'use your language's
strength to solve the problem, not to mimic other language, i.e. the
what not the how'.

And this sentiment is not unique to Haskell. I recently saw similar
questions on J language of 'how can I write a Haskell style
filter(HOF)', the overall answers there are 'you don't need haskell
style filter and can achieve the same result in a J way'. Similarly
for Haskell which is 'you don't need to use mutable hash table and can
very likely get the same result using other immutable data structure'

But in this case the problem is 'implement a mutable hashtable'  which
is what my 'no choice' was referring to. Unlike language say Python or
F# where hash table is in general considered to be part of the
language, Data.HashTable is not. It is just one 'sample' of
implementation of mutable hash table which happens to be slow.

>
>
>> >> >> And Data.HashTable also use some mutable array thing so it is still not
>> >> >> the idiomatic Haskell of everything is immutable.
>>
>> >> > afaict idiomatic is everything referentially transparent not
>> >> > everything immutable, as in - "I needed a halfway decent mutable
>> >> > collection type – having a properly tested mutable collection that
>> >> > actually performs well would be a godsend."
>>
>> >> how can you assure that(let's put aside the under the hood things
>> >> where it is done in C) if you break the assumption that value can be
>> >> changed.
>>
>> > Reading the first paragraph "Introduction to Uniqueness Typing" of
>> > this paper should help you with that question -
>>
>> >http://www.st.cs.ru.nl/papers/2008/vrie08-IFL07-UniquenessTypingSimpl...
>>
>> Would try to digest that.
>
> Bite-sized:
>
> "An important property of pure functional programming languages is
> referential transparency: the same expression used twice must have the
> same value twice."
>
> "A side effect on a variable (file) is okay as long as that variable
> is never used again: it is okay for a function to modify its input if
> the input is not shared. Referential transparency then trivially holds
> because the same expression never occurs more than once."
>
> "Rather than just returning the read character, fgetc returns a pair
> consisting of the read character and a new file, file1. Although file0
> and file1 point to the same file on disk, they are conceptually and
> syntactically different, and thus it is clear that a and b may have
> different values."
>

I read this part, trying to fit that into this mutable hashtable
context. Below this paragraph, it mentioned some
requirement/assumption that file0, file1 ... cannot be 're-used' which
I don't know how to apply to hashtable.

-- 
You 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 Clojure "Scholarship": Let's send Raynes to the Conj!

2010-09-10 Thread Alan
Did we really get this done in an hour? I haven't been part of the
community for long, but Rayne has been helpful to me already on
#clojure so I was going to donate a bit. Did I already miss my chance?

On Sep 10, 10:39 am, Chas Emerick  wrote:
> With a huge helping hand from Relevance, the host of the Conj in  
> October, I'm hoping we can make it possible for Anthony Simpson (you  
> may know him as Raynes in #clojure irc) to attend the conference.
>
> The blog post tells the story:
>
> http://bit.ly/9dmeDe
>
> I hope you'll check it out, and help in whatever small way you can.
>
> Many thanks,
>
> - Chas

-- 
You 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 Clojure "Scholarship": Let's send Raynes to the Conj!

2010-09-10 Thread Sean Devlin
Welcome to Clojure

On Sep 10, 2:55 pm, Alan  wrote:
> Did we really get this done in an hour? I haven't been part of the
> community for long, but Rayne has been helpful to me already on
> #clojure so I was going to donate a bit. Did I already miss my chance?
>
> On Sep 10, 10:39 am, Chas Emerick  wrote:
>
> > With a huge helping hand from Relevance, the host of the Conj in  
> > October, I'm hoping we can make it possible for Anthony Simpson (you  
> > may know him as Raynes in #clojure irc) to attend the conference.
>
> > The blog post tells the story:
>
> >http://bit.ly/9dmeDe
>
> > I hope you'll check it out, and help in whatever small way you can.
>
> > Many thanks,
>
> > - Chas

-- 
You 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: testing local functions?

2010-09-10 Thread Brian Marick
I've worked out a way to test local functions. When I tried it out by hand, it 
felt good. See here: http://bit.ly/b1AoG7

Implementing it is on my wishlist for Midje, my test framework. 
http://github.com/marick/Midje



On Sep 10, 2010, at 6:24 AM, alux wrote:

> Hello,
> 
> I always thought it to be good style to make helper functions only as
> visible as needed, e.g. by using letfn.
> 
> But when I want to test my code, I just dont see a way to access these
> local functions for tests.



-
Brian Marick, independent consultant
Mostly on agile methods with a testing slant
Author of /Programming Cocoa with Ruby/
www.exampler.com, www.exampler.com/blog, www.twitter.com/marick

-- 
You 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 Clojure "Scholarship": Let's send Raynes to the Conj!

2010-09-10 Thread Chas Emerick
Just a little over an hour, yes!  Raynes is going to the Conj.  Thanks  
to all who donated.


More info, numbers, and more thank-yous here:

http://bit.ly/aj0XPr

And, if you *wanted* to donate, but ended up coming in after we hit  
our goal, please read the above post anyway. :-)


Thanks again to all!

- Chas

On Sep 10, 2010, at 2:55 PM, Alan wrote:


Did we really get this done in an hour? I haven't been part of the
community for long, but Rayne has been helpful to me already on
#clojure so I was going to donate a bit. Did I already miss my chance?

On Sep 10, 10:39 am, Chas Emerick  wrote:

With a huge helping hand from Relevance, the host of the Conj in
October, I'm hoping we can make it possible for Anthony Simpson (you
may know him as Raynes in #clojure irc) to attend the conference.

The blog post tells the story:

http://bit.ly/9dmeDe

I hope you'll check it out, and help in whatever small way you can.

Many thanks,

- Chas


--
You 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: Simple things should be simple

2010-09-10 Thread Mike Meyer
On Fri, 10 Sep 2010 00:03:22 -0700 (PDT)
Meikel Brandmeyer  wrote:

> Hi,
> 
> On 9 Sep., 20:46, Mike Meyer  620...@mired.org> wrote:
> 
> > The first problem with that is that this stuff seems show up
> > *everywhere* in Javaland. It's not just web apps, it's pretty much
> > anything.
> 
> You just lost me completely with your argumentation. I wrote a small
> desktop utility (simple problem, simple solution, simple program)
> which is distributed to different locations in the company. It works
> on Windows and Unix w/o adaption to the system. Download jar and
> double-click / execute via java -jar. It works without library version
> hell, complicated Makefiles, system differences and other shenanigans.
> I'm quite willing to pay more complexity upfront to have it easier in
> the end.

Ok, let's see how this goes:

With simple things are simple tools, for a simple problem with a
simple solution and a simple program, the solution goes like this:

1) Write program in chosen unix-friendly interpreted language.
2) Distribute program text file.

Users can then run it via double-clicking (mac & windows), running it
directly on the command line (mac & unix) or - under extreme duress -
running it via the interpreter on the command line.

As far as I can tell, to do the same thing with Java tools, the steps
are:

1) Write program in chosen language that runs on the JVM.
2) Compile program to class file(s).
3) Use some tool to create a manifest file.
4) Run jar to create jar file.
5) Distribute jar file.

Users can then run it via double-clicking (mac & windows) or via the
interpreter on the command line (mac & unix). There is no option to
run it directly on the command line.

Possibly some tool will do steps 3 and 4 in single step for you.  So
the Javaland tools take at least twice as many steps, and deliver a
solution that's harder to use in some cases. Of course, I'm not as
familiar with Javaland tools as I am Unix tools, so maybe I got it
wrong. If so, *please* tell me the better way!

> It is obvious that Clojure doesn't fit your needs. Then simply don't
> use it.

Wrong. It may be that the Java infrastructure that Clojure runs in is
baroque enough that I won't be willing to use it. Then the same would
be true of any language running on the JVM. On the other hand, a
Clojure that ran on, oh, Parrot just for instance, wouldn't have any
of these problems.

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 Clojure "Scholarship": Let's send Raynes to the Conj!

2010-09-10 Thread Rayne
I wrote a brief thank you post on my blog (actually the first post on
this new blog. :>) 
http://blog.acidrayne.net/thank-you-for-sending-me-to-the-conj

I'm unbelievably excited. I love you guys.

On Sep 10, 2:09 pm, Chas Emerick  wrote:
> Just a little over an hour, yes!  Raynes is going to the Conj.  Thanks  
> to all who donated.
>
> More info, numbers, and more thank-yous here:
>
> http://bit.ly/aj0XPr
>
> And, if you *wanted* to donate, but ended up coming in after we hit  
> our goal, please read the above post anyway. :-)
>
> Thanks again to all!
>
> - Chas
>
> On Sep 10, 2010, at 2:55 PM, Alan wrote:
>
>
>
> > Did we really get this done in an hour? I haven't been part of the
> > community for long, but Rayne has been helpful to me already on
> > #clojure so I was going to donate a bit. Did I already miss my chance?
>
> > On Sep 10, 10:39 am, Chas Emerick  wrote:
> >> With a huge helping hand from Relevance, the host of the Conj in
> >> October, I'm hoping we can make it possible for Anthony Simpson (you
> >> may know him as Raynes in #clojure irc) to attend the conference.
>
> >> The blog post tells the story:
>
> >>http://bit.ly/9dmeDe
>
> >> I hope you'll check it out, and help in whatever small way you can.
>
> >> Many thanks,
>
> >> - Chas
>
> > --
> > You 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: Simple things should be simple

2010-09-10 Thread Mike Meyer
On Fri, 10 Sep 2010 07:11:18 -0700
gary ng  wrote:

> On Fri, Sep 10, 2010 at 4:47 AM, John Cromartie  wrote:
> > #!/usr/local/bin/clj
> >
> > (println "Content-type: text/plain\n")
> > (println "Hello, World!")
> > ^D
> >
> > Is that simple enough?
> >
> That was my thought too, java/clojure console app should not be more
> complex than python etc. The issue is the startup time
> 
> > For better startup performance, you can use Nailgun.
> 
> How can nailjun help here ? I am not too familiar with it.

Nailgun is a "java server", for want of a better term. You start it
with the classpath you want. You then run a front end that you pass
the classname & arguments you'd normally hand to java, and it runs
them. Instead of exiting when they end, it hangs around so the next
time you run it, you don't have to reload the classes.

  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


Generating functions programmatically

2010-09-10 Thread icemaze
Hi, I'm developing a small DSL with Clojure and I need to define many
similar functions. I'd like to do that programmatically, of course.

My solution (involving a simple macro) doesn't work, so I won't bother
you with it. I'll post it if anyone asks.

Basically what I need is: given a list of keywords, for each keyword x
i need to define a function whose name is (str "prefix-" (name x)).
The function has a very short body which uses x in one place
(something like (fn [n] (= n x))).

Can you help me please? I've been banging my head against this for
over four hours and I'm getting a little frustrated.

Thanks.

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

2010-09-10 Thread Cyrus Harmon

This still doesn't quite add up to me. What's the consequence of not 
alter-var-root'ing maker-var# if def-form is a defmacro? Why would def-form be 
a defmacro in the first place?

Also, I don't think you've given the example of the actual call that gave the 
error, only the macroexpansion of it. Can you provide that as well?

thanks,

Cyrus 

On Sep 10, 2010, at 10:30 AM, joshua-choi wrote:

> I've solved the problem. I found that it only occurred when general-
> defmaker was called with its forms argument containing another general-
> defmaker call with def-form being defmacro. Thus, in the inner general-
> defmaker call, the *result* of (NamedRule. (delay …)) was embedded
> into a defmacro call, resulting in the error.
> 
> The solution was to change
>(alter-var-root maker-var# named-rule-maker ~rule-type-kw)
> to
>(when (= '~def-form `defmacro)
>  (alter-var-root maker-var# named-rule-maker ~rule-type-kw))
> 
> Thanks, everyone for your help.
> 
> joshua-choi wrote:
>> That ought to be correct, but I can't reconcile that with the error
>> message. Doesn't the "Can't embed object in code, maybe print-dup not
>> defined" error only appear in macros, when some object being spliced
>> into a macro's expansion is not a basic Clojure form? Yet, you are
>> correct, commenting out that function call in the macro does prevent
>> the error. I don't understand it.
>> 
>> Konrad Hinsen wrote:
>>> On 10 Sep 2010, at 03:11, joshua-choi wrote:
>>> 
 And here is a full macro-expansion of the call at which the error
 happens:
 
 http://gist.github.com/572879
>>> 
>>> If I understand the comment ("the following form is the culprit...")
>>> correctly, it's not the macroexpansion that fails, but the evaluation
>>> of the resulting expression. Is that correct? In that case, it's not
>>> really a macro problem, but a problem with a complex use case of alter-
>>> var-root.
>>> 
>>> 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

-- 
You 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 Clojure "Scholarship": Let's send Raynes to the Conj!

2010-09-10 Thread Rayne
Just told that the site went down: not sure why, but I'll work on it
later. Sorry. <3

On Sep 10, 2:21 pm, Rayne  wrote:
> I wrote a brief thank you post on my blog (actually the first post on
> this new blog. 
> :>)http://blog.acidrayne.net/thank-you-for-sending-me-to-the-conj
>
> I'm unbelievably excited. I love you guys.
>
> On Sep 10, 2:09 pm, Chas Emerick  wrote:
>
>
>
> > Just a little over an hour, yes!  Raynes is going to the Conj.  Thanks  
> > to all who donated.
>
> > More info, numbers, and more thank-yous here:
>
> >http://bit.ly/aj0XPr
>
> > And, if you *wanted* to donate, but ended up coming in after we hit  
> > our goal, please read the above post anyway. :-)
>
> > Thanks again to all!
>
> > - Chas
>
> > On Sep 10, 2010, at 2:55 PM, Alan wrote:
>
> > > Did we really get this done in an hour? I haven't been part of the
> > > community for long, but Rayne has been helpful to me already on
> > > #clojure so I was going to donate a bit. Did I already miss my chance?
>
> > > On Sep 10, 10:39 am, Chas Emerick  wrote:
> > >> With a huge helping hand from Relevance, the host of the Conj in
> > >> October, I'm hoping we can make it possible for Anthony Simpson (you
> > >> may know him as Raynes in #clojure irc) to attend the conference.
>
> > >> The blog post tells the story:
>
> > >>http://bit.ly/9dmeDe
>
> > >> I hope you'll check it out, and help in whatever small way you can.
>
> > >> Many thanks,
>
> > >> - Chas
>
> > > --
> > > You 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: Generating functions programmatically

2010-09-10 Thread Alan
I actually did this just the other day, to create a simple C-style
enum macro (I assume someone has a better version; this was a learning
exercise). You can see my project at www.github.com/amalloy/enum. It
sounds like your problem might be constructing the symbol to define;
the solution will look something like:

(let [fn-sym (->> name (str "prefix-") symbol)]
  `(defn ~fn-sym [args] body))

On Sep 10, 12:39 pm, icemaze  wrote:
> Hi, I'm developing a small DSL with Clojure and I need to define many
> similar functions. I'd like to do that programmatically, of course.
>
> My solution (involving a simple macro) doesn't work, so I won't bother
> you with it. I'll post it if anyone asks.
>
> Basically what I need is: given a list of keywords, for each keyword x
> i need to define a function whose name is (str "prefix-" (name x)).
> The function has a very short body which uses x in one place
> (something like (fn [n] (= n x))).
>
> Can you help me please? I've been banging my head against this for
> over four hours and I'm getting a little frustrated.
>
> Thanks.

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

2010-09-10 Thread Alan
SPOILER BELOW. I'm not sure how much help you want, so I went ahead
and wrote your macro. Whitespace padding so that you won't see it if
you don't want the whole solution:











user=> (defmacro make-fn [key]
(let [sym (->> key name (str "synthetic-") symbol)]
  `(defn ~sym [n#] (= n# ~key
#'user/make-fn
user=> (make-fn :a)
#'user/synthetic-a
user=> (synthetic-a :q)
false
user=> (synthetic-a :a)
true
user=> (macroexpand '(make-fn :a))
(def synthetic-a (.withMeta (clojure.core/fn synthetic-a
([n__1041__auto__] (clojure.core/= n__1041__auto__ :a))) (.meta (var
synthetic-a

On Sep 10, 1:02 pm, Alan  wrote:
> I actually did this just the other day, to create a simple C-style
> enum macro (I assume someone has a better version; this was a learning
> exercise). You can see my project atwww.github.com/amalloy/enum. It
> sounds like your problem might be constructing the symbol to define;
> the solution will look something like:
>
> (let [fn-sym (->> name (str "prefix-") symbol)]
>   `(defn ~fn-sym [args] body))
>
> On Sep 10, 12:39 pm, icemaze  wrote:
>
> > Hi, I'm developing a small DSL with Clojure and I need to define many
> > similar functions. I'd like to do that programmatically, of course.
>
> > My solution (involving a simple macro) doesn't work, so I won't bother
> > you with it. I'll post it if anyone asks.
>
> > Basically what I need is: given a list of keywords, for each keyword x
> > i need to define a function whose name is (str "prefix-" (name x)).
> > The function has a very short body which uses x in one place
> > (something like (fn [n] (= n x))).
>
> > Can you help me please? I've been banging my head against this for
> > over four hours and I'm getting a little frustrated.
>
> > Thanks.
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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 Clojure "Scholarship": Let's send Raynes to the Conj!

2010-09-10 Thread Alan
It's working for me now (but wasn't earlier, so this is probably a
sign that it's fixed).

On Sep 10, 12:57 pm, Rayne  wrote:
> Just told that the site went down: not sure why, but I'll work on it
> later. Sorry. <3
>
> On Sep 10, 2:21 pm, Rayne  wrote:
>
> > I wrote a brief thank you post on my blog (actually the first post on
> > this new blog. 
> > :>)http://blog.acidrayne.net/thank-you-for-sending-me-to-the-conj
>
> > I'm unbelievably excited. I love you guys.
>
> > On Sep 10, 2:09 pm, Chas Emerick  wrote:
>
> > > Just a little over an hour, yes!  Raynes is going to the Conj.  Thanks  
> > > to all who donated.
>
> > > More info, numbers, and more thank-yous here:
>
> > >http://bit.ly/aj0XPr
>
> > > And, if you *wanted* to donate, but ended up coming in after we hit  
> > > our goal, please read the above post anyway. :-)
>
> > > Thanks again to all!
>
> > > - Chas
>
> > > On Sep 10, 2010, at 2:55 PM, Alan wrote:
>
> > > > Did we really get this done in an hour? I haven't been part of the
> > > > community for long, but Rayne has been helpful to me already on
> > > > #clojure so I was going to donate a bit. Did I already miss my chance?
>
> > > > On Sep 10, 10:39 am, Chas Emerick  wrote:
> > > >> With a huge helping hand from Relevance, the host of the Conj in
> > > >> October, I'm hoping we can make it possible for Anthony Simpson (you
> > > >> may know him as Raynes in #clojure irc) to attend the conference.
>
> > > >> The blog post tells the story:
>
> > > >>http://bit.ly/9dmeDe
>
> > > >> I hope you'll check it out, and help in whatever small way you can.
>
> > > >> Many thanks,
>
> > > >> - Chas
>
> > > > --
> > > > You 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: testing local functions?

2010-09-10 Thread alux
Brian, thats way cool!

(I still have to think this through, thats high magic!)

Thank you for sharing this, and kind regards, alux

On 10 Sep., 21:04, Brian Marick  wrote:
> I've worked out a way to test local functions. When I tried it out by hand, 
> it felt good. See here:http://bit.ly/b1AoG7
>
> Implementing it is on my wishlist for Midje, my test 
> framework.http://github.com/marick/Midje
>
> On Sep 10, 2010, at 6:24 AM, alux wrote:
>
> > Hello,
>
> > I always thought it to be good style to make helper functions only as
> > visible as needed, e.g. by using letfn.
>
> > But when I want to test my code, I just dont see a way to access these
> > local functions for tests.
>
> -
> Brian Marick, independent consultant
> Mostly on agile methods with a testing slant
> Author of /Programming Cocoa with 
> Ruby/www.exampler.com,www.exampler.com/blog,www.twitter.com/marick

-- 
You 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: Generating functions programmatically

2010-09-10 Thread icemaze
Alan, thank you for your reply.
Unfortunately your solution is very similar to mine and it suffers
from the same problem (maybe I'm using it incorrectly, I don't know).
If I write:

  (doseq [x '(:a :b)]
(make-fn x))

it defines a single function "synthetic-x". Is there a way to make
this work? I tried everything but both eval and var-get don't work for
local bindings.

Thanks again.

-- 
You 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: Simple things should be simple

2010-09-10 Thread Phil Hagelberg
On Fri, Sep 10, 2010 at 12:17 PM, Mike Meyer
 wrote:
> 1) Write program in chosen language that runs on the JVM.
> 2) Compile program to class file(s).
> 3) Use some tool to create a manifest file.
> 4) Run jar to create jar file.
> 5) Distribute jar file.
>
> Users can then run it via double-clicking (mac & windows) or via the
> interpreter on the command line (mac & unix). There is no option to
> run it directly on the command line.

It's true that the command-line situation with java is awful. Here's
one solution that does a pretty good job of promoting the JVM to a
first-class CLI citizen:

http://hashdot.sourceforge.net/

Of course, it would also help a lot if Clojure shipped with its own
shell script.

-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: Clojure 1.2 and the Computer Language Benchmarks Game

2010-09-10 Thread Isaac Gouy


On Sep 10, 11:54 am, gary ng  wrote:
> On Fri, Sep 10, 2010 at 11:13 AM, Isaac Gouy  wrote:
> > Clearly, they did choose "to write all that code" "in order to get a
> > much faster program" - I can't tell you if Andy had noticed the
> > benchmark was about "Hashtable update and k-nucleotide strings" or
> > whether he knew about Data.HashTable.
>
> I know they did it to get a faster program, but under the requirement of :
>
> IT MUST BE MUTABLE HASHTABLE
>
> If you change the requirement to something else that acheives the end
> result without this specific requirement, they may not use hashtable
> at all. Which is also the message I get from various place like reddit
> or stackoverlow about this same issue. That is 'use your language's
> strength to solve the problem, not to mimic other language, i.e. the
> what not the how'.


It's starting to look like actually there was a point you wanted to
make ;-)

If you change the requirement to something else you'd simply be
missing the point - which was to look at hashtable updates and
strings.

Does it actually say that the hashtable updates have to be
destructive?


> And this sentiment is not unique to Haskell. I recently saw similar
> questions on J language of 'how can I write a Haskell style
> filter(HOF)', the overall answers there are 'you don't need haskell
> style filter and can achieve the same result in a J way'. Similarly
> for Haskell which is 'you don't need to use mutable hash table and can
> very likely get the same result using other immutable data structure'
>
> But in this case the problem is 'implement a mutable hashtable'  which
> is what my 'no choice' was referring to. Unlike language say Python or
> F# where hash table is in general considered to be part of the
> language, Data.HashTable is not. It is just one 'sample' of
> implementation of mutable hash table which happens to be slow.


There's no choice in binary-trees either - you must use binary-trees
and you must allocate all the memory.

There's no choice in pi-digits either - you must use that particular
step-by-step spigot algorithm taken from that Haskell paper.

There's no choice in fannkuch-redux either - you must use that
particular ordering of permutations taken from that Lisp paper.

etc etc

Forgive me but you do seem to be belabouring the obvious.


-snip-
> > Bite-sized:
>
> > "An important property of pure functional programming languages is
> > referential transparency: the same expression used twice must have the
> > same value twice."
>
> > "A side effect on a variable (file) is okay as long as that variable
> > is never used again: it is okay for a function to modify its input if
> > the input is not shared. Referential transparency then trivially holds
> > because the same expression never occurs more than once."
>
> > "Rather than just returning the read character, fgetc returns a pair
> > consisting of the read character and a new file, file1. Although file0
> > and file1 point to the same file on disk, they are conceptually and
> > syntactically different, and thus it is clear that a and b may have
> > different values."
>
> I read this part, trying to fit that into this mutable hashtable
> context. Below this paragraph, it mentioned some
> requirement/assumption that file0, file1 ... cannot be 're-used' which
> I don't know how to apply to hashtable.

Do you know if we re-write that as - Rather than just returning the
updated value, htAddOrUpdate returns a pair consisting of the updated
value and a new hashtable, hashtable1. Although hashtable0 and
hashtable1 point to the same structures in memory, they are
conceptually and syntactically different, and thus it is clear that a
and b may have different values.

-- 
You 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 Clojure "Scholarship": Let's send Raynes to the Conj!

2010-09-10 Thread Rayne
http://blog.acidrayne.net/?p=4 I threw up a wordpress site and posted
this there. Maybe it'll last through a couple requests. :p

On Sep 10, 2:57 pm, Rayne  wrote:
> Just told that the site went down: not sure why, but I'll work on it
> later. Sorry. <3
>
> On Sep 10, 2:21 pm, Rayne  wrote:
>
>
>
> > I wrote a brief thank you post on my blog (actually the first post on
> > this new blog. 
> > :>)http://blog.acidrayne.net/thank-you-for-sending-me-to-the-conj
>
> > I'm unbelievably excited. I love you guys.
>
> > On Sep 10, 2:09 pm, Chas Emerick  wrote:
>
> > > Just a little over an hour, yes!  Raynes is going to the Conj.  Thanks  
> > > to all who donated.
>
> > > More info, numbers, and more thank-yous here:
>
> > >http://bit.ly/aj0XPr
>
> > > And, if you *wanted* to donate, but ended up coming in after we hit  
> > > our goal, please read the above post anyway. :-)
>
> > > Thanks again to all!
>
> > > - Chas
>
> > > On Sep 10, 2010, at 2:55 PM, Alan wrote:
>
> > > > Did we really get this done in an hour? I haven't been part of the
> > > > community for long, but Rayne has been helpful to me already on
> > > > #clojure so I was going to donate a bit. Did I already miss my chance?
>
> > > > On Sep 10, 10:39 am, Chas Emerick  wrote:
> > > >> With a huge helping hand from Relevance, the host of the Conj in
> > > >> October, I'm hoping we can make it possible for Anthony Simpson (you
> > > >> may know him as Raynes in #clojure irc) to attend the conference.
>
> > > >> The blog post tells the story:
>
> > > >>http://bit.ly/9dmeDe
>
> > > >> I hope you'll check it out, and help in whatever small way you can.
>
> > > >> Many thanks,
>
> > > >> - Chas
>
> > > > --
> > > > You 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: Simple things should be simple

2010-09-10 Thread Meikel Brandmeyer
Hi,

Am 10.09.2010 um 21:17 schrieb Mike Meyer:

> 1) Write program in chosen unix-friendly interpreted language.

You lost exactly here. "unix-friendly". Since you keep putting your context 
over everything, I will also keep on putting mine over everything. Ruby, 
Python, Perl, Tcl, ... are all not installed on the machine I have to target. 
So writing things in them requires me to have two month dance with corporate IT 
only to get no support in the end. I'm sorry, but "unix friendly interpreted 
language" is *not* simple.

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: Clojure 1.2 and the Computer Language Benchmarks Game

2010-09-10 Thread gary ng
On Fri, Sep 10, 2010 at 2:04 PM, Isaac Gouy  wrote:
> It's starting to look like actually there was a point you wanted to
> make ;-)
You mean the 'no chice' part ? yes.

You mean the why not Data.Hashtable  comment ? I don't think so.

>
> If you change the requirement to something else you'd simply be
> missing the point - which was to look at hashtable updates and
> strings.
I know perfectly well what you want to measure and I was not implying
if those measure is valid or not, I am totally neutral to the whole
thing.

My initial comment was all about 'it seems that Haskell submission is
not the typical elegant form' and to me because of the specific you
want to measure, there is no acceptable elegant Haskell form.

>
> Does it actually say that the hashtable updates have to be
> destructive?

If want to go that route, be my guest.

> There's no choice in binary-trees either - you must use binary-trees
> and you must allocate all the memory.
>
> There's no choice in pi-digits either - you must use that particular
> step-by-step spigot algorithm taken from that Haskell paper.
>
> There's no choice in fannkuch-redux either - you must use that
> particular ordering of permutations taken from that Lisp paper.
>
> etc etc

Indeed. Your benchmark suite are very specific about how certain
things must be done in order to measure a specific aspect you want to
measure.

>
> Forgive me but you do seem to be belabouring the obvious.
>

I think you are too sensitive

-- 
You 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-test-mode elpa version still out of date?

2010-09-10 Thread Bruce Durling
Hi,

On Fri, Sep 10, 2010 at 18:15, User7  wrote:
>
> I'm using emacs starter kit and clojure-test-mode 1.4 installed using
> elpa.  Running clojure-tests-run-tests seems to work fine, but clojure-
> test-run-test seems flakey.  This blog post from May says the elpa
> version is out of date.
>
> http://otfrom.wordpress.com/2010/05/16/leiningen-clojure-1-2-and-emacs/
>
> "However, now clojure-test-mode won’t work. The version is elpa isn’t
> new enough (you are using elpa and emacs-starter-kit aren’t you?) so
> we need to get it from technomancy’s github."
>
> Does anybody know if the elpa version is still out of date?


I'm the author of that post and now use clojure-test-mode happily from elpa.

cheers,
Bruce

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


partition-starting-every : yet another partition function

2010-09-10 Thread Matt Smith
problem: convert a collection [1 2 0 1 2 3 0 1 2 3 0 0 1 2] into
partitions like:
((1 2) (0 1 2 3) (0 1 2 3) (0) (0 1 2))
In this case, start each partition on a 0.


I looked at the various partition functions but none of them would do
the trick without adding unnecessary complexity.  Instead  I wrote a
new function based on partition-by:

Solution:
(defn partition-starting-every
  "Partition the sequence starting each partition when the f is true."
  [f coll]
  (if-let [coll (seq coll)]
(let [p (cons (first coll) (take-while (complement f) (rest
coll)))]
  (lazy-seq (cons p (partition-starting-every f (drop (count p)
coll)))

user=>(partition-starting-every zero? [1 2 0 1 2 3 0 1 2 3 0 0 1 2])
((1 2) (0 1 2 3) (0 1 2 3) (0) (0 1 2))

Questions:
1 - Is there a simpler way to do this using existing partition
functions?
2 - If not, is this something people are interested in having
contributed?

In looking at the partition functions they are very similar.  Maybe
there is a why to combine them in to a single function.

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


Convenience (was Simple things should be simple)

2010-09-10 Thread Stuart Halloway
Hi Mike,

I think this is more about convenience than simplicity. In both Unix and Java 
deployment is complex, and often complicated as well. In spite of this, small, 
one-off things should be convenient to deploy, and Unix does this better in 
some contexts.

There is no reason we can't make one-off scripting convenient in Clojure. The 
specific example you raised (deploying one-off scripts) could be addressed by a 
standard launcher. Several have been written, and we need to take the simplest 
design and include it in Clojure. There is already a ticket for this: 
https://www.assembla.com/spaces/clojure/tickets/366-multiplatform-command-line-clojure-launcher,
 and I would love to see it in the next release.

That said, your example was one representative example of a general problem. 
Inconvenience bubbles up from the Java ecosystem in many places. Fortunately, 
these inconveniences are easier to fix in Clojure that elsewhere, since Clojure 
is such a simple language. :-)

Cheers,
Stu


> On Fri, 10 Sep 2010 00:03:22 -0700 (PDT)
> Meikel Brandmeyer  wrote:
> 
>> Hi,
>> 
>> On 9 Sep., 20:46, Mike Meyer > 620...@mired.org> wrote:
>> 
>>> The first problem with that is that this stuff seems show up
>>> *everywhere* in Javaland. It's not just web apps, it's pretty much
>>> anything.
>> 
>> You just lost me completely with your argumentation. I wrote a small
>> desktop utility (simple problem, simple solution, simple program)
>> which is distributed to different locations in the company. It works
>> on Windows and Unix w/o adaption to the system. Download jar and
>> double-click / execute via java -jar. It works without library version
>> hell, complicated Makefiles, system differences and other shenanigans.
>> I'm quite willing to pay more complexity upfront to have it easier in
>> the end.
> 
> Ok, let's see how this goes:
> 
> With simple things are simple tools, for a simple problem with a
> simple solution and a simple program, the solution goes like this:
> 
> 1) Write program in chosen unix-friendly interpreted language.
> 2) Distribute program text file.
> 
> Users can then run it via double-clicking (mac & windows), running it
> directly on the command line (mac & unix) or - under extreme duress -
> running it via the interpreter on the command line.
> 
> As far as I can tell, to do the same thing with Java tools, the steps
> are:
> 
> 1) Write program in chosen language that runs on the JVM.
> 2) Compile program to class file(s).
> 3) Use some tool to create a manifest file.
> 4) Run jar to create jar file.
> 5) Distribute jar file.
> 
> Users can then run it via double-clicking (mac & windows) or via the
> interpreter on the command line (mac & unix). There is no option to
> run it directly on the command line.
> 
> Possibly some tool will do steps 3 and 4 in single step for you.  So
> the Javaland tools take at least twice as many steps, and deliver a
> solution that's harder to use in some cases. Of course, I'm not as
> familiar with Javaland tools as I am Unix tools, so maybe I got it
> wrong. If so, *please* tell me the better way!
> 
>> It is obvious that Clojure doesn't fit your needs. Then simply don't
>> use it.
> 
> Wrong. It may be that the Java infrastructure that Clojure runs in is
> baroque enough that I won't be willing to use it. Then the same would
> be true of any language running on the JVM. On the other hand, a
> Clojure that ran on, oh, Parrot just for instance, wouldn't have any
> of these problems.
> 
>-- 
> Mike Meyerhttp://www.mired.org/consulting.html
> Independent Network/Unix/Perforce consultant, email for more information.
> 
> O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Generating functions programmatically

2010-09-10 Thread Hubert Iwaniuk
Hi icemaze,

Please look at how fns are generated in http.async.client 
http://github.com/neotyk/http.async.client/blob/master/src/http/async/client/util.clj#L54
this macro is later used here: 
http://github.com/neotyk/http.async.client/blob/master/src/http/async/client.clj#L43

HTH,
Hubert.

On Sep 10, 2010, at 9:39 PM, icemaze wrote:

> Hi, I'm developing a small DSL with Clojure and I need to define many
> similar functions. I'd like to do that programmatically, of course.
> 
> My solution (involving a simple macro) doesn't work, so I won't bother
> you with it. I'll post it if anyone asks.
> 
> Basically what I need is: given a list of keywords, for each keyword x
> i need to define a function whose name is (str "prefix-" (name x)).
> The function has a very short body which uses x in one place
> (something like (fn [n] (= n x))).
> 
> Can you help me please? I've been banging my head against this for
> over four hours and I'm getting a little frustrated.
> 
> Thanks.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> 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: Clojure 1.2 and the Computer Language Benchmarks Game

2010-09-10 Thread Isaac Gouy


On Sep 10, 2:22 pm, gary ng  wrote:
-snip-
> My initial comment was all about 'it seems that Haskell submission is
> not the typical elegant form' and to me because of the specific you
> want to measure, there is no acceptable elegant Haskell form.

So what are we to do when there's a problem that has "no acceptable
elegant Haskell form"?


> > Does it actually say that the hashtable updates have to be
> > destructive?
>
> If want to go that route, be my guest.

I don't understand what you mean, didn't you say - it must be a
mutable hashtable?

Why couldn't it be a hashtable that copied values?


> Indeed. Your benchmark suite are very specific about how certain
> things must be done in order to measure a specific aspect you want to
> measure.

The other complaint is that it's not specific enough and allows too
much play, with programs in one language being too different to
programs in other languages.

-- 
You 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: Generating functions programmatically

2010-09-10 Thread Alan
I see. It's hard to imagine how this could work, since macros don't
have access to runtime data like the value of x in your example.
Perhaps you're better off writing a function that returns a closure,
and iteratively def'ing those?

user=> (defn make-kw-fn [kw]
 #(= kw %))
#'user/make-kw-fn
user=>
(def kws [:a :b])
#'user/kws
user=>
(eval (cons 'do (map #(list 'def (symbol (str "test-" (name %))) (make-
kw-fn %)) kws)))
#'user/test-b
user=> (test-b :a)
false
user=> (test-b :b)
true

On Sep 10, 1:37 pm, icemaze  wrote:
> Alan, thank you for your reply.
> Unfortunately your solution is very similar to mine and it suffers
> from the same problem (maybe I'm using it incorrectly, I don't know).
> If I write:
>
>   (doseq [x '(:a :b)]
>     (make-fn x))
>
> it defines a single function "synthetic-x". Is there a way to make
> this work? I tried everything but both eval and var-get don't work for
> local bindings.
>
> Thanks again.

-- 
You 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: Generating functions programmatically

2010-09-10 Thread Alan
PS this is super-ugly and I'm always embarrassed when I find myself
using eval in a lisp. While this works, I'd love it if someone could
tell me how to do it with macros.

On Sep 10, 3:07 pm, Alan  wrote:
> I see. It's hard to imagine how this could work, since macros don't
> have access to runtime data like the value of x in your example.
> Perhaps you're better off writing a function that returns a closure,
> and iteratively def'ing those?
>
> user=> (defn make-kw-fn [kw]
>          #(= kw %))
> #'user/make-kw-fn
> user=>
> (def kws [:a :b])
> #'user/kws
> user=>
> (eval (cons 'do (map #(list 'def (symbol (str "test-" (name %))) (make-
> kw-fn %)) kws)))
> #'user/test-b
> user=> (test-b :a)
> false
> user=> (test-b :b)
> true
>
> On Sep 10, 1:37 pm, icemaze  wrote:
>
> > Alan, thank you for your reply.
> > Unfortunately your solution is very similar to mine and it suffers
> > from the same problem (maybe I'm using it incorrectly, I don't know).
> > If I write:
>
> >   (doseq [x '(:a :b)]
> >     (make-fn x))
>
> > it defines a single function "synthetic-x". Is there a way to make
> > this work? I tried everything but both eval and var-get don't work for
> > local bindings.
>
> > Thanks again.
>
>

-- 
You 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.2 and the Computer Language Benchmarks Game

2010-09-10 Thread gary ng
On Fri, Sep 10, 2010 at 3:06 PM, Isaac Gouy  wrote:
> So what are we to do when there's a problem that has "no acceptable
> elegant Haskell form"?
Depending on the intend, for you benchmark program, write something
like what it is now.

For real life cases, call an exnternal library, use another language,
transform the solution into something that would not hit the weak
point of the language(I recently saw an example of this on J about a
simple but interesting quiz).

>
>
>> > Does it actually say that the hashtable updates have to be
>> > destructive?
>>
>> If want to go that route, be my guest.
>
> I don't understand what you mean, didn't you say - it must be a
> mutable hashtable?
>
> Why couldn't it be a hashtable that copied values?
As I said, be my guest.

>
>
>> Indeed. Your benchmark suite are very specific about how certain
>> things must be done in order to measure a specific aspect you want to
>> measure.
>
> The other complaint is that it's not specific enough and allows too
> much play, with programs in one language being too different to
> programs in other languages.
>
not sure what you want to say.

-- 
You 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: Simple things should be simple

2010-09-10 Thread Mike Meyer
On Fri, 10 Sep 2010 23:21:01 +0200
Meikel Brandmeyer  wrote:

> Hi,
> 
> Am 10.09.2010 um 21:17 schrieb Mike Meyer:
> 
> > 1) Write program in chosen unix-friendly interpreted language.
> 
> You lost exactly here. "unix-friendly". Since you keep putting your context 
> over everything, I will also keep on putting mine over everything. Ruby, 
> Python, Perl, Tcl, ... are all not installed on the machine I have to target. 
> So writing things in them requires me to have two month dance with corporate 
> IT only to get no support in the end. I'm sorry, but "unix friendly 
> interpreted language" is *not* simple.

Fair enough. But Java is not installed on the machines *I* have to
target, so writing things in a JVM language requires *me* to go
through the multi-month dance with security just to be allowed to use
it. (Come to that, I've already had clojure rejected by my current
client because the JVM hasn't been vetted for security, and doing so
wasn't worth the effort).

In the real world, you get one of two situations:

1) Most linux distros, and a few Unix distros (including Macs) come
   with Java, Python, Perl, Ruby and most popular languages already
   installed.

2) Windows, the rest of the Unix distros and a few oddball Linux
   distros come *without* Java, Python, Perl, Tcl, Ruby
   etc. installed, so you have to go through some kind of dance to get
   them.

As far as I can tell, neither one has an advantage over the other,
unless you're in an environment where one has already been approved,
and the other hasn't. I'm trying to be fair, and ignore things that
are local aberrations that only need to be overcome once.

I mean, really - if I complained that Clojure had a problem because it
ran on the JVM and my clients don't want to go to the effort to vet
the JVM, you'd be quite right in laughing at me and pointing out that
the problem is with my clients, not with clojure.

   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: Convenience (was Simple things should be simple)

2010-09-10 Thread Mike Meyer
On Fri, 10 Sep 2010 17:29:24 -0400
Stuart Halloway  wrote:

> Hi Mike,
> 
> I think this is more about convenience than simplicity. In both Unix and Java 
> deployment is complex, and often complicated as well. In spite of this, 
> small, one-off things should be convenient to deploy, and Unix does this 
> better in some contexts.
> 
> There is no reason we can't make one-off scripting convenient in Clojure. The 
> specific example you raised (deploying one-off scripts) could be addressed by 
> a standard launcher. Several have been written, and we need to take the 
> simplest design and include it in Clojure. There is already a ticket for 
> this: 
> https://www.assembla.com/spaces/clojure/tickets/366-multiplatform-command-line-clojure-launcher,
>  and I would love to see it in the next release.
> 
> That said, your example was one representative example of a general problem. 
> Inconvenience bubbles up from the Java ecosystem in many places. Fortunately, 
> these inconveniences are easier to fix in Clojure that elsewhere, since 
> Clojure is such a simple language. :-)

Bingo.

I think it's deeper than that. The reason that the Unix version is so
simple isn't just a simple launcher script, or the #! hack, or any one
things. It's that "simple things should be simple" is axiomatic for
those tools (I'm not sure which came first - the software tools
project or unix, but they both share this philosophy, and software
tools project ran on damn near everything when they were still
supported). All those things derive from that philosophy, and combine
to make simple things simple.

I.e. - someone claimed that this boils down to not being able to
tweak CLASSPATH in the program. Well, that would help, but it's not
quite enough. Most simple/simple programs don't have to tweak their
search path for loadable modules, because - no matter where they are
running - the default path to look for loadable modules includes the
current directory, possibly the directory the application was launched
from, and the appropriate library directory for that installation of
the system. Which means that 95% of the time, you don't have to worry
about the path at all. Simple things - loading standard modules (even
if they're optional), loading application-specific modules, or even
invocation-specific modules - are simple, because the appropriate
elements are *already* in the search path.

Ditto for compiled binaries: if they're built properly, they know
where to find all their shard libraries, and you don't have to muck
about with LD_LIBRARY_PATH.

The default CLASSPATH is ".", so to do anything more complicated than
running a .class file from the current directory (and really - how
often do you do that?) you have to do something complicated.

Ok, fixing this in clojure would require the ability to change the
class path - or a smarter classloader - that looked in the right
places to start with. So that ability is a first step in this
direction.

   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: Generating functions programmatically

2010-09-10 Thread Robert McIntyre
Why not explicitly feed the macro the keyword map if that is what it wants?

(defmacro ultra-synth [prefix keywords]
  (let [symbols (map (comp symbol name)  keywords)
fn-names (map (comp symbol
(partial str prefix) name) keywords)
defn-forms (map
(fn [fn-name symbol]
  `(defn ~fn-name [n#]
 (= n# ~symbol)))
fn-names symbols)]
`(do ~...@defn-forms)))

thunderbolt.play> (def a 5)
#'thunderbolt.play/a
thunderbolt.play> (def b 5)
#'thunderbolt.play/b
thunderbolt.play> (ultra-synth "hi" [:a :b])
#'thunderbolt.play/hib
thunderbolt.play>  (hia 5)
true

--Robert McIntyre

On Fri, Sep 10, 2010 at 6:17 PM, Alan  wrote:
> PS this is super-ugly and I'm always embarrassed when I find myself
> using eval in a lisp. While this works, I'd love it if someone could
> tell me how to do it with macros.
>
> On Sep 10, 3:07 pm, Alan  wrote:
>> I see. It's hard to imagine how this could work, since macros don't
>> have access to runtime data like the value of x in your example.
>> Perhaps you're better off writing a function that returns a closure,
>> and iteratively def'ing those?
>>
>> user=> (defn make-kw-fn [kw]
>>          #(= kw %))
>> #'user/make-kw-fn
>> user=>
>> (def kws [:a :b])
>> #'user/kws
>> user=>
>> (eval (cons 'do (map #(list 'def (symbol (str "test-" (name %))) (make-
>> kw-fn %)) kws)))
>> #'user/test-b
>> user=> (test-b :a)
>> false
>> user=> (test-b :b)
>> true
>>
>> On Sep 10, 1:37 pm, icemaze  wrote:
>>
>> > Alan, thank you for your reply.
>> > Unfortunately your solution is very similar to mine and it suffers
>> > from the same problem (maybe I'm using it incorrectly, I don't know).
>> > If I write:
>>
>> >   (doseq [x '(:a :b)]
>> >     (make-fn x))
>>
>> > it defines a single function "synthetic-x". Is there a way to make
>> > this work? I tried everything but both eval and var-get don't work for
>> > local bindings.
>>
>> > Thanks again.
>>
>>
>
> --
> You 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: Generating functions programmatically

2010-09-10 Thread Alan
It sounds like he's going to be given the list of keywords by the
user, and won't have it as a compile-time literal. Maybe he's load'ing
a .clj file, for example, that someone will write in the future. Maybe
you can combine our two approaches to get something that works and
isn't ugly, but I'm having a hard time finding it. (def) requires a
symbol as its first argument, and is a macro so needs it at compile
time. The best I can do is:

(defmacro buildfn [name]
`(defn ~name [arg#] 10))
(doseq [k '[a b c]]
(eval `(buildfn ~k)))

On Sep 10, 4:20 pm, Robert McIntyre  wrote:
> Why not explicitly feed the macro the keyword map if that is what it wants?
>
> (defmacro ultra-synth [prefix keywords]
>   (let [symbols (map (comp symbol name)  keywords)
>         fn-names (map (comp symbol
>                             (partial str prefix) name) keywords)
>         defn-forms (map
>                     (fn [fn-name symbol]
>                       `(defn ~fn-name [n#]
>                          (= n# ~symbol)))
>                     fn-names symbols)]
>     `(do ~...@defn-forms)))
>
> thunderbolt.play> (def a 5)
> #'thunderbolt.play/a
> thunderbolt.play> (def b 5)
> #'thunderbolt.play/b
> thunderbolt.play> (ultra-synth "hi" [:a :b])
> #'thunderbolt.play/hib
> thunderbolt.play>  (hia 5)
> true
>
> --Robert McIntyre
>
> On Fri, Sep 10, 2010 at 6:17 PM, Alan  wrote:
> > PS this is super-ugly and I'm always embarrassed when I find myself
> > using eval in a lisp. While this works, I'd love it if someone could
> > tell me how to do it with macros.
>
> > On Sep 10, 3:07 pm, Alan  wrote:
> >> I see. It's hard to imagine how this could work, since macros don't
> >> have access to runtime data like the value of x in your example.
> >> Perhaps you're better off writing a function that returns a closure,
> >> and iteratively def'ing those?
>
> >> user=> (defn make-kw-fn [kw]
> >>          #(= kw %))
> >> #'user/make-kw-fn
> >> user=>
> >> (def kws [:a :b])
> >> #'user/kws
> >> user=>
> >> (eval (cons 'do (map #(list 'def (symbol (str "test-" (name %))) (make-
> >> kw-fn %)) kws)))
> >> #'user/test-b
> >> user=> (test-b :a)
> >> false
> >> user=> (test-b :b)
> >> true
>
> >> On Sep 10, 1:37 pm, icemaze  wrote:
>
> >> > Alan, thank you for your reply.
> >> > Unfortunately your solution is very similar to mine and it suffers
> >> > from the same problem (maybe I'm using it incorrectly, I don't know).
> >> > If I write:
>
> >> >   (doseq [x '(:a :b)]
> >> >     (make-fn x))
>
> >> > it defines a single function "synthetic-x". Is there a way to make
> >> > this work? I tried everything but both eval and var-get don't work for
> >> > local bindings.
>
> >> > Thanks again.
>
> > --
> > You 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: Generating functions programmatically

2010-09-10 Thread icemaze
Yeah, I guess I could use a macro to generate the "call" to the other
macro in a way similar to how you used it. Thank you, that should
definitely work. I'll try it right now.

-- 
You 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: Generating functions programmatically

2010-09-10 Thread icemaze
I agree: eval never looks pretty.

-- 
You 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: Generating functions programmatically

2010-09-10 Thread Robert McIntyre
there's always apply-macro from contrib for doing perverse stuff like
that, so you don't
have to *see* eval if you don't want to :)

--Robert McIntyre

On Fri, Sep 10, 2010 at 8:24 PM, icemaze  wrote:
> I agree: eval never looks pretty.
>
> --
> You 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: Generating functions programmatically

2010-09-10 Thread icemaze
Yes, I think I'll have to pass the keywords as literals. I don't think
there's a way around that (other than using eval, as per Alan's
solution).
I was too excited about Hubert's hint and I found myself in the exact
same problem with the second macro.

-- 
You 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: Generating functions programmatically

2010-09-10 Thread icemaze
You are mostly right in your assumptions: I could dump the keywords in
the clj as literals but it would be tedious and not elegant at all.
Eval's not pretty but it works; plus it's there for a reason, like
working around the shortcomings of the language (and of my brain).

I was about to post my solution but I won't, since it looks exactly
like yours.

Thank you guys for your efforts!

-- 
You 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: Generating functions programmatically

2010-09-10 Thread Btsai
This is probably not the prettiest way to do it, but I think it gets
the job done:

(defn make-sym [keyword]
  (->> keyword name (str "prefix-") symbol))

(defn make-fn [keyword]
  (let [n (gensym)]
   (list 'defn (make-sym keyword) [n] (list '= n keyword

(defmacro make-fns [keywords]
  `(do ~@(map make-fn keywords)))

user=> (make-fns [:a :b :c])
#'user/prefix-c
user=> (prefix-a :a)
true
user=> (prefix-a :x)
false
user=> (prefix-b :b)
true
user=> (prefix-b :x)
false
user=> (prefix-c :c)
true
user=> (prefix-c :x)
false

The credit belongs to Alan, and Mr. Stuart Halloway for his examples
from Ch. 7 of Programming Clojure.

On Sep 10, 2:37 pm, icemaze  wrote:
> Alan, thank you for your reply.
> Unfortunately your solution is very similar to mine and it suffers
> from the same problem (maybe I'm using it incorrectly, I don't know).
> If I write:
>
>   (doseq [x '(:a :b)]
>     (make-fn x))
>
> it defines a single function "synthetic-x". Is there a way to make
> this work? I tried everything but both eval and var-get don't work for
> local bindings.
>
> Thanks again.

-- 
You 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: Problem importing JOptionPane from a string evaluated by load-string

2010-09-10 Thread Paul D. Fernhout

On 9/10/10 9:03 AM, Laurent PETIT wrote:

Got it. You cannot invoke (import) (or (ns)) from within the function
definition. The function is already being evaluated, and it's "too
late".

This works fine for me:

(do
   (import '(javax.swing JOptionPane))
   ((fn []
 (println "Hello World")
  (println (+ 2 2))
  (JOptionPane/showMessageDialog
nil "Hello from the text panel" "Greeting"
JOptionPane/INFORMATION_MESSAGE

So be aware that then some namespace will be changed by the call to
import (side effect on *ns*).

I would suggest either you create a temporary namespace for the code
to execute, either as Sean suggested, you write the call to
JOptionPane static methods and fields fully qualified:
(javax.swing.JOptionPane/showMessageDialog ...)


I see, those are good suggestions that help me better understand what is 
going on with namespaces. I can remember now in my work that I had other 
errors related to where I placed an import statement in the base code that I 
had resolved by pulling them out of a function (not really understanding 
then what worked, because at the same time I changed the form of it).


Strangely, when I click on "Update code" to evaluate that code it popped up 
the JOptionPane right away. I would think it would have not done that, 
because I was trying to return an anonymous function I could bind to the 
button action.


And then "Click Me!" to actually call the function produces an error.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at 
org.pointrel.guitest2$hookupActionPerformed$fn__54.invoke(guitest2.clj:13)
	at 
org.pointrel.guitest2.proxy$java.lang.Object$ActionListener$46793e3a.actionPerformed(Unknown 
Source)

at 
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)

I'm presuming that (do ...) returns nil and so the nil gets bound instead of 
a function and that causes the error.


I just removed a set of parens that caused the anonymous fn to evaluate 
during the load-string call, and now it works the way I wanted to. I can't 
say the GUI design was very self-explanatory, so I can see how you might 
have thought success was different then I expected. :-)


This is the variant that works the way I wanted:

(do
  (import '(javax.swing JOptionPane))
  (fn []
 (println "Hello World")
 (println (+ 2 2))
 (JOptionPane/showMessageDialog
   nil "Hello from the text panel" "Greeting"
   JOptionPane/INFORMATION_MESSAGE)))


And this works also with the complete path as Sean suggested:

 (fn []
 (println "Hello World")
 (println (+ 2 2))
 (JOptionPane/showMessageDialog
   nil "Hello from the text panel2" "Greeting"
   javax.swing.JOptionPane/INFORMATION_MESSAGE))

So, my thanks go to you and Sean, for two different solutions. :-)

I'll need to look more into that namespace thing. I'm more used to 
Python/Jython recently where you can import stuff wherever you want 
(suboptimally if done in a frequently called function, of course). 
Obviously, I can see a functional language making different tradeoffs.


Anyway, I've just been noodling around in terms of what it would take to 
build an interactive GUI building system where you could easily change how 
some of the system worked at run-time as a sort of rapid prototyping (like 
Smalltalk systems usually can do). This amount of code seems to be the bare 
bones to doing that (at least as a proof-of-concept), so thanks again for 
the solutions. I know there are other Clojure GUI building stuff out there, 
already; I was just starting playing with something interesting to show the 
power and elegance of Clojure. :-)


--Paul Fernhout
http://www.pdfernhout.net/

The biggest challenge of the 21st century is the irony of technologies of 
abundance in the hands of those thinking in terms of scarcity.


--
You 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: Improved stack traces

2010-09-10 Thread Mike Hinchey
I found when working on ticket 191 (dead now, I suppose) that counting the
stack elements is not reliable, but = works to get rid of duplicates.  Below
you can compare java's to your new function - the clojure has one duplicate
element (the very last one).  Also, I find the "..." useful to know
something is cut off.

root-cause is too generic of a name since it only strips out
CompileException.

Will clojure.stacktrace be deprecated or patched to use this implementation?

My patch for 191 includes test code if you want to adjust it for this.

-Mike

user=> (.printStackTrace *e)
java.lang.Exception: Unable to resolve symbol: x in this context,
compiling:(NO_SOURCE_FILE:0)
at clojure.lang.Compiler.analyze(Compiler.java:5777)
at clojure.lang.Compiler.analyze(Compiler.java:5723)
at clojure.lang.Compiler.eval(Compiler.java:6002)
at clojure.lang.Compiler.eval(Compiler.java:5965)
at clojure.core$eval.invokeStatic(core.clj:2652)
at clojure.core$eval.invoke(core.clj)
at clojure.main$repl$read_eval_print__5766.invoke(main.clj:177)
at clojure.main$repl$fn__5771.invoke(main.clj:198)
at clojure.main$repl.doInvoke(main.clj:198)
at clojure.lang.RestFn.invoke(RestFn.java:422)
at clojure.main$repl_opt.invoke(main.clj:256)
at clojure.main$main.doInvoke(main.clj:349)
at clojure.lang.RestFn.invoke(RestFn.java:398)
at clojure.lang.Var.invoke(Var.java:361)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: java.lang.Exception: Unable to resolve symbol: x in this context
at clojure.lang.Compiler.resolveIn(Compiler.java:6251)
at clojure.lang.Compiler.resolve(Compiler.java:6195)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6158)
at clojure.lang.Compiler.analyze(Compiler.java:5744)
... 16 more
nil

user=> (pst *e 40)
CompilerException java.lang.Exception: Unable to resolve symbol: x in this
context, compiling:(NO_SOURCE_FILE:0)
clojure.lang.Compiler.analyze (Compiler.java:5777)
clojure.lang.Compiler.analyze (Compiler.java:5723)
clojure.lang.Compiler.eval (Compiler.java:6002)
clojure.lang.Compiler.eval (Compiler.java:5965)
clojure.core/eval (core.clj:2652)
clojure.core/eval (core.clj:-1)
clojure.main/repl/read-eval-print--5766 (main.clj:177)
clojure.main/repl/fn--5771 (main.clj:198)
clojure.main/repl (main.clj:198)
clojure.main/repl-opt (main.clj:256)
clojure.main/main (main.clj:349)
clojure.lang.Var.invoke (Var.java:361)
clojure.lang.Var.applyTo (Var.java:482)
clojure.main.main (main.java:37)
Caused by:
Exception Unable to resolve symbol: x in this context
clojure.lang.Compiler.resolveIn (Compiler.java:6251)
clojure.lang.Compiler.resolve (Compiler.java:6195)
 clojure.lang.Compiler.analyzeSymbol (Compiler.java:6158)
clojure.lang.Compiler.analyze (Compiler.java:5744)
clojure.lang.Compiler.analyze (Compiler.java:5723)
nil

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

2010-09-10 Thread Robert McIntyre
That is very elegant but has the exact same problem in that the macro
must be called on a literal vector of keywords.

--Robert McIntyre

On Fri, Sep 10, 2010 at 5:41 PM, Btsai  wrote:
> This is probably not the prettiest way to do it, but I think it gets
> the job done:
>
> (defn make-sym [keyword]
>  (->> keyword name (str "prefix-") symbol))
>
> (defn make-fn [keyword]
>  (let [n (gensym)]
>   (list 'defn (make-sym keyword) [n] (list '= n keyword
>
> (defmacro make-fns [keywords]
>  `(do ~@(map make-fn keywords)))
>
> user=> (make-fns [:a :b :c])
> #'user/prefix-c
> user=> (prefix-a :a)
> true
> user=> (prefix-a :x)
> false
> user=> (prefix-b :b)
> true
> user=> (prefix-b :x)
> false
> user=> (prefix-c :c)
> true
> user=> (prefix-c :x)
> false
>
> The credit belongs to Alan, and Mr. Stuart Halloway for his examples
> from Ch. 7 of Programming Clojure.
>
> On Sep 10, 2:37 pm, icemaze  wrote:
>> Alan, thank you for your reply.
>> Unfortunately your solution is very similar to mine and it suffers
>> from the same problem (maybe I'm using it incorrectly, I don't know).
>> If I write:
>>
>>   (doseq [x '(:a :b)]
>>     (make-fn x))
>>
>> it defines a single function "synthetic-x". Is there a way to make
>> this work? I tried everything but both eval and var-get don't work for
>> local bindings.
>>
>> Thanks again.
>
> --
> You 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