Re: server-socket on exit event

2009-10-16 Thread Emeka
Ngo,

I checked out your github , it is great. I have not used netty, it looks
clean. However, what is the meaning of this, (def reshedule nil)?


Regards,
Emeka


On Thu, Oct 15, 2009 at 3:02 AM, ngocdaothanh wrote:

>
> I created this (Netty is used instead of server-socket):
> http://github.com/ngocdaothanh/telchat-clojure
>
> I am going to create a Scala version of the same program to have a
> feeling of Clojure vs Scala, it will be telchat-scala.
>
>
> On Oct 14, 10:12 pm, Emeka  wrote:
> > Ngo,
> >
> > Honestly  speaking I don't know. How far have you gone?
> >
> > Regards,
> > Emeka
> >
> > On Sat, Oct 3, 2009 at 3:21 PM, ngocdaothanh 
> wrote:
> >
> > > Emeka, good catch. It's just my mistake.
> >
> > > Another thing is I think there may be exception raised when on-msg
> > > sends message to a closed socket. How would you solve this?
> >
> > > On Oct 3, 7:35 pm, Emeka  wrote:
> > > > ngo,
> > > > I was about doing this kind of client/server thing some  days ago,
> > > however
> > > > now you are into it I would like to learn then. I am not quite clear
> why
> > > you
> > > > have this:
> > > > (.start (new Thread (fn [] (create-server 8080 chat-loop
> >
> > > > My concern is on  Thread, create-server function has a Thread inside
> > > > create-server-aux function.
> >
> > > > Regards,
> > > > Emeka
> >
> > > > On Fri, Oct 2, 2009 at 3:13 AM, ngocdaothanh  >
> > > wrote:
> >
> > > > > > I'm not sure TCP/IP has a native facility for that.
> >
> > > > > I'm afraid John's statement is correct:
> >
> > > > >
> http://www.velocityreviews.com/forums/t125620-client-socket-disconnec.
> > > ..
> > > > > and trying to read and write until something wrong happens as
> > > > > demonstrated in Roger's code is the only way to check for
> > > > > disconnection.
> >
> > > > > Below is my new code. Sorry it is rather long.
> >
> > > > > (import '[java.io BufferedReader InputStreamReader
> > > > > OutputStreamWriter])
> > > > > (use 'clojure.contrib.server-socket)
> >
> > > > > (def clients (ref []))  ; Each client is an *out*
> >
> > > > > (defn on-msg [from msg]
> > > > >  (println msg)
> > > > >  (doall
> > > > >(map
> > > > >  (fn [client]
> > > > >(if-not (= from client)
> > > > >  (binding [*out* client]
> > > > >(println msg)
> > > > >(flush
> > > > >  @clients)))
> >
> > > > > (defn on-disconnect [client]
> > > > >  (dosync
> > > > >(alter clients
> > > > >  (fn [clients]
> > > > >(remove (fn [c] (= c client)) clients
> > > > >  (on-msg client "A client has disconnected"))
> >
> > > > > (defn on-connect [client]
> > > > >  (dosync (alter clients conj client))
> > > > >  (on-msg client "A client has connected"))
> >
> > > > > (defn chat-loop [is os]
> > > > >  (let [client (OutputStreamWriter. os)]
> > > > >(on-connect client)
> > > > >(binding [*in* (BufferedReader. (InputStreamReader. is))]
> > > > >  (loop []
> > > > >(let [msg (read-line)]  ; msg is nil when the client
> > > > > disconnects
> > > > >  (if (nil? msg)
> > > > >(on-disconnect client)
> > > > >(do
> > > > >  (on-msg client msg)
> > > > >  (recur
> >
> > > > > (.start (new Thread (fn [] (create-server 8080 chat-loop
> >
> > > > > On Oct 2, 5:20 am, John Harrop  wrote:
> > > > > > On Thu, Oct 1, 2009 at 4:02 PM, Roger Gilliar 
> > > wrote:
> > > > > > > Am 01.10.2009 um 21:28 schrieb ngocdaothanh:
> > > > > > > > Roger, your code is not event based.
> > > > > > > What do you mean by not event based ?
> >
> > > > > > He means he wants automatic notification if a connection is
> dropped.
> >
> > > > > > I'm not sure TCP/IP has a native facility for that.
> >
> > > > > > What most chat type programs, multiplayer games, and suchlike do
> is
> > > send
> > > > > a
> > > > > > periodic ping from server to each connected client, which as part
> of
> > > the
> > > > > > chat protocol the client is supposed to acknowledge. If a client
> > > stops
> > > > > > responding for more than a few ping-intervals, it's assumed to
> have
> > > > > > disconnected or otherwise become unreachable.
> >
> > > > > > This method has the advantage of being entirely under the control
> of
> > > the
> > > > > > application layer, and the further advantage of also working with
> UDP
> > > > > (which
> > > > > > is crucial in the "multiplayer games" case at least).
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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's 2nd Birthday!

2009-10-16 Thread John Harrop
On Fri, Oct 16, 2009 at 1:35 AM, Mark Engelberg wrote:

>
> Uh oh, time for the "terrible twos".  Who wants to throw the first tantrum?
> :)


Didn't Wrexsoul already do that a few months ago?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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's 2nd Birthday!

2009-10-16 Thread Mark Derricutt
Well we do have a maven plugin to give us all clojure/maven pain ;-)

On Fri, Oct 16, 2009 at 6:35 PM, Mark Engelberg wrote:

> Uh oh, time for the "terrible twos".  Who wants to throw the first tantrum?
> :)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Circular dependencies (Clojure and Java)

2009-10-16 Thread jng27



On Oct 15, 11:48 am, Stuart Sierra 
wrote:
> On Oct 15, 7:56 am, Laurent PETIT  wrote:
>
> > if the clojure classes depend on the java classes in the implementation and
> > not in their interfaces ( extends, implements, methods signatures ), then
> > you can write your gen-class with a separate namespace for the
> > implementation of the class ( using :impl-ns ). Then you compile clojure
> > code in 2 pass : 1/ compile the namespaces that use call gen-class and
> > gen-interface for generating the class stubs 2/ compile java 3/ compile all
> > the remaining clojure code.
>
> I used this approach in the past, now I try to avoid circular
> dependencies like this.
>
> -SS

Sure, this sometimes works for new and smaller projects.
Even then there are enough cases where circular dependencies could
easily be a justified part of a design.

However, back to how this relates to the adoption of Clojure by
industry.
Many companies trying to embrace Clojure would replace parts of their
existing Java code bases piecemeal as they come up to speed with
Clojure.
Many of them will be forced to deal with this issue. I'm wondering if
there's an elegant
solution for them to help with Clojure being a practical option in
those places ?

It probably goes without saying that the ability for Clojure to deal
with circular dependencies
and bi-directional relationships between Java and Clojure code is
quite important for it's successful adoption in the mainstream.

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



clj-html - how to generate DOCTYPE

2009-10-16 Thread Amitava

Hello all,

Does anyone know how to generate the html doctype using clj-html? I am
trying out the conjure web framework.

Thanks & Regards,
Amitava Shee

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Circular dependencies (Clojure and Java)

2009-10-16 Thread jng27

To deal with the problem the ideal solution would be supporting
something along these lines.
It's probably inevitable that at some point the Clojure compiler would
have be modified.

On Oct 15, 12:17 pm, Manuel Woelker  wrote:
> On Thu, Oct 15, 2009 at 5:48 AM, jng27  wrote:
>
> > The following seems like it could be a common scenario when attempting
> > to re-write parts of an existing Java application in Clojure.
>
> > Let's say there exists Clojure code and Java code in the same
> > 'project'.
> > The Clojure code depends on the Java code in one direction and then
> > the same is true in the opposite direction.
> > Given that compiling Java and Clojure require separate and different
> > compilation steps, how would circular dependencies be resolved ?
> > e.g. A class is defined in the Clojure code that references Java
> > classes(yet to be compiled) and the same is true for the Java code
> > referencing classes defined in Clojure(yet to be compiled). It doesn't
> > seem like compiling one before the other would solve this issue.
>
> One possible solution that could be feasible is a two pass compilation
> for clojure. The first compilation pass would basically just generate
> the skeletons for the classes, i.e. just the method "heads" with each
> method body being ignored and replaced with 'throw new
> IllegalStateExccpetion("You are using first pass compilation
> results")' or something along those lines. After this compilation pass
> the Java classes can be compiled just fine, since all method calls can
> be resolved. Finally the second pass of the clojure compilation fills
> in the real method bodies, now that Java classes have been generated.
> This should in theory work for most scenarios.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Project Euler: Problem suggestions that show off clojure?

2009-10-16 Thread Meikel Brandmeyer

Hi,

You can have a look here: http://clojure-euler.wikispaces.com.

I chose the problems I solved because I found them interesting or
because I had an idea how to solve them. I didn't look specifically
for problems fitting to Clojure. (And in fact most of my solution look
rather ugly when now looking at them...)

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



Bug: -main function corrupts applet

2009-10-16 Thread Andreas Wenger

When writing an applet with Clojure I discovered the following bug:

Whenever a class with a -main function is loaded (e.g. by :use), the
applet is broken (Java 6 with new plugin technology):

java.lang.NullPointerException
  at sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel
(Plugin2Manager.java:2996)
  at sun.plugin2.applet.Plugin2Manager.createApplet
(Plugin2Manager.java:2947)
  at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run
(Plugin2Manager.java:1397)
  at java.lang.Thread.run(Thread.java:619)

You can very easily reproduce the problem with the following
experiment I prepared:

http://www.xenoage.com/extern/bugreports/clojure-main-problem.zip

First, look at the .clj files. There are three identical (minimal)
applets. Each uses another (minimal) file: One uses a class with a -
main method, one uses a class with no main method and the third one
uses a renamed main method.
Now, compile the files by calling the build.sh script. When finished,
open the HTML files in the browser. You will see that the two applets
without -main functions work, but the applet with the -main function
fails.

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



is there a cannonical way to create executable jar files?

2009-10-16 Thread Folcon

Hello,

Is there a cannonical way to create executable jar files? I'm
having some success to make this a web start application but every
time I compile I keep getting could not find main class.
(I have tried compiling in both eclipse and netbeans with more luck in
eclipse)

my namespace contains   (:gen-class :main true) with the main
function
I want to declare called -main. and I have tried telling my manifest
file to call my namespace and clojure.main and both fail.

I've also tried (:gen-class :init init :main true) with my "main"
function called init. I am wondering if it will be neccessary to
create a java launcher class that just evaluates my clojure script and
then calls the main function?

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



Help locating library for docstring, attr-map parsing in macros

2009-10-16 Thread Garth Sheldon-Coulson
Hi All,

The other day when browsing the web I came across a library that I can't
locate anymore.

The library is an aid for macro-writing. It automates the simple but
annoying task of parsing optional attr-maps and docstrings for passing to
defn, etc.

Could someone jog my memory as to who wrote it or where it is? Thanks in
advance.

Garth

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



Re: Help locating library for docstring, attr-map parsing in macros

2009-10-16 Thread James Reeves

Could you be thinking of clojure.contrib.def/name-with-attributes ?

On Oct 16, 1:20 pm, Garth Sheldon-Coulson  wrote:
> Hi All,
>
> The other day when browsing the web I came across a library that I can't
> locate anymore.
>
> The library is an aid for macro-writing. It automates the simple but
> annoying task of parsing optional attr-maps and docstrings for passing to
> defn, etc.
>
> Could someone jog my memory as to who wrote it or where it is? Thanks in
> advance.
>
> Garth
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Help locating library for docstring, attr-map parsing in macros

2009-10-16 Thread Garth Sheldon-Coulson
Yes, thanks!

On Fri, Oct 16, 2009 at 9:48 AM, James Reeves wrote:

>
> Could you be thinking of clojure.contrib.def/name-with-attributes ?
>
> On Oct 16, 1:20 pm, Garth Sheldon-Coulson  wrote:
> > Hi All,
> >
> > The other day when browsing the web I came across a library that I can't
> > locate anymore.
> >
> > The library is an aid for macro-writing. It automates the simple but
> > annoying task of parsing optional attr-maps and docstrings for passing to
> > defn, etc.
> >
> > Could someone jog my memory as to who wrote it or where it is? Thanks in
> > advance.
> >
> > Garth
> >
>

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



Re: is there a cannonical way to create executable jar files?

2009-10-16 Thread Stuart Sierra

On Oct 16, 8:12 am, Folcon  wrote:
> my namespace contains   (:gen-class :main true) with the main
> function
> I want to declare called -main. and I have tried telling my manifest
> file to call my namespace and clojure.main and both fail.

That should be the correct approach.  Not sure what might be wrong.
Are you sure your Clojure files are getting AOT-compiled properly?  If
you can't launch clojure.main, maybe the Clojure JAR contents are not
included in your application JAR?

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



function names ending with !

2009-10-16 Thread Mark Volkmann

What's the rule of thumb for deciding whether a function name should
end with an exclamation point? I thought maybe it was when the
function modifies its first argument, but it seems there are functions
that do that and do not have such names.

For example, set-validator! and add-watch. Why don't they either both
end with ! or both not do that.

-- 
R. Mark Volkmann
Object Computing, Inc.

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



clojurecheck?

2009-10-16 Thread Wilson MacGyver

A friend of mine showed me this. It's an effort to bring Haskell's
Quickcheck to clojure.

http://kotka.de/projects/clojure/clojurecheck.html

Has anyone used it? What's your experience with it?

Thanks

-- 
Omnem crede diem tibi diluxisse supremum.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: function names ending with !

2009-10-16 Thread Jarkko Oranen

On Oct 16, 5:44 pm, Mark Volkmann  wrote:
> What's the rule of thumb for deciding whether a function name should
> end with an exclamation point? I thought maybe it was when the
> function modifies its first argument, but it seems there are functions
> that do that and do not have such names.
>
> For example, set-validator! and add-watch. Why don't they either both
> end with ! or both not do that.

add-watch doesn't really affect the object itself, while set-
validator! certainly does, so I think the naming is consistent.
I think it might be a good rule of thumb to add the ! if the operation
either mutates the object (set!) or invalidates old values/references
to it, like persistent! or set-validator!. However, even core.clj
doesn't seem to follow this...

The exceptions seem to be the "alter" operations for reference types;
alter, commute, alter-var-root, and for some reason, ref-set.

--
Jarkko
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 is two!

2009-10-16 Thread Rich Hickey

http://clojure.blogspot.com/2009/10/clojure-is-two.html

Thanks again to all!

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



Re: Clojure is two!

2009-10-16 Thread tmountain

Wow, congrats! I have to say that for only being two, Clojure has made
a helluva stir as an up and comer. I think it's the most exciting
language in serious development right now, and I'm thrilled to be a
part of this community. Thanks to everyone for all the hard work!

-Travis

On Oct 16, 12:12 pm, Rich Hickey  wrote:
> http://clojure.blogspot.com/2009/10/clojure-is-two.html
>
> Thanks again to all!
>
> Rich
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure is two!

2009-10-16 Thread Wilson MacGyver

Congrats. I hadn't heard of clojure until the 1.0 release. So for me,
the amount of
progress and how it's taking off in the past few month has been amazing.

On Fri, Oct 16, 2009 at 12:12 PM, Rich Hickey  wrote:
>
> http://clojure.blogspot.com/2009/10/clojure-is-two.html
>
> Thanks again to all!
>
> Rich
> >
>



-- 
Omnem crede diem tibi diluxisse supremum.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: function names ending with !

2009-10-16 Thread Meikel Brandmeyer
Hi,

Am 16.10.2009 um 18:09 schrieb Jarkko Oranen:

> add-watch doesn't really affect the object itself, while set-
> validator! certainly does, so I think the naming is consistent.
> I think it might be a good rule of thumb to add the ! if the operation
> either mutates the object (set!) or invalidates old values/references
> to it, like persistent! or set-validator!. However, even core.clj
> doesn't seem to follow this...
>
> The exceptions seem to be the "alter" operations for reference types;
> alter, commute, alter-var-root, and for some reason, ref-set.

I also use ! for functions, which modify resources. Eg. creating a  
database table or such.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: clojurecheck?

2009-10-16 Thread Meikel Brandmeyer
Hi,

Am 16.10.2009 um 17:52 schrieb Wilson MacGyver:

> A friend of mine showed me this. It's an effort to bring Haskell's
> Quickcheck to clojure.
>
> http://kotka.de/projects/clojure/clojurecheck.html
>
> Has anyone used it? What's your experience with it?

It is probably not very useful at the moment. The TAP implementation  
should work actually, but the QuickCheck clone is rather - hmm -  
sketchy at best. I want to rework it, but don't really have the  
necessary time at the moment

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: function names ending with !

2009-10-16 Thread Laurent PETIT
2009/10/16 Meikel Brandmeyer 

> Hi,
>
> Am 16.10.2009 um 18:09 schrieb Jarkko Oranen:
>
> > add-watch doesn't really affect the object itself, while set-
> > validator! certainly does, so I think the naming is consistent.
> > I think it might be a good rule of thumb to add the ! if the operation
> > either mutates the object (set!) or invalidates old values/references
> > to it, like persistent! or set-validator!. However, even core.clj
> > doesn't seem to follow this...
> >
> > The exceptions seem to be the "alter" operations for reference types;
> > alter, commute, alter-var-root, and for some reason, ref-set.
>
> I also use ! for functions, which modify resources. Eg. creating a
> database table or such.
>

I'm currently trying to follow the rule that every function with
"side-effect" (e.g. non-pure) has an ended '!'.
Not sure I'll stick to it in the long run, though ...

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 is two!

2009-10-16 Thread MarkSwanson

Grats. Clojure is amazing.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: server-socket on exit event

2009-10-16 Thread ngocdaothanh

The snippet:
---
(def reschedule nil) ; Forward declaration

(defn broadcast [msg]
  (reschedule)
  (doall
(map
  (fn [client]
(send-msg client msg))
  @clients)))
---

(def reschedule nil) is a forward declaration. It is just there to
avoid syntax error, because "broadcast" uses "reschedule", thus
"reschedule" must exist before "broadcast". "reschedule" is actually
defined later in the file.

Thanks for your interest.


On Oct 16, 4:06 pm, Emeka  wrote:
> Ngo,
>
> I checked out your github , it is great. I have not used netty, it looks
> clean. However, what is the meaning of this, (def reshedule nil)?
>
> Regards,
> Emeka
>
> On Thu, Oct 15, 2009 at 3:02 AM, ngocdaothanh wrote:
>
>
>
> > I created this (Netty is used instead of server-socket):
> >http://github.com/ngocdaothanh/telchat-clojure
>
> > I am going to create a Scala version of the same program to have a
> > feeling of Clojure vs Scala, it will be telchat-scala.
>
> > On Oct 14, 10:12 pm, Emeka  wrote:
> > > Ngo,
>
> > > Honestly  speaking I don't know. How far have you gone?
>
> > > Regards,
> > > Emeka
>
> > > On Sat, Oct 3, 2009 at 3:21 PM, ngocdaothanh 
> > wrote:
>
> > > > Emeka, good catch. It's just my mistake.
>
> > > > Another thing is I think there may be exception raised when on-msg
> > > > sends message to a closed socket. How would you solve this?
>
> > > > On Oct 3, 7:35 pm, Emeka  wrote:
> > > > > ngo,
> > > > > I was about doing this kind of client/server thing some  days ago,
> > > > however
> > > > > now you are into it I would like to learn then. I am not quite clear
> > why
> > > > you
> > > > > have this:
> > > > > (.start (new Thread (fn [] (create-server 8080 chat-loop
>
> > > > > My concern is on  Thread, create-server function has a Thread inside
> > > > > create-server-aux function.
>
> > > > > Regards,
> > > > > Emeka
>
> > > > > On Fri, Oct 2, 2009 at 3:13 AM, ngocdaothanh 
> > > > wrote:
>
> > > > > > > I'm not sure TCP/IP has a native facility for that.
>
> > > > > > I'm afraid John's statement is correct:
>
> >http://www.velocityreviews.com/forums/t125620-client-socket-disconnec.
> > > > ..
> > > > > > and trying to read and write until something wrong happens as
> > > > > > demonstrated in Roger's code is the only way to check for
> > > > > > disconnection.
>
> > > > > > Below is my new code. Sorry it is rather long.
>
> > > > > > (import '[java.io BufferedReader InputStreamReader
> > > > > > OutputStreamWriter])
> > > > > > (use 'clojure.contrib.server-socket)
>
> > > > > > (def clients (ref []))  ; Each client is an *out*
>
> > > > > > (defn on-msg [from msg]
> > > > > >  (println msg)
> > > > > >  (doall
> > > > > >    (map
> > > > > >      (fn [client]
> > > > > >        (if-not (= from client)
> > > > > >          (binding [*out* client]
> > > > > >            (println msg)
> > > > > >            (flush
> > > > > >     �...@clients)))
>
> > > > > > (defn on-disconnect [client]
> > > > > >  (dosync
> > > > > >    (alter clients
> > > > > >      (fn [clients]
> > > > > >        (remove (fn [c] (= c client)) clients
> > > > > >  (on-msg client "A client has disconnected"))
>
> > > > > > (defn on-connect [client]
> > > > > >  (dosync (alter clients conj client))
> > > > > >  (on-msg client "A client has connected"))
>
> > > > > > (defn chat-loop [is os]
> > > > > >  (let [client (OutputStreamWriter. os)]
> > > > > >    (on-connect client)
> > > > > >    (binding [*in* (BufferedReader. (InputStreamReader. is))]
> > > > > >      (loop []
> > > > > >        (let [msg (read-line)]  ; msg is nil when the client
> > > > > > disconnects
> > > > > >          (if (nil? msg)
> > > > > >            (on-disconnect client)
> > > > > >            (do
> > > > > >              (on-msg client msg)
> > > > > >              (recur
>
> > > > > > (.start (new Thread (fn [] (create-server 8080 chat-loop
>
> > > > > > On Oct 2, 5:20 am, John Harrop  wrote:
> > > > > > > On Thu, Oct 1, 2009 at 4:02 PM, Roger Gilliar 
> > > > wrote:
> > > > > > > > Am 01.10.2009 um 21:28 schrieb ngocdaothanh:
> > > > > > > > > Roger, your code is not event based.
> > > > > > > > What do you mean by not event based ?
>
> > > > > > > He means he wants automatic notification if a connection is
> > dropped.
>
> > > > > > > I'm not sure TCP/IP has a native facility for that.
>
> > > > > > > What most chat type programs, multiplayer games, and suchlike do
> > is
> > > > send
> > > > > > a
> > > > > > > periodic ping from server to each connected client, which as part
> > of
> > > > the
> > > > > > > chat protocol the client is supposed to acknowledge. If a client
> > > > stops
> > > > > > > responding for more than a few ping-intervals, it's assumed to
> > have
> > > > > > > disconnected or otherwise become unreachable.
>
> > > > > > > This method has the advantage of being entirely under the control
> > of
> > >

Re: function names ending with !

2009-10-16 Thread Mark Volkmann

On Fri, Oct 16, 2009 at 11:09 AM, Jarkko Oranen  wrote:
>
> On Oct 16, 5:44 pm, Mark Volkmann  wrote:
>> What's the rule of thumb for deciding whether a function name should
>> end with an exclamation point? I thought maybe it was when the
>> function modifies its first argument, but it seems there are functions
>> that do that and do not have such names.
>>
>> For example, set-validator! and add-watch. Why don't they either both
>> end with ! or both not do that.
>
> add-watch doesn't really affect the object itself, while set-
> validator! certainly does, so I think the naming is consistent.

set-validator! sets the validator field in the object, so that's a modification.

add-watch replaces the watches map in the object with a new map
containing the new watch function, so that's a modification.

You could say there's a difference because validators can prevent
future changes to an object whereas watchers are just notified.

> I think it might be a good rule of thumb to add the ! if the operation
> either mutates the object (set!) or invalidates old values/references
> to it, like persistent! or set-validator!. However, even core.clj
> doesn't seem to follow this...
>
> The exceptions seem to be the "alter" operations for reference types;
> alter, commute, alter-var-root, and for some reason, ref-set.

So the situation seems to be that the presence of ! in a name
indicates something, but the lack of it doesn't necessarily mean
anything.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: clojurecheck?

2009-10-16 Thread Wilson MacGyver

Thanks for the info. I understand. I'm sure vimclojure is taking up a
lot of your time.

On Fri, Oct 16, 2009 at 12:47 PM, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 16.10.2009 um 17:52 schrieb Wilson MacGyver:
>
>> A friend of mine showed me this. It's an effort to bring Haskell's
>> Quickcheck to clojure.
>>
>> http://kotka.de/projects/clojure/clojurecheck.html
>>
>> Has anyone used it? What's your experience with it?
>
> It is probably not very useful at the moment. The TAP implementation
> should work actually, but the QuickCheck clone is rather - hmm -
> sketchy at best. I want to rework it, but don't really have the
> necessary time at the moment
>
> Sincerely
> Meikel
>
>



-- 
Omnem crede diem tibi diluxisse supremum.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: is there a cannonical way to create executable jar files?

2009-10-16 Thread Folcon

Hi Stuart,

Thanks for the help, I have tried running clojure.main and it doesn't
error out(ie. I think it can find that). However it doesn't seem to do
anything either. I've checked my task manager and I've got an instance
of javaw.exe running, but it just runs. I have a bad feeling it's just
loaded a repl as opposed to running my clojure code. Is there any way
to get the clojure.main to run init or -main in a specific namespace?

Regards,
Folcon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 is two!

2009-10-16 Thread rzeze...@gmail.com

On Oct 16, 12:12 pm, Rich Hickey  wrote:
> http://clojure.blogspot.com/2009/10/clojure-is-two.html
>
> Thanks again to all!
>
> Rich

"Stu Halloway's terrific book, and more books on the way"

Can anyone elaborate on this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 is two!

2009-10-16 Thread Wilson MacGyver

two more coming.

one is clojure in action, published by manning, written by Amit Rathore
the other is definitive guide to clojure by Luke VanderHart
http://www.apress.com/book/view/1430272317

On Fri, Oct 16, 2009 at 3:51 PM, rzeze...@gmail.com  wrote:
>
> On Oct 16, 12:12 pm, Rich Hickey  wrote:
>> http://clojure.blogspot.com/2009/10/clojure-is-two.html
>>
>> Thanks again to all!
>>
>> Rich
>
> "Stu Halloway's terrific book, and more books on the way"
>
> Can anyone elaborate on this?
> >
>



-- 
Omnem crede diem tibi diluxisse supremum.

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



JVM Language Summit talk on state, identity, time

2009-10-16 Thread Garth Sheldon-Coulson
In his blog post Rich mentioned his JVM Language Summit talk
http://wiki.jvmlangsummit.com/Clojure_Keynote
on state, identity, value, time, etc.

There are notes and slides on the site, but no audio or video.

Does anyone know if audio or video was recorded, or (if Rich is reading
this) if there are more comprehensive notes to be gotten?

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: Clojure is two!

2009-10-16 Thread Jeff Heon

Link for clojure in action green paper
http://www.manning.com/free/green_rathore.html

On Oct 16, 3:59 pm, Wilson MacGyver  wrote:
> one is clojure in action, published by manning, written by Amit Rathore

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: clojurecheck?

2009-10-16 Thread Meikel Brandmeyer
Hi,

Am 16.10.2009 um 20:53 schrieb Wilson MacGyver:

> Thanks for the info. I understand. I'm sure vimclojure is taking up a
> lot of your time.

Even VC is lacking a bit at the moment. Buying a new apartment and  
moving there while having a 8-month old around is a task :)

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: clj-html - how to generate DOCTYPE

2009-10-16 Thread Mark McGranaghan

Hi Amitava,

You can se clj-html.helpers/doctype, which is from the clj-html-
helpers project:

http://github.com/mmcgrana/clj-html-helpers

I hope this helps,
- Mark

On Oct 15, 8:26 pm, Amitava  wrote:
> Hello all,
>
> Does anyone know how to generate the html doctype using clj-html? I am
> trying out the conjure web framework.
>
> Thanks & Regards,
> Amitava Shee
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 is two!

2009-10-16 Thread Robert Stehwien
On Fri, Oct 16, 2009 at 1:59 PM, Wilson MacGyver wrote:

>
> two more coming.
>
> one is clojure in action, published by manning, written by Amit Rathore
> the other is definitive guide to clojure by Luke VanderHart
> http://www.apress.com/book/view/1430272317


There are two manning books coming out I believe.  One by Amit and the other
by, I don't know who.  I reviewed 2 clojure book proposals for manning and
was told both were green lighted.  But I haven't heard any more than that.
 Hoping to get on the beta for both.

I'll ping the manning representative.

--Robert


>
>
> On Fri, Oct 16, 2009 at 3:51 PM, rzeze...@gmail.com 
> wrote:
> >
> > On Oct 16, 12:12 pm, Rich Hickey  wrote:
> >> http://clojure.blogspot.com/2009/10/clojure-is-two.html
> >>
> >> Thanks again to all!
> >>
> >> Rich
> >
> > "Stu Halloway's terrific book, and more books on the way"
> >
> > Can anyone elaborate on this?
> > >
> >
>
>
>
> --
> Omnem crede diem tibi diluxisse supremum.
>
> >
>

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



let-while

2009-10-16 Thread mbrodersen

Hi,

I am new to Clojure and I am wondering if there is anything similar to
the following macro already built in:

(defmacro let-while
"Makes it easy to continue processing an expression as long as it is
true"
[[name expr] & forms]
`(loop []
(let [~name ~expr]
(when ~name
~...@forms
(recur)

I find it really useful when (for example) reading from a non-blocking
socket. Here is a quick (silly) example:

(let-while [x (if (> (rand) 0.2) "Yep!" nil)]
(println x)
(println (str x)))

The idea is that x is bound to the if expression and if x is true the
println's are executed. Repeat until x is false/nil.

Thanks
Morten

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 is two!

2009-10-16 Thread mbrodersen

Congratulations everybody.

Clojure is the answer.

On Oct 17, 3:12 am, Rich Hickey  wrote:
> http://clojure.blogspot.com/2009/10/clojure-is-two.html
>
> Thanks again to all!
>
> Rich
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: let-while

2009-10-16 Thread John Harrop
On Fri, Oct 16, 2009 at 7:58 PM, mbrodersen wrote:

>
> Hi,
>
> I am new to Clojure and I am wondering if there is anything similar to
> the following macro already built in:
>
> (defmacro let-while
>"Makes it easy to continue processing an expression as long as it is
> true"
>[[name expr] & forms]
>`(loop []
>(let [~name ~expr]
>(when ~name
>~...@forms
>(recur)
>

Nice.

But name is multiply evaluated. This might be preferable:

(defmacro let-while
  "Makes it easy to continue processing an expression as long as it is true"
  [[name expr] & forms]
  (let [n# ~name]
`(loop []
   (let [~n# ~expr]
 (when ~n#
   ~...@forms
   (recur)

This evaluates the name argument first, and only once, and (as required)
evaluates expr and forms once each time around the loop, plus expr one
additional time (the first time it evaluates to false).

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: let-while

2009-10-16 Thread John Harrop
On Fri, Oct 16, 2009 at 8:12 PM, John Harrop  wrote:

> (defmacro let-while
>   "Makes it easy to continue processing an expression as long as it
> is true"
>   [[name expr] & forms]
>   (let [n# ~name]
> `(loop []
>(let [~n# ~expr]
>  (when ~n#
>~...@forms
>(recur)
>

Dammit.

(defmacro let-while
  "Makes it easy to continue processing an expression as long as it is true"
  [[name expr] & forms]
  `(let [n# ~name]
 (loop []
   (let [n# ~expr]
 (when n#
   ~...@forms
   (recur)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 is two!

2009-10-16 Thread Sean Devlin

Thanks Rich!  Clojure has solved all sorts of crazy problems at work
(i.e. saves money). It makes coding & problem solving fun!

On Oct 16, 12:12 pm, Rich Hickey  wrote:
> http://clojure.blogspot.com/2009/10/clojure-is-two.html
>
> Thanks again to all!
>
> Rich
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: JVM Language Summit talk on state, identity, time

2009-10-16 Thread Alex Osborne

Garth Sheldon-Coulson wrote:
> In his blog post Rich mentioned his JVM Language Summit talk
> on state, identity, value, time, etc.
> 
> Does anyone know if audio or video was recorded, or (if Rich is reading 
> this) if there are more comprehensive notes to be gotten?

The conclusion of it is here:

http://www.youtube.com/watch?v=zRTx1oGG_1Y

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



-> vs comp

2009-10-16 Thread Sean Devlin

I have an idea in my head, and I can't quite put all the details
together.  The intent with of this posting is to start a healthy
debate of the merits of -> vs. comp.  I know people on this list will
think of something.

After designing my own Clojure libraries for a while, I've come to a
conclusion in the -> vs. comp debate. I think comp & partial is a
better choice than ->, because they return a closure. I believe
working with closures have the following advantages

* It "just works" with higher order functions, like map or filter.
* comp, like any other function, can be swapped out. As long as the
result is a closure, the rest of the code will "just work". This makes
swapping out a monad more straightforward.
* comp & partial can be applied to a list, -> cannot.

Given these reasons, I'd like to make a proposal. Contrib should be
centered around closures, not ->.

In order to generate closures, every function should take parameters
first, and data at the end, so that they work well with partial. When
possible, higher order functions should be given preference over
macros.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: -> vs comp

2009-10-16 Thread samppi

Don't forget about the third piece of the puzzle, #() (and fn).
Whenever I need to create a function using ->, I just do #(-> % ...).
It's about as much typing as (comp ...).

Personally, I can go either way—I just kind of wish that there was a
consistent practice for the placement of the most important argument,
whether it's first or last, in both core and contrib.

On Oct 16, 7:22 pm, Sean Devlin  wrote:
> I have an idea in my head, and I can't quite put all the details
> together.  The intent with of this posting is to start a healthy
> debate of the merits of -> vs. comp.  I know people on this list will
> think of something.
>
> After designing my own Clojure libraries for a while, I've come to a
> conclusion in the -> vs. comp debate. I think comp & partial is a
> better choice than ->, because they return a closure. I believe
> working with closures have the following advantages
>
> * It "just works" with higher order functions, like map or filter.
> * comp, like any other function, can be swapped out. As long as the
> result is a closure, the rest of the code will "just work". This makes
> swapping out a monad more straightforward.
> * comp & partial can be applied to a list, -> cannot.
>
> Given these reasons, I'd like to make a proposal. Contrib should be
> centered around closures, not ->.
>
> In order to generate closures, every function should take parameters
> first, and data at the end, so that they work well with partial. When
> possible, higher order functions should be given preference over
> macros.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: -> vs comp

2009-10-16 Thread John Harrop
On Fri, Oct 16, 2009 at 11:55 PM, samppi  wrote:

> Don't forget about the third piece of the puzzle, #() (and fn).
> Whenever I need to create a function using ->, I just do #(-> % ...).
> It's about as much typing as (comp ...).
>
> Personally, I can go either way—I just kind of wish that there was a
> consistent practice for the placement of the most important argument,
> whether it's first or last, in both core and contrib.


While we're at it, let's not forget the fourth piece of the puzzle: swap!,
alter, send, and friends, which work best if functions put the data first
and parameters after. If the parameters come first, all of them need to be
wrapped: instead of (send agent foo param1 param2), say, you need (send
agent #(foo param1 param2 %)). Yuck!

(Irony: -> is also like swap!, alter, and their friends in this regard.)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 hang testing agent

2009-10-16 Thread Robert Stehwien
I'm using the clojure-maven-plugin v1.1 (latest shapshots of clojure and
clojure-contrib) to run a test for an agent that looks like this:

--
(ns com.arcanearcade.clojure.utils.test-timer-agent
  (:require [com.arcanearcade.clojure.utils.timer-agent :as ta])
  (:use clojure.test))

(deftest test-timer-agent-add-five
  (let [timer (ta/create-timer-agent #(+ % 5) :data 8 :run-once? true
:timer-ms 500)]
(is (= 8 (:data @timer)))
(ta/start-timer-agent timer)
(await-for 1000 timer)
(is (= 13 (:data @timer)
--

All the tests run, complete, and report back their status but then the build
freezes until I hit ctrl-c
--
[INFO] [clojure:test {execution: clojure-test}]
Testing com.arcanearcade.clojure.utils.test-file-utils
Testing com.arcanearcade.clojure.utils.test-regex-util
Testing com.arcanearcade.clojure.utils.test-timer-agent
Ran 40 tests containing 76 assertions.
0 failures, 0 errors.
^Crobert-stehwiens-macbook-pro:clojure-rstehwien-utils res$
--

Is there anything wrong with testing an agent like this?

The whole project (with hanging test) can be found here:
http://github.com/rstehwien/clojure-utils

--Robert

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 hang testing agent

2009-10-16 Thread John Harrop
On Sat, Oct 17, 2009 at 12:51 AM, Robert Stehwien wrote:

> I'm using the clojure-maven-plugin v1.1 (latest shapshots of clojure and
> clojure-contrib) to run a test for an agent
>

...


> All the tests run, complete, and report back their status but then the
> build freezes until I hit ctrl-c


Just wait a minute longer, or if you can force a particular test to always
execute last, add a dummy test that does (shutdown-agents) and force it to
execute last.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: is there a cannonical way to create executable jar files?

2009-10-16 Thread Stephen C. Gilardi


On Oct 16, 2009, at 8:12 AM, Folcon wrote:


Is there a cannonical way to create executable jar files?


I've uploaded a shell script that builds an example executable jar  
file to


  http://groups.google.com/group/clojure/web/build-executable-jar.sh

Here's the program the executable jar runs (example/hello.clj):

  (ns example.hello (:gen-class))
  (defn -main [& args]
(apply println "hi" args))

Here's the script's output which traces its operation:

% sh build-executable-jar.sh clojure.jar
+ CLOJURE_JAR=clojure.jar
+ echo staging
staging
+ rm -rf /tmp/stage
+ mkdir -p /tmp/stage/src/example /tmp/stage/classes
+ echo writing Clojure source for main function
writing Clojure source for main function
+ cat
+ echo copying clojure.jar
copying clojure.jar
+ cp clojure.jar /tmp/stage
+ echo entering stage
entering stage
+ cd /tmp/stage
+ echo compiling
compiling
+ java -cp clojure.jar:classes:src clojure.main -e '(compile  
'\''example.hello)'

example.hello
+ echo testing using clojure.jar, class files
testing using clojure.jar, class files
+ java -cp clojure.jar:classes example.hello my name is
hi my name is
+ echo unpacking clojure.jar
unpacking clojure.jar
+ cd classes
+ jar -xf ../clojure.jar
+ echo building manifest
building manifest
+ echo 'Main-Class: example.hello'
+ echo building jar file
building jar file
+ jar -cmf manifest hello.jar -C classes clojure -C classes example
+ echo testing using hello.jar
testing using hello.jar
+ java -jar hello.jar success
hi success
%

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: JVM Language Summit talk on state, identity, time

2009-10-16 Thread Timothy Pratley

The slides match this:
http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
[good recording - one of the best I've come across, gives a very
persuasive reasoning of why Clojure 'has it right']


On Oct 17, 7:58 am, Garth Sheldon-Coulson  wrote:
> In his blog post Rich mentioned his JVM Language Summit 
> talkhttp://wiki.jvmlangsummit.com/Clojure_Keynote
> on state, identity, value, time, etc.
>
> There are notes and slides on the site, but no audio or video.
>
> Does anyone know if audio or video was recorded, or (if Rich is reading
> this) if there are more comprehensive notes to be gotten?
>
> 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
-~--~~~~--~~--~--~---