Re: inconsistent behaviour when resolving java classes

2010-07-07 Thread Meikel Brandmeyer
Hi,

On Jul 7, 3:37 am, Pedro Teixeira  wrote:

> user> (use 'clojure.test)
> user> (testing (defrecord R []) (new R) )
>
> [exception: Unable to resolve classname: R]

I think you get caught by the toplevel form. Clojure compiles the
complete testing form before executing it. So the (R.) can't see the
imported class, because the import is not executed, yet. However,
since (user.R.) is fully qualified no resolution has to be done and
things can be compiled. The moment the constructor is actually called,
the class is already generated.

Executing the two forms at the toplevel first compiles and executes
the defrecord form - including the import. Then the (R.) form is
compiled and since the import was done the classname can be resolved.

Hope that helps.

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: auto-indent in Counterclockwise

2010-07-07 Thread Laurent PETIT
Steven, I did not know this page, thanks for the link.

But to make it really clear: move-past-close-and-reindent is exactly
what counterclockwise's is doing in "Strict" edition mode (not totally
true concerning the reindentation, currently in ccw it is only
reorganizing closing brackets by removing extra spaces, not
reindenting lines).

The problem was that in the "Default" mode, it is inactive, but I've
left the "insert-parentheses" function active. So people are annoyed
in the "Default" mode because they tend to type the closing ")" "]" or
"}" and then it appears twice in code.

Funny enough, the "Default" mode was created because people complained
about the "move-past-close-and-reindent" (they found it unnatural, and
they were fighting with it when they wanted to really add a damn extra
closing bracket at caret position).

2010/7/7 Steven E. Harris :
> Laurent PETIT  writes:
>
>>> I think it's a good feature, *if* typing the closing bracket/paren just
>>> resulted in "cursoring over" the one that'd already been inserted.
>>
>> ?
>
> See the Emacs function `move-past-close-and-reindent'. It works as the
> obvious counterpart to the function `insert-paretheses'.¹
>
>
> Footnotes:
> ¹ http://www.cliki.net/Editing%20Lisp%20Code%20with%20Emacs
>
> --
> Steven E. Harris
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from 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: Aleph, an asynchronous web server

2010-07-07 Thread Zach Tellman
At the Bay Area user group meeting in June, there was a very
interesting discussion about how to best use Clojure's concurrency
primitives to field large numbers of concurrent requests, especially
in a long-poll/push type application.  We didn't arrive at any solid
conclusion, but it was clear to everyone that a thread-per-request
model is especially gratuitous for a language like Clojure.

With this in mind, I decided to make the thinnest possible wrapper
around Netty such that a person could play around with alternate ways
to use Clojure effectively.  The result can be found at
http://github.com/ztellman/aleph.

I've just discovered another Netty wrapper was released this weekend
(http://github.com/datskos/ring-netty-adapter), but it's somewhat
different in its design and intent; it couples the request and
response to allow for seamless interop with Ring.

Anyways, I hope some people find this interesting.  Clojure doesn't
seem to have found its own voice w.r.t. web development; hopefully we
can work together to fix that.

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

2010-07-07 Thread George Jahad
Thanks Markus,

yes, I intentionally wanted to keep it "decoupled from any particular
editor".  I had two goals in writing CDT.

The immediate goal was to provide a better tool for debugging
exceptions, which was harder than it should be in Clojure.

The longer term goal was to expose the JDI to Clojure in a way that
allows us all to experiment with, to really provide a debugger
toolkit, little building blocks that we can all assemble in our own
ways until we find the best debugging patterns that work for Clojure,
patterns that we can share with each other without worrying about
which IDE we are using.

I think debugging Clojure is a unique beast and the standard line by
line step and break paradigm isn't sufficient.  I wanted a toolkit
that allows me to easily throw together debugger extensions that are
Clojure specific.

For example, with the building blocks CDT provides, I think it would
be fairly easy to write a function that returns a seq of all the
locals in all of the threads.  You could then filter through that seq
to find the ones that are holding the head of a lazy seq.  I doubt you
could do that with any other debugger, and certainly not easily.  CDT
is actually a hackable debugger.

Anyway, back to your point, I've found tool discussions often become
marginalized because they are tied to a specific IDE/platform so only
users of that platform can participate intelligently.  By leaving it
"decoupled", I'm hoping to provide a level playing field where we can
all share ideas.

The downside of course is it is much less user-friendly than one that
is actually integrated with an IDE.  It's certainly not going to solve
"Clojure's n00b attraction problem" ;)

On Jul 6, 11:30 pm, mac  wrote:
> I agree with Laurent, this looks very cool.
> It's great that you are making it a text/repl interface because that
> means it's decoupled from any particular editor and can easily be used
> as a base for gui debuggers in different editors and IDEs.
>
> /Markus
>
> On Jul 7, 7:39 am, George Jahad  wrote:
>
> > Thanks for the heads up, (and for the compliment,) Laurent.  I should
> > have checked it out more carefully beforehand.  I'm probably going to
> > leave it as it is for now, until I see how much interest there is.
>
> > As you may have suspected, I'm an Emacs user and so don't know much
> > about Eclipse.  But I know you put a lot of work into
> > CounterClockwise, and our community is lucky to have you!
>
> > On Jul 6, 1:21 am, Laurent PETIT  wrote:
>
> > > Oh, and btw, impressive work ! :)
>
> > > 2010/7/6 Laurent PETIT :
>
> > > > Hi George,
>
> > > > a quick word concerning the name: FYI, CDT, in the Eclipse world, in a
> > > > name taken a long time ago to mean "C/C++ Development Tools". Make
> > > > what you want with this info :)
>
> > > > 2010/7/6 George Jahad :
> > > >> My experiment with the JDI:
>
> > > >>http://georgejahad.com/clojure/cdt.html
>
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> > > >> Groups "Clojure" group.
> > > >> To post to this group, send email to clojure@googlegroups.com
> > > >> Note that posts from new members are moderated - please be patient 
> > > >> with your first post.
> > > >> To unsubscribe from this group, send email to
> > > >> clojure+unsubscr...@googlegroups.com
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/clojure?hl=en

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

2010-07-07 Thread Nicolas Oury
It looks very cool. Great to have a Clojure text interface and not another
adhoc laguage.
Will make working with it easier, as well as building tools around 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: CDT - The Clojure Debugging Toolkit

2010-07-07 Thread Anders Rune Jensen
On Wed, Jul 7, 2010 at 11:43 AM, George Jahad
 wrote:
> Thanks Markus,
>
> yes, I intentionally wanted to keep it "decoupled from any particular
> editor".  I had two goals in writing CDT.
>
> The immediate goal was to provide a better tool for debugging
> exceptions, which was harder than it should be in Clojure.
>
> The longer term goal was to expose the JDI to Clojure in a way that
> allows us all to experiment with, to really provide a debugger
> toolkit, little building blocks that we can all assemble in our own
> ways until we find the best debugging patterns that work for Clojure,
> patterns that we can share with each other without worrying about
> which IDE we are using.
>
> I think debugging Clojure is a unique beast and the standard line by
> line step and break paradigm isn't sufficient.  I wanted a toolkit
> that allows me to easily throw together debugger extensions that are
> Clojure specific.
>
> For example, with the building blocks CDT provides, I think it would
> be fairly easy to write a function that returns a seq of all the
> locals in all of the threads.  You could then filter through that seq
> to find the ones that are holding the head of a lazy seq.  I doubt you
> could do that with any other debugger, and certainly not easily.  CDT
> is actually a hackable debugger.
>
> Anyway, back to your point, I've found tool discussions often become
> marginalized because they are tied to a specific IDE/platform so only
> users of that platform can participate intelligently.  By leaving it
> "decoupled", I'm hoping to provide a level playing field where we can
> all share ideas.
>
> The downside of course is it is much less user-friendly than one that
> is actually integrated with an IDE.  It's certainly not going to solve
> "Clojure's n00b attraction problem" ;)

More debugging options are very helpful! CDT reminds me a bit of
common lisp exception handling. But as always, documentation and more
documentation would be good :) Especially with examples like the one
you describe with locals in all of the threads.

> On Jul 6, 11:30 pm, mac  wrote:
>> I agree with Laurent, this looks very cool.
>> It's great that you are making it a text/repl interface because that
>> means it's decoupled from any particular editor and can easily be used
>> as a base for gui debuggers in different editors and IDEs.
>>
>> /Markus
>>
>> On Jul 7, 7:39 am, George Jahad  wrote:
>>
>> > Thanks for the heads up, (and for the compliment,) Laurent.  I should
>> > have checked it out more carefully beforehand.  I'm probably going to
>> > leave it as it is for now, until I see how much interest there is.
>>
>> > As you may have suspected, I'm an Emacs user and so don't know much
>> > about Eclipse.  But I know you put a lot of work into
>> > CounterClockwise, and our community is lucky to have you!
>>
>> > On Jul 6, 1:21 am, Laurent PETIT  wrote:
>>
>> > > Oh, and btw, impressive work ! :)
>>
>> > > 2010/7/6 Laurent PETIT :
>>
>> > > > Hi George,
>>
>> > > > a quick word concerning the name: FYI, CDT, in the Eclipse world, in a
>> > > > name taken a long time ago to mean "C/C++ Development Tools". Make
>> > > > what you want with this info :)
>>
>> > > > 2010/7/6 George Jahad :
>> > > >> My experiment with the JDI:
>>
>> > > >>http://georgejahad.com/clojure/cdt.html
>>
>> > > >> --
>> > > >> You received this message because you are subscribed to the Google
>> > > >> Groups "Clojure" group.
>> > > >> To post to this group, send email to clojure@googlegroups.com
>> > > >> Note that posts from new members are moderated - please be patient 
>> > > >> with your first post.
>> > > >> To unsubscribe from this group, send email to
>> > > >> clojure+unsubscr...@googlegroups.com
>> > > >> For more options, visit this group at
>> > > >>http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
Anders Rune Jensen

http://www.iola.dk

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

2010-07-07 Thread David Nolen
On Wed, Jul 7, 2010 at 5:15 AM, Zach Tellman  wrote:

> At the Bay Area user group meeting in June, there was a very
> interesting discussion about how to best use Clojure's concurrency
> primitives to field large numbers of concurrent requests, especially
> in a long-poll/push type application.  We didn't arrive at any solid
> conclusion, but it was clear to everyone that a thread-per-request
> model is especially gratuitous for a language like Clojure.
>
> With this in mind, I decided to make the thinnest possible wrapper
> around Netty such that a person could play around with alternate ways
> to use Clojure effectively.  The result can be found at
> http://github.com/ztellman/aleph.
>
> I've just discovered another Netty wrapper was released this weekend
> (http://github.com/datskos/ring-netty-adapter), but it's somewhat
> different in its design and intent; it couples the request and
> response to allow for seamless interop with Ring.
>
> Anyways, I hope some people find this interesting.  Clojure doesn't
> seem to have found its own voice w.r.t. web development; hopefully we
> can work together to fix that.
>

It's great to see Clojure weighing in on the evented webserver. As far as
feedback, it would be nice to see at least one example where aleph allows
you to use the Clojure concurrency primitives in ways that are not possible
with Ring and the Jetty adapter. Otherwise I'm a bit lost as to how to start
playing around :)

David

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

2010-07-07 Thread David Nolen
On Tue, Jul 6, 2010 at 2:14 AM, George Jahad
wrote:

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


Good stuff, looking forward to playing around with this.

David

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

2010-07-07 Thread aria42
I've needed --> a few times in my code. I don't think I need it as
much as just -> or ->>. Most of the time I've needed it is because I
or someone else essentially had parameters
in the wrong order. Maybe it belongs in contrib along with -?> which
I've needed sparingly as well, but have found useful and would've been
non-trivial to have conjured.

On Jul 6, 5:22 pm, David Nolen  wrote:
> On Tue, Jul 6, 2010 at 5:02 PM, Greg  wrote:
>
> > I'll make a list here of the reasons given for Yay/Nay so far:
>
> > Nay:
>
> > 1) "I haven't had a need for a general threading macro."
> > 2) The response so far is negative (and consists of repeating point #1
> > above).
>
> 3) It would encourage people to not follow Clojure's conventions around
> argument positions for fns that deal with sequences/collections.
>
> That is a pretty important Nay and illustrates that --> decreases
> readability for people that have spent time with Clojure.
>
> It also points out why -> and ->> are not really about position anyway, it's
> about threading an expression. -> is to make Clojure read left-right instead
> of inside-out. ->> is to make Clojure read left-right when operating on
> sequences/collections.
>
> Both are far, far more common and useful then being able to fill arguments
> anywhere.
>
> David

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

2010-07-07 Thread Laurent PETIT
2010/7/7 aria42 :
> I've needed --> a few times in my code. I don't think I need it as
> much as just -> or ->>. Most of the time I've needed it is because I
> or someone else essentially had parameters
> in the wrong order. Maybe it belongs in contrib along with -?> which
> I've needed sparingly as well, but have found useful and would've been
> non-trivial to have conjured.

-?> is particularly suitable when doing lots of java interop. I use it
quite a lot in my own code in counterclockwise, for example.

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


Re: How to convert a list to arguments?

2010-07-07 Thread Cachou
Another way:

suppose test-list -> (list 1 2 3)

`(max ~...@test-list) can translate the form to what you want

so you can use eval or define a macro to handle it.



On Jul 5, 11:38 am, Mike Meyer  wrote:
> On Sun, 4 Jul 2010 20:21:22 -0700 (PDT)
>
> dennis  wrote:
> > For example:
> > (max 1 2 3)  => 3
> > (max (list 1 2 3)) => (1 2 3)
>
> > How to convert (list 1 2 3) to arguments for function?
>
> Sounds like you want apply:
>
> (apply max (list 1 2 3)) => 3
>
>        --
> 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: inconsistent behaviour when resolving java classes

2010-07-07 Thread Nick Mudge
What about (use 'clojure.test.user) ?

On Jul 6, 6:37 pm, Pedro Teixeira  wrote:
> Hi,
>
> The following seems like it was not intended, please let me know if it
> is intended.
>
> user> (use 'clojure.test)
> user> (testing (defrecord R []) (new R) )
>
> [exception: Unable to resolve classname: R]
>
> user> (defrecord R []) (new R)
>
> [ok]
>
> now, if we use the full class name, it works:
> (testing (defrecord R []) (new user.R) )
>
> is the namespace resolution affected by a macro or binding context?
>
> thanks,
> Pedro

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

2010-07-07 Thread ngocdaothanh
> [org.jboss.netty/netty "3.2.0.BETA1"]

Netty 3.2.1.Final has been released.

I think the ! mark in "respond!" is kind of misleading. Why not change
it to "arespond"?

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

2010-07-07 Thread songoku
> Thanks for both answers. Two ways of doing it. Great!

The :jvm-opts "-Xmx1g" -option in the project-file doesnt seem to work
with the swank-server.

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


Re: How to convert a list to arguments?

2010-07-07 Thread Nicolas Oury
On Wed, Jul 7, 2010 at 4:12 AM, Cachou  wrote:

> Another way:
>
> suppose test-list -> (list 1 2 3)
>
> `(max ~...@test-list) can translate the form to what you want
>
> so you can use eval or define a macro to handle it.
>
>
>
> But, most of the time, it is a bad idea.
(Except if you are in situations that call for that)
eval is very rarely useful in a program.

And doing this in a macro probably won't do what you want, except if
test-list is known at compile time.

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

2010-07-07 Thread Zach Tellman

On Jul 7, 2:57 am, ngocdaothanh  wrote:
> > [org.jboss.netty/netty "3.2.0.BETA1"]
>
> Netty 3.2.1.Final has been released.
>
> I think the ! mark in "respond!" is kind of misleading. Why not change
> it to "arespond"?

For some reason I couldn't get 3.2.1.Final to come in via maven.  I
didn't want to spend too much time futzing with it, but I'll take
another look at it.

I don't understand your point about the bang.  The respond! function
certainly has side effects, and shouldn't be used in a transaction.
What qualities is it missing that make the bang misleading?

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


Make a loop in a loop

2010-07-07 Thread uap12
Hi!
I try to make a printout witch vill have year 1999->2010 and every
week
Eg.
Year=1999 Week=1
Year=1999 Week=2
Year=1999 Week=3
Year=1999 Week=4

Year=2000 Week=1

I have made the program in java, but like to try making it in Clojure,
but so far i have got

(defn print-data [year week]
(println  (str  "Y=" year " W=" week)))


// This would not work and  i can't find how to map (print-data with a
external variabel and a range
// I can set week to a fixed number but not.
// Or is this the wrong way of doing it ??

(defn print-data2 [year]
(map (print-data year *) (range 1 53 1)))


(defn run []
(map print-data2 (range 1999 2010 1) ) )

The program vill call an externa system program, with year and week as
input, but for this test i just
like to write them...

// Anders

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

2010-07-07 Thread miner
First, thanks for your work.  I appreciate it.  Now some comments:

"Select top level s-expression" and "evaluate current selection or top-
level s-expression" should act on the sexp in front of the cursor,
especially if the cursor is at the end of an sexp.  When I tried it, I
was getting the next sexp even when it was a couple of lines below the
cursor.

"Load clojure file in REPL" should start a REPL if there isn't one
already.

In general, I would prefer not to have hierarchical menus, especially
when there aren't so many menu items to begin with.

New feature request: I would like to be able to double-click on a
paren or bracket to select the enclosed element.  (Same operation as
"Expand selection to... enclosing element".)

By the way, I let Eclipse install the new version (RC2) without
uninstalling the old one (plain 0.0.58 I think).  It seems like it
worked OK.

Thanks,
Steve

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

2010-07-07 Thread Nicolas Oury
(defn print-data2 [year]
(dorun   (map #(print-data year %) (range 1 53 1


I think you have both a problem with the syntax of anonymous functions and a
problem of lazyness.
map only creates a lazy seq that do not get evaluated.

dorun do that


You can have a look at list comprehensions (for), if you want to keep
sequences
If you want to do a more imperative solution dotimes is your friend. (Nicest
when you want to print it, I think)

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

2010-07-07 Thread Pedro Henriques dos Santos Teixeira
On Wed, Jul 7, 2010 at 4:27 AM, Meikel Brandmeyer  wrote:
> Hi,
>
> On Jul 7, 3:37 am, Pedro Teixeira  wrote:
>
>> user> (use 'clojure.test)
>> user> (testing (defrecord R []) (new R) )
>>
>> [exception: Unable to resolve classname: R]
>
> I think you get caught by the toplevel form. Clojure compiles the
> complete testing form before executing it. So the (R.) can't see the
> imported class, because the import is not executed, yet. However,
> since (user.R.) is fully qualified no resolution has to be done and
> things can be compiled. The moment the constructor is actually called,
> the class is already generated.
>
> Executing the two forms at the toplevel first compiles and executes
> the defrecord form - including the import. Then the (R.) form is
> compiled and since the import was done the classname can be resolved.
>
> Hope that helps.

Thanks a lot for the insight.

Are there any design guidelines for choosing between defrecords and
defstruct, when one wants a map with type?

I started with defrecord, but feels like I should switch to defstruct
to avoid these complex host integration issues.


best regards,
Pedro

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

2010-07-07 Thread Greg
(for [y (range 1999 2011) w (range 1 52)] (println "year=" y "w=" w))

On Jul 7, 2010, at 10:47 AM, uap12 wrote:

> Hi!
> I try to make a printout witch vill have year 1999->2010 and every
> week
> Eg.
> Year=1999 Week=1
> Year=1999 Week=2
> Year=1999 Week=3
> Year=1999 Week=4
> 
> Year=2000 Week=1
> 
> I have made the program in java, but like to try making it in Clojure,
> but so far i have got
> 
> (defn print-data [year week]
>   (println  (str  "Y=" year " W=" week)))
> 
> 
> // This would not work and  i can't find how to map (print-data with a
> external variabel and a range
> // I can set week to a fixed number but not.
> // Or is this the wrong way of doing it ??
> 
> (defn print-data2 [year]
>   (map (print-data year *) (range 1 53 1)))
> 
> 
> (defn run []
> (map print-data2 (range 1999 2010 1) ) )
> 
> The program vill call an externa system program, with year and week as
> input, but for this test i just
> like to write them...
> 
> // Anders
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from 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: Make a loop in a loop

2010-07-07 Thread Lars Nilsson
On Wed, Jul 7, 2010 at 10:47 AM, uap12  wrote:
> I have made the program in java, but like to try making it in Clojure,
> but so far i have got
> 
> (defn print-data [year week]
>        (println  (str  "Y=" year " W=" week)))
>
>
> // This would not work and  i can't find how to map (print-data with a
> external variabel and a range
> // I can set week to a fixed number but not.
> // Or is this the wrong way of doing it ??
>
> (defn print-data2 [year]
>        (map (print-data year *) (range 1 53 1)))
>
>
> (defn run []
> (map print-data2 (range 1999 2010 1) ) )
>
> The program vill call an externa system program, with year and week as
> input, but for this test i just
> like to write them...

Maybe

(doseq [year (range 1999 2010 1)]
  (doseq [month (range 1 53 1)]
(print-data year range)))

Regards,
Lars Nilsson

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

2010-07-07 Thread Nurullah Akkaya
You can build a sequence of year week pairs using,

(for [y (range 1999 2011)
   w (range 1 53)] [y w])

then you can iterate over that and print,

(doseq [[y w] (for [y (range 1999 2011)
 w (range 1 53)] [y w])]
  (println "Year " y "Week " w))


Hope it helps...
--
Nurullah Akkaya
http://nakkaya.com



On Wed, Jul 7, 2010 at 5:47 PM, uap12  wrote:
> Hi!
> I try to make a printout witch vill have year 1999->2010 and every
> week
> Eg.
> Year=1999 Week=1
> Year=1999 Week=2
> Year=1999 Week=3
> Year=1999 Week=4
> 
> Year=2000 Week=1
>
> I have made the program in java, but like to try making it in Clojure,
> but so far i have got
> 
> (defn print-data [year week]
>        (println  (str  "Y=" year " W=" week)))
>
>
> // This would not work and  i can't find how to map (print-data with a
> external variabel and a range
> // I can set week to a fixed number but not.
> // Or is this the wrong way of doing it ??
>
> (defn print-data2 [year]
>        (map (print-data year *) (range 1 53 1)))
>
>
> (defn run []
> (map print-data2 (range 1999 2010 1) ) )
>
> The program vill call an externa system program, with year and week as
> input, but for this test i just
> like to write them...
>
> // Anders
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from 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: Make a loop in a loop

2010-07-07 Thread Stuart Halloway
This usage of for is ill-advised: for is not a loop, it is a comprehension. 
This will not do what you want if, for example, you assign the result of for to 
a variable instead of entering it at the REPL.

Nurullah's response on this thread shows a nice separation of building the 
(lazy) structure and printing it.

Stu

> (for [y (range 1999 2011) w (range 1 52)] (println "year=" y "w=" w))
> 
> On Jul 7, 2010, at 10:47 AM, uap12 wrote:
> 
>> Hi!
>> I try to make a printout witch vill have year 1999->2010 and every
>> week
>> Eg.
>> Year=1999 Week=1
>> Year=1999 Week=2
>> Year=1999 Week=3
>> Year=1999 Week=4
>> 
>> Year=2000 Week=1
>> 
>> I have made the program in java, but like to try making it in Clojure,
>> but so far i have got
>> 
>> (defn print-data [year week]
>>  (println  (str  "Y=" year " W=" week)))
>> 
>> 
>> // This would not work and  i can't find how to map (print-data with a
>> external variabel and a range
>> // I can set week to a fixed number but not.
>> // Or is this the wrong way of doing it ??
>> 
>> (defn print-data2 [year]
>>  (map (print-data year *) (range 1 53 1)))
>> 
>> 
>> (defn run []
>> (map print-data2 (range 1999 2010 1) ) )
>> 
>> The program vill call an externa system program, with year and week as
>> input, but for this test i just
>> like to write them...
>> 
>> // Anders
>> 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Counterclockwise version 0.0.59.RC2

2010-07-07 Thread Laurent PETIT
2010/7/7 miner :
> First, thanks for your work.  I appreciate it.  Now some comments:
>
> "Select top level s-expression" and "evaluate current selection or top-
> level s-expression" should act on the sexp in front of the cursor,
> especially if the cursor is at the end of an sexp.

By "in front", you mean "before" ? If so, then I disagree, because all
other commands consider that when there is no selection, it's the
"next" form/symbol that must be considered by the command.

But BTW, if you're "just after" a top level s-expression, you can
still get this form selected, by using structural selection  : on
Linux/Windows it is then Shift+Alt+LEFT ARROW.

What "select top level s-expression" has over Structural selection is
that if you're "deep inside" a top-level form, you can in one command
get the top-level form selected.

> When I tried it, I
> was getting the next sexp even when it was a couple of lines below the
> cursor.

Seems to be the correct behaviour to me.

> "Load clojure file in REPL" should start a REPL if there isn't one
> already.

Yes, that is a nice addition to the feature. Issue added.
http://code.google.com/p/counterclockwise/issues/detail?id=119

You can star it if you want to get informed of this progress (this is
an easy enhancement, expect to have it in the next or so release).

> In general, I would prefer not to have hierarchical menus, especially
> when there aren't so many menu items to begin with.

Hmm, I'll think about this 

> New feature request: I would like to be able to double-click on a
> paren or bracket to select the enclosed element.  (Same operation as
> "Expand selection to... enclosing element".)

Interesting. Added as a low priority enhancement:
http://code.google.com/p/counterclockwise/issues/detail?id=121

> By the way, I let Eclipse install the new version (RC2) without
> uninstalling the old one (plain 0.0.58 I think).  It seems like it
> worked OK.

Good to know. I had problems myself, but it was late, and maybe I did an error.


Thanks for the feedback !

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: Make a loop in a loop

2010-07-07 Thread Laurent PETIT
or rather

(for [y (range 1999 (inc 2010))
      w (range 1 (inc 52))] [y w])

which remove the 2011 and 53 magic values ;-)

2010/7/7 Nurullah Akkaya :
> You can build a sequence of year week pairs using,
>
> (for [y (range 1999 2011)
>       w (range 1 53)] [y w])
>
> then you can iterate over that and print,
>
> (doseq [[y w] (for [y (range 1999 2011)
>                             w (range 1 53)] [y w])]
>  (println "Year " y "Week " w))
>
>
> Hope it helps...
> --
> Nurullah Akkaya
> http://nakkaya.com
>
>
>
> On Wed, Jul 7, 2010 at 5:47 PM, uap12  wrote:
>> Hi!
>> I try to make a printout witch vill have year 1999->2010 and every
>> week
>> Eg.
>> Year=1999 Week=1
>> Year=1999 Week=2
>> Year=1999 Week=3
>> Year=1999 Week=4
>> 
>> Year=2000 Week=1
>>
>> I have made the program in java, but like to try making it in Clojure,
>> but so far i have got
>> 
>> (defn print-data [year week]
>>        (println  (str  "Y=" year " W=" week)))
>>
>>
>> // This would not work and  i can't find how to map (print-data with a
>> external variabel and a range
>> // I can set week to a fixed number but not.
>> // Or is this the wrong way of doing it ??
>>
>> (defn print-data2 [year]
>>        (map (print-data year *) (range 1 53 1)))
>>
>>
>> (defn run []
>> (map print-data2 (range 1999 2010 1) ) )
>>
>> The program vill call an externa system program, with year and week as
>> input, but for this test i just
>> like to write them...
>>
>> // Anders
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Make a loop in a loop

2010-07-07 Thread Meikel Brandmeyer
Hi,

Am 07.07.2010 um 17:10 schrieb Nurullah Akkaya:

> (doseq [[y w] (for [y (range 1999 2011)
> w (range 1 53)] [y w])]
>  (println "Year " y "Week " w))

And just for the record:

If you don't need the intermediate seq you can use doseq directly:

(doseq [y (range 1999 2011)
w (range 1 53)]
  (println "Year" y "Week" w))

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: Counterclockwise version 0.0.59.RC2

2010-07-07 Thread miner
Many years of Emacs have trained me to expect evaluation of the form
before the cursor.  For example, with | standing for the cursor
position:

--
(+ 3 4)|

(* 2 3)
--

I expect to evaluate (+ 3 4).  Often I put my cursor right after an
expression just so I can execute it.  Again, that's how Emacs does
it.  This also makes it convenient to type and expression and evaluate
it immediately without having to move the cursor.

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

2010-07-07 Thread Laurent PETIT
2010/7/7 miner :
> [...] This also makes it convenient to type and expression and evaluate
> it immediately without having to move the cursor.

Now that's something to consider, indeed ... this makes 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: ANN: Aleph, an asynchronous web server

2010-07-07 Thread David Nolen
On Wed, Jul 7, 2010 at 5:15 AM, Zach Tellman  wrote:

> With this in mind, I decided to make the thinnest possible wrapper
> around Netty such that a person could play around with alternate ways
> to use Clojure effectively.  The result can be found at
> http://github.com/ztellman/aleph.


I played around with this some. Throughput is of course ridiculous (8+ K
req/s on my machine). One thing is that this approach encourages using
Clojure concurrency primitives over participating in the Netty NIO design.
Is that the intent?

David

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

Idiomatic Clojure namespace names

2010-07-07 Thread James Reeves
I've kinda asked this question before, but I framed in the context of
a suggestion, and the discussion got bogged down with no real answer.

So this time, let me keep it simple: if I have a small Clojure
library, "foo", which only has one namespace, what is the idiomatic
name for that namespace?

 - foo
 - foo.foo
 - foo.core
 - com.github.weavejester.foo

I don't intend to call "foo" from Java, so there is no genclass in the
namespace definition, and I do not intend to AOT compile the
namespace.

- 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: Make a loop in a loop

2010-07-07 Thread Greg
On Jul 7, 2010, at 11:14 AM, Stuart Halloway wrote:

> This usage of for is ill-advised: for is not a loop, it is a comprehension. 
> This will not do what you want if, for example, you assign the result of for 
> to a variable instead of entering it at the REPL.
> 
> Nurullah's response on this thread shows a nice separation of building the 
> (lazy) structure and printing it.

Odd you say that for is ill-advised when Nurullah did the same thing and used 
for.

But I guess you meant to say it's ill advised to put the println inside the 
body of the for, which is a good point, 'doseq' + 'for' does the trick.

- Greg


> Stu
> 
>> (for [y (range 1999 2011) w (range 1 52)] (println "year=" y "w=" w))
>> 
>> On Jul 7, 2010, at 10:47 AM, uap12 wrote:
>> 
>>> Hi!
>>> I try to make a printout witch vill have year 1999->2010 and every
>>> week
>>> Eg.
>>> Year=1999 Week=1
>>> Year=1999 Week=2
>>> Year=1999 Week=3
>>> Year=1999 Week=4
>>> 
>>> Year=2000 Week=1
>>> 
>>> I have made the program in java, but like to try making it in Clojure,
>>> but so far i have got
>>> 
>>> (defn print-data [year week]
>>> (println  (str  "Y=" year " W=" week)))
>>> 
>>> 
>>> // This would not work and  i can't find how to map (print-data with a
>>> external variabel and a range
>>> // I can set week to a fixed number but not.
>>> // Or is this the wrong way of doing it ??
>>> 
>>> (defn print-data2 [year]
>>> (map (print-data year *) (range 1 53 1)))
>>> 
>>> 
>>> (defn run []
>>> (map print-data2 (range 1999 2010 1) ) )
>>> 
>>> The program vill call an externa system program, with year and week as
>>> input, but for this test i just
>>> like to write them...
>>> 
>>> // Anders
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with 
>>> your first post.
>>> To unsubscribe from 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

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

2010-07-07 Thread Greg
Oh, sorry, I misread, I thought you said "*The* usage of for is ill-advised" :-p

- Greg

On Jul 7, 2010, at 11:27 AM, Greg wrote:

> On Jul 7, 2010, at 11:14 AM, Stuart Halloway wrote:
> 
>> This usage of for is ill-advised: for is not a loop, it is a comprehension. 
>> This will not do what you want if, for example, you assign the result of for 
>> to a variable instead of entering it at the REPL.
>> 
>> Nurullah's response on this thread shows a nice separation of building the 
>> (lazy) structure and printing it.
> 
> Odd you say that for is ill-advised when Nurullah did the same thing and used 
> for.
> 
> But I guess you meant to say it's ill advised to put the println inside the 
> body of the for, which is a good point, 'doseq' + 'for' does the trick.
> 
> - Greg
> 
> 
>> Stu
>> 
>>> (for [y (range 1999 2011) w (range 1 52)] (println "year=" y "w=" w))
>>> 
>>> On Jul 7, 2010, at 10:47 AM, uap12 wrote:
>>> 
 Hi!
 I try to make a printout witch vill have year 1999->2010 and every
 week
 Eg.
 Year=1999 Week=1
 Year=1999 Week=2
 Year=1999 Week=3
 Year=1999 Week=4
 
 Year=2000 Week=1
 
 I have made the program in java, but like to try making it in Clojure,
 but so far i have got
 
 (defn print-data [year week]
(println  (str  "Y=" year " W=" week)))
 
 
 // This would not work and  i can't find how to map (print-data with a
 external variabel and a range
 // I can set week to a fixed number but not.
 // Or is this the wrong way of doing it ??
 
 (defn print-data2 [year]
(map (print-data year *) (range 1 53 1)))
 
 
 (defn run []
 (map print-data2 (range 1999 2010 1) ) )
 
 The program vill call an externa system program, with year and week as
 input, but for this test i just
 like to write them...
 
 // Anders
 
 -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from 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
> 

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

2010-07-07 Thread RandyHudson
'doseq instead 'for works fine:

(doseq [y (range 1999 2011), w (range 1 52)] (print-data y w))

On Jul 7, 11:14 am, Stuart Halloway  wrote:
> This usage of for is ill-advised: for is not a loop, it is a comprehension. 
> This will not do what you want if, for example, you assign the result of for 
> to a variable instead of entering it at the REPL.
>
> Nurullah's response on this thread shows a nice separation of building the 
> (lazy) structure and printing it.
>
> Stu
>
> > (for [y (range 1999 2011) w (range 1 52)] (println "year=" y "w=" w))
>
> > On Jul 7, 2010, at 10:47 AM, uap12 wrote:
>
> >> Hi!
> >> I try to make a printout witch vill have year 1999->2010 and every
> >> week
> >> Eg.
> >> Year=1999 Week=1
> >> Year=1999 Week=2
> >> Year=1999 Week=3
> >> Year=1999 Week=4
> >> 
> >> Year=2000 Week=1
>
> >> I have made the program in java, but like to try making it in Clojure,
> >> but so far i have got
> >> 
> >> (defn print-data [year week]
> >>        (println  (str  "Y=" year " W=" week)))
>
> >> // This would not work and  i can't find how to map (print-data with a
> >> external variabel and a range
> >> // I can set week to a fixed number but not.
> >> // Or is this the wrong way of doing it ??
>
> >> (defn print-data2 [year]
> >>        (map (print-data year *) (range 1 53 1)))
>
> >> (defn run []
> >> (map print-data2 (range 1999 2010 1) ) )
>
> >> The program vill call an externa system program, with year and week as
> >> input, but for this test i just
> >> like to write them...
>
> >> // Anders
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Clojure" group.
> >> To post to this group, send email to clojure@googlegroups.com
> >> Note that posts from new members are moderated - please be patient with 
> >> your first post.
> >> To unsubscribe from this group, send email to
> >> clojure+unsubscr...@googlegroups.com
> >> For more options, visit this group at
> >>http://groups.google.com/group/clojure?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

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


Re: Make a loop in a loop

2010-07-07 Thread Greg
> If you don't need the intermediate seq you can use doseq directly:
> 
> (doseq [y (range 1999 2011)
>w (range 1 53)]
>  (println "Year" y "Week" w))

That's really cool, I didn't know you can do that.

I just looked over its implementation and it seems pretty complex but 
interesting, so now that's on my list of things to learn for today. :-)


On Jul 7, 2010, at 11:44 AM, Meikel Brandmeyer wrote:

> Hi,
> 
> Am 07.07.2010 um 17:10 schrieb Nurullah Akkaya:
> 
>> (doseq [[y w] (for [y (range 1999 2011)
>>w (range 1 53)] [y w])]
>> (println "Year " y "Week " w))
> 
> And just for the record:
> 
> If you don't need the intermediate seq you can use doseq directly:
> 
> (doseq [y (range 1999 2011)
>w (range 1 53)]
>  (println "Year" y "Week" w))
> 
> Sincerely
> Meikel
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Idiomatic Clojure namespace names

2010-07-07 Thread Laurent PETIT
Hi,

2010/7/7 James Reeves :
> I've kinda asked this question before, but I framed in the context of
> a suggestion, and the discussion got bogged down with no real answer.
>
> So this time, let me keep it simple: if I have a small Clojure
> library, "foo", which only has one namespace, what is the idiomatic
> name for that namespace?
>
>  - foo
>  - foo.foo
>  - foo.core
>  - com.github.weavejester.foo
>
> I don't intend to call "foo" from Java, so there is no genclass in the
> namespace definition, and I do not intend to AOT compile the
> namespace.

I would say:
if this library is only for you, and you don't intend to share it
-ever-, then "foo" for the namespace is good.
if you intend to share the library, then use the classical prefix notation:

  * either of the form net.reeves.james.foo  ( or any reversed tld you "own" )
  * either of the form com.yourcorp.foo

Of course, if your library has an especially cryptic name (as we have
with counterclockwise: ccw), then having also directly foo may also
not interfere with other's namespaces. That's the path we took for
counterclockwise, and our top-level namespace/package is just 'ccw'

My 0.02 €,

-- 
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: ANN: Aleph, an asynchronous web server

2010-07-07 Thread ngocdaothanh
> For some reason I couldn't get 3.2.1.Final to come in via maven.

I think you need to add this to project.clj:
:repositories [["jboss" "http://repository.jboss.org/nexus/content/
groups/public/"]]

> What qualities is it missing that make the bang misleading?

I thinks ! means something dangerous is about to happen.

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

2010-07-07 Thread Peter Schuller
This is not in answer to the question, but I just wanted to say: I
love that fact that Clojure got namespaces "right" in the sense of
allowing aliasing on import. Some languages don't do this, and you end
up with very difficult naming issues since you suddenly have a huge
desire to keep it short *while* also meaningful, structured  and
non-clashing.

+1 for clojure :)

-- 
/ Peter Schuller

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


Variadic arguments and macros

2010-07-07 Thread Cameron
Hello all! Today, I've either discovered a bug, or I've discovered a
flaw in my understanding of macros. Most likely the latter :-) Could
anyone set me straight?

While this is not the macro I was trying to write, it falls over in
the same place.

(user=> (defmacro foo [& xs] `(map identity ~xs))
#'user/foo
user=> (foo 1 2)
java.lang.ClassCastException: java.lang.Integer cannot be cast to
clojure.lang.IFn (NO_SOURCE_FILE:0)

However, this does work (though it doesn't feel idiomatic).

user=> (defmacro foo [& xs] `(map identity [...@xs]))
#'user/foo
user=> (foo 1 2)
(1 2)

I have tried this on todays (July 7) bleeding edge and 1.1 with the
same results.

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

2010-07-07 Thread David Nolen
On Wed, Jul 7, 2010 at 12:49 PM, Cameron  wrote:

> Hello all! Today, I've either discovered a bug, or I've discovered a
> flaw in my understanding of macros. Most likely the latter :-) Could
> anyone set me straight?
>
> While this is not the macro I was trying to write, it falls over in
> the same place.
>
> (user=> (defmacro foo [& xs] `(map identity ~xs))
> #'user/foo
> user=> (foo 1 2)

java.lang.ClassCastException: java.lang.Integer cannot be cast to
> clojure.lang.IFn (NO_SOURCE_FILE:0)
>

You're splicing in the list (1 2). 1 is not function, thus the error.


> However, this does work (though it doesn't feel idiomatic).
>
> user=> (defmacro foo [& xs] `(map identity [...@xs]))
> #'user/foo
> user=> (foo 1 2)
> (1 2)
>

Looks pretty idiomatic to me :)

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

2010-07-07 Thread Nicolas Oury
If you macroexpand the first foo in (foo 1 2), you will see something like
(1 2)

when this gets evaluated, Clojure is not happy about 1 not being a function.

On Wed, Jul 7, 2010 at 5:49 PM, Cameron  wrote:

> Hello all! Today, I've either discovered a bug, or I've discovered a
> flaw in my understanding of macros. Most likely the latter :-) Could
> anyone set me straight?
>
> While this is not the macro I was trying to write, it falls over in
> the same place.
>
> (user=> (defmacro foo [& xs] `(map identity ~xs))
> #'user/foo
> user=> (foo 1 2)
> java.lang.ClassCastException: java.lang.Integer cannot be cast to
> clojure.lang.IFn (NO_SOURCE_FILE:0)
>
> However, this does work (though it doesn't feel idiomatic).
>
> user=> (defmacro foo [& xs] `(map identity [...@xs]))
> #'user/foo
> user=> (foo 1 2)
> (1 2)
>
> I have tried this on todays (July 7) bleeding edge and 1.1 with the
> same results.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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: Variadic arguments and macros

2010-07-07 Thread miner
I think you're missing a quote in your original macro.
You wrote:
 (defmacro foo [& xs] `(map identity ~xs))

Try this in a REPL:

user=> (macroexpand-1 '(foo 1 2))
(clojure.core/map clojure.core/identity (1 2))

That shows you that it's going to try to evaluate the form (1 2). The
original complaint is that 1 is not a function.  Using the vector
notation [] created a literal vector which works without quoting.

Try this instead:

user=> (defmacro foo [& xs] `(map identity (quote ~xs)))
#'user/foo
user=> (foo 1 2)
(1 2)

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

2010-07-07 Thread Nicolas Oury
Of course I meant
(map identity (1 2))

On Wed, Jul 7, 2010 at 6:03 PM, Nicolas Oury  wrote:

> If you macroexpand the first foo in (foo 1 2), you will see something like
> (1 2)
>
> when this gets evaluated, Clojure is not happy about 1 not being a
> function.
>
>
> On Wed, Jul 7, 2010 at 5:49 PM, Cameron  wrote:
>
>> Hello all! Today, I've either discovered a bug, or I've discovered a
>> flaw in my understanding of macros. Most likely the latter :-) Could
>> anyone set me straight?
>>
>> While this is not the macro I was trying to write, it falls over in
>> the same place.
>>
>> (user=> (defmacro foo [& xs] `(map identity ~xs))
>> #'user/foo
>> user=> (foo 1 2)
>> java.lang.ClassCastException: java.lang.Integer cannot be cast to
>> clojure.lang.IFn (NO_SOURCE_FILE:0)
>>
>> However, this does work (though it doesn't feel idiomatic).
>>
>> user=> (defmacro foo [& xs] `(map identity [...@xs]))
>> #'user/foo
>> user=> (foo 1 2)
>> (1 2)
>>
>> I have tried this on todays (July 7) bleeding edge and 1.1 with the
>> same results.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from 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: Variadic arguments and macros

2010-07-07 Thread Jason Wolfe
Hi Cameron,

On Jul 7, 9:49 am, Cameron  wrote:
> Hello all! Today, I've either discovered a bug, or I've discovered a
> flaw in my understanding of macros. Most likely the latter :-) Could
> anyone set me straight?
>
> While this is not the macro I was trying to write, it falls over in
> the same place.
>
> (user=> (defmacro foo [& xs] `(map identity ~xs))
> #'user/foo
> user=> (foo 1 2)
> java.lang.ClassCastException: java.lang.Integer cannot be cast to
> clojure.lang.IFn (NO_SOURCE_FILE:0)

Well, let's look at the macroexpansion:

user> (macroexpand '(foo 1 2))
(clojure.core/map clojure.core/identity (1 2))

As you can see, this tries to call 1 with an argument of 2, which
gives the exception you see.

If you want your arguments evaluated, I think your solution is as good
as any.  If you want them unevaluated, you can do:

user> (defmacro foo2 [& xs] `(map identity '~xs))
#'user/foo2
user> (foo2 1 2)
(1 2)

The difference:

user> (foo2 1 (+ 1 1))
(1 (+ 1 1))

-Jason

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

2010-07-07 Thread Meikel Brandmeyer
Hi,

Am 07.07.2010 um 18:04 schrieb Greg:

>> If you don't need the intermediate seq you can use doseq directly:
>> 
>> (doseq [y (range 1999 2011)
>>   w (range 1 53)]
>> (println "Year" y "Week" w))
> 
> That's really cool, I didn't know you can do that.

for and doseq are quite similar in its form, but completely different in 
semantics: for creates a lazy sequence(*) while doseq performs the body. But 
they support a quite similar set of modifiers in the bindings:

(for [x (range 10) :let [y (inc x)] :when (even? y)] x)
=> (1 3 5 7 9)

(doseq [x (range 10) :let [y (inc x)] :when (even? y)] (println x))
1
3
5
7
9
=> nil

As I said in a different thread: consistency matters. And clojure is full of it.

Sincerely
Meikel

(*) That's the reason why the body of for is *not* wrapped into an implicit do.

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

2010-07-07 Thread Cameron
Thanks for all the replies everyone, I certainly have a solution now.
But I am still a little confused. Take this slight variation...

user=> (defmacro foo [coll] `(map identity ~coll))
#'user/foo
user=> (foo [1 2 3 `(+ 1 1)])
(1 2 3 (clojure.core/+ 1 1))

In this one, I am passing an explicit list and simply calling unquote
on it. I guess what I want to know is, how is passing an explicit list
different from having one destructured with '&' in the arguments
list?


On Jul 7, 1:04 pm, Nicolas Oury  wrote:
> Of course I meant
> (map identity (1 2))
>
>
>
> On Wed, Jul 7, 2010 at 6:03 PM, Nicolas Oury  wrote:
> > If you macroexpand the first foo in (foo 1 2), you will see something like
> > (1 2)
>
> > when this gets evaluated, Clojure is not happy about 1 not being a
> > function.
>
> > On Wed, Jul 7, 2010 at 5:49 PM, Cameron  wrote:
>
> >> Hello all! Today, I've either discovered a bug, or I've discovered a
> >> flaw in my understanding of macros. Most likely the latter :-) Could
> >> anyone set me straight?
>
> >> While this is not the macro I was trying to write, it falls over in
> >> the same place.
>
> >> (user=> (defmacro foo [& xs] `(map identity ~xs))
> >> #'user/foo
> >> user=> (foo 1 2)
> >> java.lang.ClassCastException: java.lang.Integer cannot be cast to
> >> clojure.lang.IFn (NO_SOURCE_FILE:0)
>
> >> However, this does work (though it doesn't feel idiomatic).
>
> >> user=> (defmacro foo [& xs] `(map identity [...@xs]))
> >> #'user/foo
> >> user=> (foo 1 2)
> >> (1 2)
>
> >> I have tried this on todays (July 7) bleeding edge and 1.1 with the
> >> same results.
>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Clojure" group.
> >> To post to this group, send email to clojure@googlegroups.com
> >> Note that posts from new members are moderated - please be patient with
> >> your first post.
> >> To unsubscribe from 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: Variadic arguments and macros

2010-07-07 Thread Cameron
Thanks everyone! I certainly have my solution; but, I'm still a bit
confused. Here's another example...

user=> (defmacro foo [coll] `(map identity ~coll))
#'user/foo
user=> (foo (list 1 2 3))
(1 2 3)

In this example, I pass an explicit list and all I have to do is
unquote 'coll'. How is passing an explicit list any different than
having it destructured via '&' in the argument vector?

On Jul 7, 1:11 pm, Jason Wolfe  wrote:
> Hi Cameron,
>
> On Jul 7, 9:49 am, Cameron  wrote:
>
> > Hello all! Today, I've either discovered a bug, or I've discovered a
> > flaw in my understanding of macros. Most likely the latter :-) Could
> > anyone set me straight?
>
> > While this is not the macro I was trying to write, it falls over in
> > the same place.
>
> > (user=> (defmacro foo [& xs] `(map identity ~xs))
> > #'user/foo
> > user=> (foo 1 2)
> > java.lang.ClassCastException: java.lang.Integer cannot be cast to
> > clojure.lang.IFn (NO_SOURCE_FILE:0)
>
> Well, let's look at the macroexpansion:
>
> user> (macroexpand '(foo 1 2))
> (clojure.core/map clojure.core/identity (1 2))
>
> As you can see, this tries to call 1 with an argument of 2, which
> gives the exception you see.
>
> If you want your arguments evaluated, I think your solution is as good
> as any.  If you want them unevaluated, you can do:
>
> user> (defmacro foo2 [& xs] `(map identity '~xs))
> #'user/foo2
> user> (foo2 1 2)
> (1 2)
>
> The difference:
>
> user> (foo2 1 (+ 1 1))
> (1 (+ 1 1))
>
> -Jason

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

2010-07-07 Thread Meikel Brandmeyer
Hi,

Am 07.07.2010 um 15:47 schrieb Pedro Henriques dos Santos Teixeira:

> Are there any design guidelines for choosing between defrecords and
> defstruct, when one wants a map with type?
> 
> I started with defrecord, but feels like I should switch to defstruct
> to avoid these complex host integration issues.

You should stay with defrecord. It will replace defstruct eventually. There are 
no complex host integration issues. It's just that you have to understand how 
clojure compiles code and that what you want to do requires you to qualify your 
classname. Is there a reason, why you can't put the defrecord simply before the 
testing?

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: ANN: Aleph, an asynchronous web server

2010-07-07 Thread Zach Tellman
On Jul 7, 9:12 am, David Nolen  wrote:
> On Wed, Jul 7, 2010 at 5:15 AM, Zach Tellman  wrote:
> > With this in mind, I decided to make the thinnest possible wrapper
> > around Netty such that a person could play around with alternate ways
> > to use Clojure effectively.  The result can be found at
> >http://github.com/ztellman/aleph.
>
> I played around with this some. Throughput is of course ridiculous (8+ K
> req/s on my machine). One thing is that this approach encourages using
> Clojure concurrency primitives over participating in the Netty NIO design.
> Is that the intent?
>
> David

Developers are still required to "participate" in the NIO design, in
that blocking calls in the request handler need to be avoided to reap
the full benefits.  Netty provides a lot of nice abstractions over
NIO, but kind of punts on how to effectively manage the concurrency it
requires.  Clojure's concurrency primitives don't really have a
counterpart in Netty, so I don't see why they shouldn't be used.

If you really want access to Netty, though, (:channel request) will
return an org.jboss.netty.channel.Channel object, which will allow you
to do pretty much anything you want.

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

2010-07-07 Thread Zach Tellman
On Jul 7, 8:28 am, ngocdaothanh  wrote:
> > For some reason I couldn't get 3.2.1.Final to come in via maven.
>
> I think you need to add this to project.clj:
> :repositories [["jboss" "http://repository.jboss.org/nexus/content/
> groups/public/"]]
>

Thanks, I'll give that a try.

> > What qualities is it missing that make the bang misleading?
>
> I thinks ! means something dangerous is about to happen.

If by "dangerous" you mean side-effects, then respond! qualifies.
It's neither pure nor idempotent, and it's important that people
realize that fact.

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

2010-07-07 Thread James Reeves
On 7 July 2010 17:24, Laurent PETIT  wrote:
> Of course, if your library has an especially cryptic name (as we have
> with counterclockwise: ccw), then having also directly foo may also
> not interfere with other's namespaces. That's the path we took for
> counterclockwise, and our top-level namespace/package is just 'ccw'

For the purposes of this discussion, let us assume that "foo" is a
suitably unique library name, and it is highly unlikely there exist
any other libraries with the same name.

- 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: ANN: Aleph, an asynchronous web server

2010-07-07 Thread David Nolen
On Wed, Jul 7, 2010 at 1:43 PM, Zach Tellman  wrote:

> Developers are still required to "participate" in the NIO design, in
> that blocking calls in the request handler need to be avoided to reap
> the full benefits.  Netty provides a lot of nice abstractions over
> NIO, but kind of punts on how to effectively manage the concurrency it
> requires.  Clojure's concurrency primitives don't really have a
> counterpart in Netty, so I don't see why they shouldn't be used.
>

So something like this:

(defn hello-world [request]
  (future
   (Thread/sleep 1)
   (respond! request
 {:status 200
  :headers {"Content-Type" "text/html"}
  :body "Hello world!"})))

Is non-blocking and perfectly fine?


> If you really want access to Netty, though, (:channel request) will
> return an org.jboss.netty.channel.Channel object, which will allow you
> to do pretty much anything you want.
>

Great!

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

2010-07-07 Thread James Reeves
On 7 July 2010 19:04, David Nolen  wrote:
> So something like this:
> (defn hello-world [request]
>   (future
>    (Thread/sleep 1)
>    (respond! request
>              {:status 200
>               :headers {"Content-Type" "text/html"}
>               :body "Hello world!"})))
> Is non-blocking and perfectly fine?

Actually that rather defeats the point of a non-blocking server.
You're still using up a thread, and hence haven't really gained
anything over:

  (defn hello-world [request]
(Thread/sleep 1)
{:status 200
 :headers {"Content-Type" "text/html"}
 :body "Hello world!"})

The main advantage of a non-blocking server is that you're don't use
up a thread waiting for an event (such as the user sending data, or
some other external trigger).

- 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: ANN: Aleph, an asynchronous web server

2010-07-07 Thread David Nolen
On Wed, Jul 7, 2010 at 2:10 PM, James Reeves wrote:

> On 7 July 2010 19:04, David Nolen  wrote:
> > So something like this:
> > (defn hello-world [request]
> >   (future
> >(Thread/sleep 1)
> >(respond! request
> >  {:status 200
> >   :headers {"Content-Type" "text/html"}
> >   :body "Hello world!"})))
> > Is non-blocking and perfectly fine?
>
> Actually that rather defeats the point of a non-blocking server.
> You're still using up a thread, and hence haven't really gained
> anything over:
>
>  (defn hello-world [request]
>(Thread/sleep 1)
> {:status 200
> :headers {"Content-Type" "text/html"}
> :body "Hello world!"})
>
> The main advantage of a non-blocking server is that you're don't use
> up a thread waiting for an event (such as the user sending data, or
> some other external trigger).
>
> - James


But I guess I'm trying to figure out what the most idiomatic way to pipeline
in this situation would be (one thing I don't like about Node.js is that it
encourages working with a mess of callbacks).

For example what would be the best most idiomatic way to hit a database
(blocking operation), process that data and return the result with respond!
?

David

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

2010-07-07 Thread Meikel Brandmeyer
Hi,

Am 07.07.2010 um 18:13 schrieb James Reeves:

> - foo.core
> - com.github.weavejester.foo

I would go with one of these two. At the moment I prefer the former. I think 
putting domain names in the package is suboptimal for a quite simple reason. 
I'm a hobbyist. I don't own a domain. Eh? What to put there? nil.foo? So I 
choose the hosting site. com.google.code.foo. Ah. I move to github. So rename 
everything to com.github.foo.  Iegh. github sucks. So next rename to 
org.gitorious.foo. Ah. I like mercurial better. org.bitbucket.foo.

Ok. That's a little far-fetched but it happens (jetty).

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: ANN: Aleph, an asynchronous web server

2010-07-07 Thread Zach Tellman


On Jul 7, 11:17 am, David Nolen  wrote:
> On Wed, Jul 7, 2010 at 2:10 PM, James Reeves wrote:
>
>
>
>
>
> > On 7 July 2010 19:04, David Nolen  wrote:
> > > So something like this:
> > > (defn hello-world [request]
> > >   (future
> > >    (Thread/sleep 1)
> > >    (respond! request
> > >              {:status 200
> > >               :headers {"Content-Type" "text/html"}
> > >               :body "Hello world!"})))
> > > Is non-blocking and perfectly fine?
>
> > Actually that rather defeats the point of a non-blocking server.
> > You're still using up a thread, and hence haven't really gained
> > anything over:
>
> >  (defn hello-world [request]
> >    (Thread/sleep 1)
> >     {:status 200
> >     :headers {"Content-Type" "text/html"}
> >     :body "Hello world!"})
>
> > The main advantage of a non-blocking server is that you're don't use
> > up a thread waiting for an event (such as the user sending data, or
> > some other external trigger).
>
> > - James
>
> But I guess I'm trying to figure out what the most idiomatic way to pipeline
> in this situation would be (one thing I don't like about Node.js is that it
> encourages working with a mess of callbacks).
>
> For example what would be the best most idiomatic way to hit a database
> (blocking operation), process that data and return the result with respond!
> ?
>
> David

I'd say the most idiomatic way to hit a database is to use one that
has a non-blocking interface (postgres is one example).  Barring that,
I'd say that the future approach is slightly better than the thread-
per-request model because it uses a thread pool, but otherwise the
chain is only going to be as strong as its weakest link.

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

2010-07-07 Thread Justin Kramer
As part of the Clojure Examples Wiki experiment, I created a page
adapted from the Cheatsheet, with links to relevant docs and examples
(not many, yet):

http://clojure-examples.appspot.com/clojure.core

It's been reorganized and revised a bit from the Cheatsheet. The
design is a little plain but it's a first cut.

Justin

On Jul 2, 5:11 pm, ngocdaothanh  wrote:
> Hi,
>
> This is my nth attempt to learn Clojure.
>
> I think it will be an improvement if there are links to API document
> for functions in the cheat sheet (http://clojure.org/cheatsheet).
> Clicking a function name will jump right to the description for the
> function is very convenient for newbies.

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


navigate and edit tree nodes / branches

2010-07-07 Thread Bill Marshall
Is there a library facilitating the navigating and editing nodes in a fairly
complex tree (nested map) structure?  billm

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

2010-07-07 Thread Laurent PETIT
Quick answer (sorry not much time): clojure.zip

It's quite easy to use once you've got the basics "in place"

2010/7/7 Bill Marshall :
> Is there a library facilitating the navigating and editing nodes in a fairly
> complex tree (nested map) structure?  billm
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from 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: inconsistent behaviour when resolving java classes

2010-07-07 Thread Pedro Henriques dos Santos Teixeira
On Wed, Jul 7, 2010 at 2:42 PM, Meikel Brandmeyer  wrote:
> Hi,>
> Am 07.07.2010 um 15:47 schrieb Pedro Henriques dos Santos Teixeira:>

>> Are there any design guidelines for choosing between defrecords and
>> defstruct, when one wants a map with type?
>>
>> I started with defrecord, but feels like I should switch to defstruct
>> to avoid these complex host integration issues.
>
> You should stay with defrecord. It will replace defstruct eventually. There 
> are no complex host integration issues. It's just that you have to understand 
> how clojure compiles code and that what you want to do requires you to 
> qualify your classname. Is there a reason, why you can't put the defrecord 
> simply before the testing?
>

Thanks for the feedback. I actually decided to stay with defrecord as
well --> already seeing the benefits of extending protocols later on.

There is no problem for this particular testing use case, but I was a
bit worried that a function might eval differently accordingly to how
it was called. But then I realized that's alright and it's totally
fine in the lisp world.


By the way, is anyone aware of any way to destroy a class that was generated?
Situation is that I might have dynamically generated records. They may
be no longer used, in these cases, it might make sense to remove the
generated bytecode  and unload from classloader.

cheers,
Pedro

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

2010-07-07 Thread Pedro Henriques dos Santos Teixeira
On Wed, Jul 7, 2010 at 2:55 PM, James Reeves  wrote:
> On 7 July 2010 17:24, Laurent PETIT  wrote:
>> Of course, if your library has an especially cryptic name (as we have
>> with counterclockwise: ccw), then having also directly foo may also
>> not interfere with other's namespaces. That's the path we took for
>> counterclockwise, and our top-level namespace/package is just 'ccw'
>
> For the purposes of this discussion, let us assume that "foo" is a
> suitably unique library name, and it is highly unlikely there exist
> any other libraries with the same name.

if "foo" is to be shared on public repos, a prefix denotating its
author or origin is quite essencial -- especially in these "github"
days. For instance, it would be best if the namespaces relate to the
project/jar name in the repo. Right?


Perhaps, immigrate can be used to hide long namespace names

(ns foo)
(immigrate 'origin.foo)


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

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


Re: ANN: Aleph, an asynchronous web server

2010-07-07 Thread Pedro Henriques dos Santos Teixeira
On Wed, Jul 7, 2010 at 3:10 PM, James Reeves  wrote:
> On 7 July 2010 19:04, David Nolen  wrote:
>> So something like this:
>> (defn hello-world [request]
>>   (future
>>    (Thread/sleep 1)
>>    (respond! request
>>              {:status 200
>>               :headers {"Content-Type" "text/html"}
>>               :body "Hello world!"})))
>> Is non-blocking and perfectly fine?
>
> Actually that rather defeats the point of a non-blocking server.
> You're still using up a thread, and hence haven't really gained
> anything over:
>
>  (defn hello-world [request]
>    (Thread/sleep 1)
>    {:status 200
>     :headers {"Content-Type" "text/html"}
>     :body "Hello world!"})
>
> The main advantage of a non-blocking server is that you're don't use
> up a thread waiting for an event (such as the user sending data, or
> some other external trigger).


Actually, a huge benefit of a non-blocking http server is that it
won't create a thread per request. But, don't seen any problem the use
code spawing threads to handle work for one particular request.

In clojure, I think it'll be hard to go NIO all the way (like in node.js).

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

2010-07-07 Thread Saul Hazledine
On Jul 7, 5:24 pm, Laurent PETIT  wrote:
> if you intend to share the library, then use the classical prefix notation:
>
>   * either of the form net.reeves.james.foo  ( or any reversed tld you "own" )
>   * either of the form com.yourcorp.foo
>

com.read.to.easy.that.not.its.but

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

2010-07-07 Thread David Blubaugh
To All,


I am extremely interested in LISP and Clojure.  I was wondering if it
would be possible to obtain NSF grant funding for further development
of Clojure ??

thanks,

David Blubaugh


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


examples (like doc)

2010-07-07 Thread John Cromartie
I've whipped up a proof-of-concept of how to implement built-in
examples for functions and macros. The general idea is to add an
attribute to the var that contains a list of docstrings and arg lists
or code that illustrate common usage.

Let me know what you think: http://gist.github.com/466743

It could also be useful for generating documentation.

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

2010-07-07 Thread Mike Meyer

"Meikel Brandmeyer"  wrote:

>Hi,
>
>Am 07.07.2010 um 18:13 schrieb James Reeves:
>
>> - foo.core
>> - com.github.weavejester.foo
>
>I would go with one of these two. At the moment I prefer the former. I think 
>putting domain names in the package is suboptimal for a quite simple reason. 
>I'm a hobbyist. I don't own a domain. Eh? What to put there? nil.foo? So I 
>choose the hosting site. com.google.code.foo. Ah. I move to github. So rename 
>everything to com.github.foo.  Iegh. github sucks. So next rename to 
>org.gitorious.foo. Ah. I like mercurial better. org.bitbucket.foo.

Why bother renaming it when you move? You're going to want to put a redirect up 
at the old site anyway. Just leave it there until the project dies.

That's actually better than using your own domain name. Should you change 
domain names, you have to keep paying for it or loose it. With a repo provider, 
it's generally free.
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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


Re: Variadic arguments and macros

2010-07-07 Thread Laurent PETIT
2010/7/7 Cameron :
> Thanks everyone! I certainly have my solution; but, I'm still a bit
> confused. Here's another example...
>
> user=> (defmacro foo [coll] `(map identity ~coll))
> #'user/foo
> user=> (foo (list 1 2 3))
> (1 2 3)
>
> In this example, I pass an explicit list and all I have to do is
> unquote 'coll'. How is passing an explicit list any different than
> having it destructured via '&' in the argument vector?


You're not passing a list. You're passing the code for creating a list.
Use macroexpand, it's your friend

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

2010-07-07 Thread Luc Préfontaine

Here in Canada we have a number
of programs for R&D and the
bureaucratic burden is not worth
the $$$ you get back for it except
if you a budget in the 6 digits range.

And if you want to get the paper done
by a consultant, he/she will charge
20% of the expected refund.

I looked at the NSF documentation
and I am not convinced that the
red tape is minimal.

You certainly loose some flexibilty
by having to get scope changes
approved by them.

Anyone got involved with them ?

Luc P

Sent from my iPod

On 2010-07-07, at 14:49, David Blubaugh   
wrote:



To All,


I am extremely interested in LISP and Clojure.  I was wondering if it
would be possible to obtain NSF grant funding for further development
of Clojure ??

thanks,

David Blubaugh


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient  
with your first post.

To unsubscribe from 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: examples (like doc)

2010-07-07 Thread Moritz Ulrich
I don't think examples should be integrated in the
function-definition. It's *way* to much bloat.

I like the way http://clojure-examples.appspot.com/clojure.core goes.
A wiki-like documentation for examples, linked to every
clojure-namespace. These examples could be serialized into some data
structure and integrated in clojure.jar. This would result in no bloat
for core.clj etc. and nice, accessible examples for our
development-tools.

On Wed, Jul 7, 2010 at 9:05 PM, John Cromartie  wrote:
> I've whipped up a proof-of-concept of how to implement built-in
> examples for functions and macros. The general idea is to add an
> attribute to the var that contains a list of docstrings and arg lists
> or code that illustrate common usage.
>
> Let me know what you think: http://gist.github.com/466743
>
> It could also be useful for generating documentation.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
Moritz Ulrich
Programmer, Student, Almost normal Guy

http://www.google.com/profiles/ulrich.moritz

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


Ordering of messages to agents

2010-07-07 Thread Brian Hurt
I'm wondering if the following pattern is safe or not.  I'm in a
transaction, and I want to create an agent and then send it an initializing
message (the message function isn't transaction-safe, so I don't want to run
it in the transaction).  So I want to do something like:

(def my-ref (ref nil))

(defn example [ f ]
(dosync
(if (nil? @my-ref)
(let [ a (agent nil) ]
(ref-set my-ref a)
(send a init-function)
(send a f))
(send @my-ref f

(actually, what I want to do is rather more complicated than this, but this
demonstrates the problem).  So, my question is: is it guaranteed that
init-function will be received by the agent before any f functions are
received?

Brian

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

Re: Ordering of messages to agents

2010-07-07 Thread Meikel Brandmeyer
Hi,

Am 07.07.2010 um 22:46 schrieb Brian Hurt:

> I'm wondering if the following pattern is safe or not.  I'm in a transaction, 
> and I want to create an agent and then send it an initializing message (the 
> message function isn't transaction-safe, so I don't want to run it in the 
> transaction).  So I want to do something like:
> 
> (def my-ref (ref nil))
> 
> (defn example [ f ]
> (dosync
> (if (nil? @my-ref)
> (let [ a (agent nil) ]
> (ref-set my-ref a)
> (send a init-function)
> (send a f))
> (send @my-ref f
> 
> (actually, what I want to do is rather more complicated than this, but this 
> demonstrates the problem).  So, my question is: is it guaranteed that 
> init-function will be received by the agent before any f functions are 
> received?  

The ordering of sends will be preserved, although they will be scheduled after 
the transaction commits.

It might be due to the simplified example, but... Why don't you just initialise 
your agent when you create it?

(def my-ref (agent (init-function)))

(defn example
  [f]
  (send @my-ref f))

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: Make a loop in a loop

2010-07-07 Thread Isak Hansen
On Wed, Jul 7, 2010 at 5:00 PM, Lars Nilsson  wrote:
>
> Maybe
>
> (doseq [year (range 1999 2010 1)]
>  (doseq [month (range 1 53 1)]
>    (print-data year range)))
>

You could also do this with dotimes instead of doseq. Doesn't matter
for Ns this small, but creating a range just so you have something to
iterate across is a bit wasteful.


Isak



> Regards,
> Lars Nilsson
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from 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: navigate and edit tree nodes / branches

2010-07-07 Thread Moritz Ulrich
There is also assoc-in and get-in for accessing and associng values in
nested maps.

On Wed, Jul 7, 2010 at 9:26 PM, Laurent PETIT  wrote:
> Quick answer (sorry not much time): clojure.zip
>
> It's quite easy to use once you've got the basics "in place"
>
> 2010/7/7 Bill Marshall :
>> Is there a library facilitating the navigating and editing nodes in a fairly
>> complex tree (nested map) structure?  billm
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your
>> first post.
>> To unsubscribe from 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



-- 
Moritz Ulrich
Programmer, Student, Almost normal Guy

http://www.google.com/profiles/ulrich.moritz

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

2010-07-07 Thread Meikel Brandmeyer
Hi,

Am 07.07.2010 um 21:41 schrieb Mike Meyer:

> Why bother renaming it when you move?

Why come into a situation where bothering is a question?

Sincerely
Meikel

PS: You K-9 Mail sends every message twice.

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

2010-07-07 Thread Brian Hurt
On Wed, Jul 7, 2010 at 5:04 PM, Meikel Brandmeyer  wrote:

> Hi,
>
> Am 07.07.2010 um 22:46 schrieb Brian Hurt:
>
> > I'm wondering if the following pattern is safe or not.  I'm in a
> transaction, and I want to create an agent and then send it an initializing
> message (the message function isn't transaction-safe, so I don't want to run
> it in the transaction).  So I want to do something like:
> >
> > (def my-ref (ref nil))
> >
> > (defn example [ f ]
> > (dosync
> > (if (nil? @my-ref)
> > (let [ a (agent nil) ]
> > (ref-set my-ref a)
> > (send a init-function)
> > (send a f))
> > (send @my-ref f
> >
> > (actually, what I want to do is rather more complicated than this, but
> this demonstrates the problem).  So, my question is: is it guaranteed that
> init-function will be received by the agent before any f functions are
> received?
>
> The ordering of sends will be preserved, although they will be scheduled
> after the transaction commits.
>
> It might be due to the simplified example, but... Why don't you just
> initialise your agent when you create it?
>
>
This is due to the simplified example.  I'm actually creating a map of keys
to soft references to agents (and removing the references and keys from the
map when the agents are reclaimed), which allows me to generate agents only
when I need them, and have them freed when they are no longer needed.

(def my-ref (agent (init-function)))
>
> (defn example
>  [f]
>  (send @my-ref f))
>
> Sincerely
> Meikel
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Re: Re: Clojure for NSF grant funding

2010-07-07 Thread labwork07
All I know is that you have to show educational value for NSF. So, funding  
for development should be accompanied by teaching or lecturing.



On Jul 7, 2010 4:14pm, Luc Préfontaine  wrote:

Here in Canada we have a number



of programs for R&D and the



bureaucratic burden is not worth



the $$$ you get back for it except



if you a budget in the 6 digits range.





And if you want to get the paper done



by a consultant, he/she will charge



20% of the expected refund.





I looked at the NSF documentation



and I am not convinced that the



red tape is minimal.





You certainly loose some flexibilty



by having to get scope changes



approved by them.





Anyone got involved with them ?





Luc P





Sent from my iPod




On 2010-07-07, at 14:49, David Blubaugh davidblubaugh2...@gmail.com>  
wrote:






To All,







I am extremely interested in LISP and Clojure. I was wondering if it



would be possible to obtain NSF grant funding for further development



of Clojure ??





thanks,





David Blubaugh







--



You received this message because you are subscribed to the Google



Groups "Clojure" group.



To post to this group, send email to clojure@googlegroups.com


Note that posts from new members are moderated - please be patient with  
your first post.



To unsubscribe from this group, send email to



clojure+unsubscr...@googlegroups.com



For more options, visit this group at



http://groups.google.com/group/clojure?hl=en






--



You received this message because you are subscribed to the Google



Groups "Clojure" group.



To post to this group, send email to clojure@googlegroups.com


Note that posts from new members are moderated - please be patient with  
your first post.



To unsubscribe from this group, send email to



clojure+unsubscr...@googlegroups.com



For more options, visit this group at



http://groups.google.com/group/clojure?hl=en


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

Re: Ordering of messages to agents

2010-07-07 Thread Ryan Waters
On Wed, Jul 7, 2010 at 3:46 PM, Brian Hurt  wrote:
> I'm wondering if the following pattern is safe or not.  I'm in a
> transaction, and I want to create an agent and then send it an initializing
> message (the message function isn't transaction-safe, so I don't want to run
> it in the transaction).  So I want to do something like:
>
> (def my-ref (ref nil))
>
> (defn example [ f ]
>     (dosync
>     (if (nil? @my-ref)
>     (let [ a (agent nil) ]
>     (ref-set my-ref a)
>     (send a init-function)
>     (send a f))
>     (send @my-ref f
>
> (actually, what I want to do is rather more complicated than this, but this
> demonstrates the problem).  So, my question is: is it guaranteed that
> init-function will be received by the agent before any f functions are
> received?
>
> Brian
>
> --

It's not guaranteed the init-function will complete before f.

At the end of the Concurrency (Chapter 6) of Programming Clojure,
Stuart Halloway outlines a rationale and a way to create functions
that only run once.  Related code can be found here - see 'runonce':

http://github.com/stuarthalloway/lancet/blob/master/lancet.clj

I hope that helps with what you're trying to do!

Ryan

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

2010-07-07 Thread Meikel Brandmeyer
Hi,

Am 07.07.2010 um 23:11 schrieb Ryan Waters:

>> (send a init-function)
>> (send a f))
> 
> It's not guaranteed the init-function will complete before f.

I doubt that. Since only one action can be active at a time and the ordering is 
preserved, init-function will be complete before f by definition: f is not 
started until init-function is complete. (And btw: no other g can happen 
between init-function and f, because the agent is not yet known to the outside 
world)

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: Make a loop in a loop

2010-07-07 Thread Dave M
On Jul 7, 5:06 pm, Isak Hansen  wrote:
> On Wed, Jul 7, 2010 at 5:00 PM, Lars Nilsson  wrote:
>
> > Maybe
>
> > (doseq [year (range 1999 2010 1)]
> >  (doseq [month (range 1 53 1)]
> >    (print-data year range)))
>
> You could also do this with dotimes instead of doseq. Doesn't matter
> for Ns this small, but creating a range just so you have something to
> iterate across is a bit wasteful.

That's the beauty of lazy sequences, and range produces a lazy
sequence:

  http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/range

At any point in time, only a single value from each range exists; the
other values in the range are either garbage or don't exist (have not
been computed) yet.

I think this use of range is considered idiomatic Clojure.

-Dave

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

2010-07-07 Thread Mike Meyer

"Meikel Brandmeyer"  wrote:

>Hi,
>
>Am 07.07.2010 um 21:41 schrieb Mike Meyer:
>
>> Why bother renaming it when you move?
>
>Why come into a situation where bothering is a question?

You would have to ask the people at sun.com who created the convention that one.

>PS: You K-9 Mail sends every message twice.

Certainly, if an address you read is on the recipient list twice.
-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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


Re: auto-indent in Counterclockwise

2010-07-07 Thread Steven E. Harris
Laurent PETIT  writes:

> But to make it really clear: move-past-close-and-reindent is exactly
> what counterclockwise's is doing in "Strict" edition mode (not totally
> true concerning the reindentation, currently in ccw it is only
> reorganizing closing brackets by removing extra spaces, not
> reindenting lines).

I see. That's good to hear.

It's hard to know when you've really met the Emacs capability
there. That function does so many things right that I can't bear editing
Lisp code without it. That it's hard to adapt it to work with symmetric
brackets (for Clojure's '[' and ']') is disappointing, and I have found
the paredit package to be not much better on that front (having
difficulty with balancing '{' and '}'). It has its own set of oddities.

-- 
Steven E. Harris

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

2010-07-07 Thread Marc Spitzer
 DARPA might be a better bet, they fund potentially useful things

I have nothing to do with them though.

Marc

On 7/7/10, David Blubaugh  wrote:
> To All,
>
>
> I am extremely interested in LISP and Clojure.  I was wondering if it
> would be possible to obtain NSF grant funding for further development
> of Clojure ??
>
> thanks,
>
> David Blubaugh
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
Sent from my mobile device

Freedom is nothing but a chance to be better.
--Albert Camus

 The problem with socialism is that eventually you run out
of other people's money.
--Margaret Thatcher

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

2010-07-07 Thread David Nolen
On Wed, Jul 7, 2010 at 2:10 PM, James Reeves wrote:

> The main advantage of a non-blocking server is that you're don't use
> up a thread waiting for an event (such as the user sending data, or
> some other external trigger).
>
> - James


I think the main advantage of a non-blocking server is throughput, or at
least that's what I'm seeing. I haven't been able to get Jetty to serve
faster than 100 rq/s, while aleph (via Netty) is easily getting 600-700 rq/s
even if I'm writing to a database (CouchDB).

I don't really care if threads do or don't get eaten up. In fact, in the
"Hello world" microbenchmark Node.js gets trounced by aleph because aleph
can take advantage of all cores.

I also note that using future gives me more throughput if I'm using
(Thread/sleep 1).

In summary the raw request throughput of Netty NIO + the sanity of Clojure's
concurrency primitives (atom, agent, ref, future, promise) might just be a
real sweet spot.

David

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

2010-07-07 Thread Pedro Teixeira

What's the idiomatic way to handle cases where one has a macro rather
than a function?

For example:

intent is as follows but does not work:
(def args [false true false])
(apply or args)


alternatives?

a> (eval `(or @~args))

b> (reduce #(or %1 %2) args)


any recommended?


thanks,
Pedro

On Jul 7, 4:47 pm, Laurent PETIT  wrote:
> 2010/7/7 Cameron :
>
> > Thanks everyone! I certainly have my solution; but, I'm still a bit
> > confused. Here's another example...
>
> > user=> (defmacro foo [coll] `(map identity ~coll))
> > #'user/foo
> > user=> (foo (list 1 2 3))
> > (1 2 3)
>
> > In this example, I pass an explicit list and all I have to do is
> > unquote 'coll'. How is passing an explicit list any different than
> > having it destructured via '&' in the argument vector?
>
> You're not passing a list. You're passing the code for creating a list.
> Use macroexpand, it's your friend

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

2010-07-07 Thread j-g-faustus
On Jul 7, 7:55 pm, James Reeves  wrote:
> For the purposes of this discussion, let us assume that "foo" is a
> suitably unique library name, and it is highly unlikely there exist
> any other libraries with the same name.

It sounds like Clojure doesn't have an idiom for namespace names yet,
so I guess we are free to make our own conventions.

The Sun/Java notation has the advantage that it scales. Any short one-
element name convention will eventually clash, since there are only
that many TLAs available.

For CCW, a quick Google search tells me that it is an acronym for
* Complete Custom Wheels
* Countryside Council for Wales
* Carlisle Coating and Waterproofing
* Coastal Championship Wrestling
* etc. etc. etc.

I suppose most of those organizations do not ship Clojure code, at
least not yet :), but if Clojure grows to see widespread use name
clashes are inevitable.
The Sun/Java convention is made to scale to the point where everyone
in the world can release their own modules without interfering with
each other.

The disadvantage is of course that you end up with names like
org.apache.http.client.params.ClientPNames/
CONNECTION_MANAGER_FACTORY_CLASS_NAME
which gets old really quick if you have to type it a lot :)

I would like to see a middle ground - somewhat less verbose than Java
but still long enough to scale to orders of magnitude more libraries
than today. Although aliases go a long way towards making long names
less of an issue.

So perhaps something like
(com|net|org|edu).(author).(project)
where 'com' means 'commercial' (for sale), 'org' is open source, 'edu'
related to education and 'net' a general-purpose catch-all for
remaining cases.

This would make it
- org.weavejester.foo
and we can leave out github as a hosting detail. (As pointed out
earlier, the project could move to bitbucket next week.)

What I don't like about the leading com/net/... is that we are wasting
an entire namespace element and several characters to distinguish four
cases, that's just two bits of information...

A better alternative might be
(where).(who).(what)
- github.weavejester.foo
although tying the namespace up to a hosting provider doesn't seem
ideal either.

So perhaps just
(who).(what)
- weavejester.foo
which would get my vote today. If "who" and "what" are both suitably
unique today, the combination is unique squared and should be good for
a couple of orders of magnitude more growth.
It is also the convention used by the Clojure core, as in clojure.set,
clojure.xml etc.

My proposal would be
- for private use: Doesn't matter, "foo" is fine.
- for shared libraries with a short- to mid-term life expectancy:
Minimum two-element namespace (who).(what)
- for larger, long-term libraries, when you hope it will be an
industry standard in ten years: Three-element namespace, perhaps
(where).(who).(what).

IMHO, YMMV etc.
I'm new to Clojure and can hardly claim to be qualified to appoint the
idiomatic Clojure way, but I think something along these lines gives
the best of both worlds - minimizing namespace clashes as well as
maximizing readability and reducing typing.

jf


On Jul 7, 7:55 pm, James Reeves  wrote:
> On 7 July 2010 17:24, Laurent PETIT  wrote:
>
> > Of course, if your library has an especially cryptic name (as we have
> > with counterclockwise: ccw), then having also directly foo may also
> > not interfere with other's namespaces. That's the path we took for
> > counterclockwise, and our top-level namespace/package is just 'ccw'
>
> For the purposes of this discussion, let us assume that "foo" is a
> suitably unique library name, and it is highly unlikely there exist
> any other libraries with the same name.
>
> - 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: ANN: Aleph, an asynchronous web server

2010-07-07 Thread Greg
"well I think the main advantage" is memory. :-)

Theoretically (I think), thread-per-connection servers can be very close to 
matching asynchronous servers in throughput, but they definitely require much 
more RAM to do so. RAM is one of the more expensive commodities to come by on 
VPS and cloud servers.

Of course, I'm being facetious, I think we can agree that there are lots of 
advantages to evented servers, and it's awesome they're getting better support 
in Clojure!

- Greg

On Jul 7, 2010, at 10:04 PM, David Nolen wrote:

> On Wed, Jul 7, 2010 at 2:10 PM, James Reeves  wrote:
> The main advantage of a non-blocking server is that you're don't use
> up a thread waiting for an event (such as the user sending data, or
> some other external trigger).
> 
> - James
> 
> I think the main advantage of a non-blocking server is throughput, or at 
> least that's what I'm seeing. I haven't been able to get Jetty to serve 
> faster than 100 rq/s, while aleph (via Netty) is easily getting 600-700 rq/s 
> even if I'm writing to a database (CouchDB).
> 
> I don't really care if threads do or don't get eaten up. In fact, in the 
> "Hello world" microbenchmark Node.js gets trounced by aleph because aleph can 
> take advantage of all cores.
> 
> I also note that using future gives me more throughput if I'm using 
> (Thread/sleep 1).
> 
> In summary the raw request throughput of Netty NIO + the sanity of Clojure's 
> concurrency primitives (atom, agent, ref, future, promise) might just be a 
> real sweet spot.
> 
> David
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from 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: Ordering of messages to agents

2010-07-07 Thread Ryan Waters
On Wed, Jul 7, 2010 at 4:32 PM, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 07.07.2010 um 23:11 schrieb Ryan Waters:
>
>>>                 (send a init-function)
>>>                 (send a f))
>>
>> It's not guaranteed the init-function will complete before f.
>
> I doubt that. Since only one action can be active at a time and the ordering 
> is preserved, init-function will be complete before f by definition: f is not 
> started until init-function is complete. (And btw: no other g can happen 
> between init-function and f, because the agent is not yet known to the 
> outside world)
>
> Sincerely
> Meikel
>

My apologies - I read the code wrong and should explain more of what I
see.  When the if is true, the ordering of init-function and f is
guaranteed so init-function will complete before f.  However, on any
subsequent calls to example, there are no language guarantees that
keep the if from evaluating to false, calling (send @my-ref f), but
only after the previous call to (send a init-function).

Stated another way, it's technically possible the agent calls won't
complete before a subsequent call to example.

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

2010-07-07 Thread Mike Meyer
On Wed, 7 Jul 2010 18:53:39 -0700 (PDT)
j-g-faustus  wrote:

> On Jul 7, 7:55 pm, James Reeves  wrote:
> > For the purposes of this discussion, let us assume that "foo" is a
> > suitably unique library name, and it is highly unlikely there exist
> > any other libraries with the same name.
> 
> It sounds like Clojure doesn't have an idiom for namespace names yet,
> so I guess we are free to make our own conventions.

You're overlooking that one of the major benefits of Clojure is that
it interoperates with other JVM languages. So any idiom it uses needs
to have some assurance that it won't clash with an idiom used by thsoe
other languages. Ditto for the CLR. The very first thing I did with
clojure was grabbed a Java library - and all the things it depended on
- and wrote some test code to play with it.

> The Sun/Java notation has the advantage that it scales. Any short one-
> element name convention will eventually clash, since there are only
> that many TLAs available.

That the Oracle/Sun/java way scales is a good reason to do it their
way. Except that I notice that Sun doesn't do that: the libraries I've
got from them are javax.comm, *not* com.sun.javax.comm (being renamed
to com.oracle.sun.javax.comm, I suppose).

> For CCW, a quick Google search tells me that it is an acronym for
> * Complete Custom Wheels
> * Countryside Council for Wales
> * Carlisle Coating and Waterproofing
> * Coastal Championship Wrestling
> * etc. etc. etc.

If I ever add AJAX widgets to bitchen' it's going to be the "Cool
Clojure Widgets" library. Just 'cause.

> I suppose most of those organizations do not ship Clojure code, at
> least not yet :), but if Clojure grows to see widespread use name
> clashes are inevitable.

It will happen long before that for clojure users if they incorporate
non-clojure libraries.

> The Sun/Java convention is made to scale to the point where everyone
> in the world can release their own modules without interfering with
> each other.

Just so long as everyone follows that convention. As far as I know,
Sun didn't do anything to enforce that, or even to prevent people from
shipping code in namespaces in a domain name they don't own.

> The disadvantage is of course that you end up with names like
> org.apache.http.client.params.ClientPNames/
> CONNECTION_MANAGER_FACTORY_CLASS_NAME
> which gets old really quick if you have to type it a lot :)
> 
> I would like to see a middle ground - somewhat less verbose than Java
> but still long enough to scale to orders of magnitude more libraries
> than today. Although aliases go a long way towards making long names
> less of an issue.
> 
> So perhaps something like
> (com|net|org|edu).(author).(project)
> where 'com' means 'commercial' (for sale), 'org' is open source, 'edu'
> related to education and 'net' a general-purpose catch-all for
> remaining cases.

By picking the DNS TLD's, you're *asking* for collisions with the DNS
namespace. Unless you want to use XXX, of course.

The first component needs to be something that is 1) isn't likely to
collide with a DNS namespace, and 2) isn't likely to be used by any
other language.

Given that Sun is using javax, something like
"clojure.(author).(project)" would seem to be appropriate. That should
be safe from the DNS namespace (unless it means something when
transliterated into a foreign language) nor is a project in a language
other than clojure likely to use it.

Of course, if you google for "Mike Meyer", you'll find (on the first
page I get from google) a photographer, an artist, a statistician, an
online educator, an astrophysicist (I seem to be an intellectual
bunch), a sports commentator, and a Canadian comedian who doesn't
spell his last name right. At least the mass murderer has fallen out
of the rankings.  In the past, I've gotten party invitations meant for
another Mike Meyer, been handed the wrong paycheck, been asked how my
kids were (long before I had any myself), and once even collaborated
with myself on extending the emacs MH-E package.

So maybe that's not so good. Especially if your name is "Muhammad",
"Chen", or "Smith".

> This would make it
> - org.weavejester.foo
> and we can leave out github as a hosting detail. (As pointed out
> earlier, the project could move to bitbucket next week.)
> 
> What I don't like about the leading com/net/... is that we are wasting
> an entire namespace element and several characters to distinguish four
> cases, that's just two bits of information...

As above, that namespace needs to be used to distinguish clojure from
everything else that runs on the JVM.

> A better alternative might be
> (where).(who).(what)
> - github.weavejester.foo
> although tying the namespace up to a hosting provider doesn't seem
> ideal either.

Actually, the WWW consortium found out the hard way that using URL as
namespaces for schema was a *bad* idea. They weren't supposed to
actually be used to find the schema, but the www made them available
that way, and people wrote code to use

defrecord + defprotocol brittleness (also about docstring handling)

2010-07-07 Thread Michał Marczyk
Just noticed that defprotocol -- or rather, emit-protocol -- simply
assumes that method signatures are well-formed. This leads to the
following behaviour:

;; this compiles fine
(defprotocol PTestProt
  (p-test-method "foo" [this]))

;; this does not -- no matching method found
(defrecord RTestRec []
  PTestProt
  (p-test-method [this] :foo))

What happens (AFAICT) is that emit-protocol, upon seeing the "foo"
string in the signature for p-test-method, assumes that it's done with
that signature (because the docstring comes last, right?) and never
notices there's anything more to process; nor does it complain about
the signature being malformed. This is doubly weird if you consider
that p-test-method ends up being without a valid signature, yet it has
a docstring which (doc p-test-method) can display.

While I'm at it, I have to say that I'm wondering if having the
(optional) docstring come first, before the arglists, wouldn't be more
consistent with the way defn handles docstrings.

Sincerely,
Michał

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


Re: navigate and edit tree nodes / branches

2010-07-07 Thread Michał Marczyk
(inc clojure.zip); clojure.contrib.zip-filter is a nice companion.

Also, clojure.walk might be worth investigating. It provides no
complex navigational facilities, so only some types of tree
transformations are "walkable", but for dealing with those, it's an
absolutely fantastic tool.

Sincerely,
Michał

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


Re: Idiomatic Clojure namespace names

2010-07-07 Thread Michael Gardner
On Jul 7, 2010, at 8:53 PM, j-g-faustus wrote:

> The disadvantage is of course that you end up with names like
> org.apache.http.client.params.ClientPNames/
> CONNECTION_MANAGER_FACTORY_CLASS_NAME
> which gets old really quick if you have to type it a lot :)

Why would you ever type that more than once? Just use :as.

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

2010-07-07 Thread Daniel Gagnon
>
>
> Why would you ever type that more than once? Just use :as.
>
>
Because you use it in more than one file / project.

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

2010-07-07 Thread Heinz N. Gies

On Jul 7, 2010, at 21:05 , John Cromartie wrote:

> I've whipped up a proof-of-concept of how to implement built-in
> examples for functions and macros. The general idea is to add an
> attribute to the var that contains a list of docstrings and arg lists
> or code that illustrate common usage.
> 
> Let me know what you think: http://gist.github.com/466743
> 
> It could also be useful for generating documentation.


http://getclojure.org:8080/examples/concat is a nice way to get usage examples 
for a function :) they are actually real life and extracted from the #clojure 
channel logs.

Regards,
Heinz

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

2010-07-07 Thread Laurent PETIT
2010/7/8 Steven E. Harris 

> Laurent PETIT  writes:
>
> > But to make it really clear: move-past-close-and-reindent is exactly
> > what counterclockwise's is doing in "Strict" edition mode (not totally
> > true concerning the reindentation, currently in ccw it is only
> > reorganizing closing brackets by removing extra spaces, not
> > reindenting lines).
>
> I see. That's good to hear.
>
> It's hard to know when you've really met the Emacs capability
> there. That function does so many things right that I can't bear editing
> Lisp code without it. That it's hard to adapt it to work with symmetric
> brackets (for Clojure's '[' and ']') is disappointing, and I have found
> the paredit package to be not much better on that front (having
> difficulty with balancing '{' and '}'). It has its own set of oddities.
>
>
When you say "that it's hard ... '[' and ']' ...", you're talking about the
original paredit.el in emacs ? Or you saw a deficiency in counterclockwise ?
'cause in ccw this works equally well for ], } and )  ( it even allows you
to jump out of a ] even if the cursor is deep inside nested (({{(

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

2010-07-07 Thread Laurent PETIT
2010/7/8 Pedro Teixeira 

>
> What's the idiomatic way to handle cases where one has a macro rather
> than a function?
>
> For example:
>
> intent is as follows but does not work:
> (def args [false true false])
> (apply or args)
>
>
> alternatives?
>
> a> (eval `(or @~args))
>

big no-no.

>
> b> (reduce #(or %1 %2) args)
>
> that's it.


>
> any recommended?
>
>
> thanks,
> Pedro
>
> On Jul 7, 4:47 pm, Laurent PETIT  wrote:
> > 2010/7/7 Cameron :
> >
> > > Thanks everyone! I certainly have my solution; but, I'm still a bit
> > > confused. Here's another example...
> >
> > > user=> (defmacro foo [coll] `(map identity ~coll))
> > > #'user/foo
> > > user=> (foo (list 1 2 3))
> > > (1 2 3)
> >
> > > In this example, I pass an explicit list and all I have to do is
> > > unquote 'coll'. How is passing an explicit list any different than
> > > having it destructured via '&' in the argument vector?
> >
> > You're not passing a list. You're passing the code for creating a list.
> > Use macroexpand, it's your friend
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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: auto-indent in Counterclockwise

2010-07-07 Thread Lee Spector

I spent a bunch of time today in CCW 0.0.59.RC2, in "default" mode, and thought 
I'd report my experience:

- Lots of very nice features and I really appreciate having this -- please 
don't take my criticisms below in the wrong way!

- There are some cases in which the indentation doesn't follow the rules that 
I'd expect, e.g. from emacs and other lisp editors. For example, if you 
auto-indent this:

(def a1 '((2 1 2)
   (1 0 0)
   (0 0 1)))

then I think the "(1" should align under the "(2" but it doesn't. Other 
problematic cases include indentation after a line like "(list foo", which I 
think should align under the "f", and indentation under "(cond x y" which I 
think should align under the "x".

- The automatic insertion of closing brackets has been driving me crazy, 
although I realize that others will differ on this. I type the closing brackets 
without thinking and then I have lots of extra closes, indentation breaks 
(because it currently only works when everything is matched), etc. I also tend 
to type sloppily with a lot of backspaces to clean up as I go, and if I try to 
do this after typing an opening bracket or even a quotation mark (") my 
backspace only erases one character, leaving the other. So a lot of my typing 
produces a mess that I don't immediately notice and then have to go back and 
clean up. In addition, I often want to wrap an existing form with another call 
and while I know CCW provides structure-oriented ways to do this I often just 
want to type "(wrapper " before it and ")" after -- but then I end up with an 
extra ")" in the before part that has to be deleted in a somewhat awkward 
way... Again, I know CCW supports a whole different and perhaps better way to 
do this stuff once one commits to it and internalizes it, but as somebody who 
has been typing in a more free-form way for many years I'm really finding this 
cumbersome. On a couple of occasions I found myself typing code into a plain 
text editor to avoid these issues and then pasting it into eclipse... surely a 
bad sign.

- Symbol completion: It took me a while and some digging to figure out that 
this is invoked with control-. (on a mac, anyway), and that one hits that 
multiple times to cycle through the matches. Did I miss that being mentioned in 
introductory materials, or is this another place where Eclipse experience is 
assumed? (I see the text at 
http://code.google.com/p/counterclockwise/wiki/Documentation#Code_completion 
but this doesn't actually tell you how to invoke it.) If not then it should 
probably be added. BTW, is there a way to get a popup menu of the options, or 
some other listing of them without going through them one by one?

- Arglist-on-space: This is something I've mentioned in other threads, with 
respect to other editors, but I really found myself longing for it today as I 
worked in Eclipse and it seemed like it might be possible given the other 
infrastructure that is there. The idea is that when you type something like 
"(nth " a mini-buffer somewhere shows the argument list(s) like "([coll index] 
[coll index not-found])". In the feature as it existed in MCL (among other 
systems, I think) you didn't have to hit any other keys or do anything else -- 
as soon as you hit a space after the function name the arglist would appear in 
another buffer, and a quick glance jogged the memory about the arguments and 
their order. It may be that Clojure's flexibility with argument lists makes 
this unusually difficult to do correctly all of the time, but I'd find it 
really useful even if it didn't perform flawlessly. I currently find (as a new 
user, still) that I keep having to go to the repl to type things like "(doc 
nth)" to remember the order of arguments. While "doc" is great this does 
require me to switch to the repl and type/eval a form, and it's really nice to 
avoid that by having arglists appear automatically all of the time.

Again, I offer these as what I hope are constructive suggestions...

Thanks, -Lee

--
Lee Spector, Professor of Computer Science
School of Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspec...@hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438

Check out Genetic Programming and Evolvable Machines:
http://www.springer.com/10710 - http://gpemjournal.blogspot.com/

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