Re: Clojure's syntax design: macros vs functions

2009-03-05 Thread Mike Benfield
FWIW: I have thought the same thing in the past. But, in practice, this has never been a problem for me. Not once. Now I haven't written quadrillions of lines of Lisp, but it doesn't seem to have been a problem for those who have either. One thing to keep in mind is that you don't typically have

Re: IntelliJ Clojure Plugin - Minor Indentation Issues.

2009-03-05 Thread Laurent PETIT
Hello, 2009/3/6 Ilya Sergey > > Hello. > > Look at last plugin version. I've changed rules for indentation and > alignment in Clojure files. Now all forms inside function call are > aligned by its _second_ elemnt, i. e. first argument as in the > following example: > > (defn select-keys > "Retu

Re: Chrono date library

2009-03-05 Thread Phil Hagelberg
Allen Rohner writes: > http://www.ociweb.com/jnb/jnbJul2008.html "As mentioned, one of the > problems with the JDK API is difficulty in calculating the number of > days between two different dates. To learn a bit about how to use Joda > Time, let's see how one can solve that problem a few diff

Comparing lists

2009-03-05 Thread Mark Engelberg
I know that this has been brought up several times here, but I don't recall whether there was ever any resolution: It seems reasonable to expect (compare '(1 2 3) '(4 5)) to do a lexicographic comparison of the two lists, just like (compare [1 2 3] [4 5]) does. Is there an intentional reason why

Re: Chrono date library

2009-03-05 Thread Allen Rohner
On Mar 5, 6:10 pm, Phil Hagelberg wrote: > Allen Rohner writes: > > I strongly recommend that you make sure you understand where and why > > Joda differs from the Java standard lib. If you don't handle the cases > > that Joda already does, you *will* have bugs. > > Interesting. So far everyone

Re: Clojure + Terracotta: We Have REPL!

2009-03-05 Thread Mark H.
On Mar 5, 12:23 pm, Paul Stadig wrote: > I had one last, major hurdle, and was helped by Chouser (thank you!). > > http://paul.stadig.name/2009/03/clojure-terracotta-we-have-repl.html > > Still lots more to do, and probably some simple changes that could be > rolled back into the Clojure codebase

Re: fitness

2009-03-05 Thread Dan
On Thu, Mar 5, 2009 at 8:53 PM, Jason Wolfe wrote: > >> The mutation constructing function seems obvious in hindsight. I feel >> stupid now. > > You shouldn't :).  Immutability definitely takes some getting used to; > I know it's taking me quite some time to wrap my head around it. I'm actually

Re: Chrono date library

2009-03-05 Thread Jeffrey Straszheim
I took a brief glance at Joda. It appears they already use immutable objects to a large degree. It looks like *exactly* the sort of library we can just use out of the box, unwrapped. On Thu, Mar 5, 2009 at 6:49 PM, Phil Hagelberg wrote: > > Cosmin Stejerean writes: > > > I like the API so far

Re: fitness

2009-03-05 Thread Jason Wolfe
> The mutation constructing function seems obvious in hindsight. I feel > stupid now. You shouldn't :). Immutability definitely takes some getting used to; I know it's taking me quite some time to wrap my head around it. -Jason --~--~-~--~~~---~--~~ You receiv

Re: fitness

2009-03-05 Thread Dan
On Thu, Mar 5, 2009 at 8:11 PM, Matt Moriarity wrote: > > what about memoizing the fitness function? call fitness on your > structs, and if it's memoized, it will return the cached value as long > as the struct is the same value. if it's changed, then it will > recompute. somebody correct me if t

Re: Clojure's syntax design: macros vs functions

2009-03-05 Thread Elena
(Warning: long post) Thank you all for the answers, especially to Konrad who suggested thinking in terms of forms instead of functions and macros. He's right that I'm a newcomer and maybe I've rushed a bit by calling it a flaw. I'll try thinking about it more. As I started to learn Lisp, the syn

Re: fitness

2009-03-05 Thread Jason Wolfe
Without seeing your code, it's hard to say exactly what's best. I assume when you say "mutating function", you mean "function that returns a fresh map representing a new individual". One option is to make all of your "mutations" go through a single utility function, which will make the chang

Re: fitness

2009-03-05 Thread Matt Moriarity
what about memoizing the fitness function? call fitness on your structs, and if it's memoized, it will return the cached value as long as the struct is the same value. if it's changed, then it will recompute. somebody correct me if this doesn't account for something, but it sounds like the right a

Re: IntelliJ Clojure Plugin - Minor Indentation Issues.

2009-03-05 Thread Ilya Sergey
Hello. Look at last plugin version. I've changed rules for indentation and alignment in Clojure files. Now all forms inside function call are aligned by its _second_ elemnt, i. e. first argument as in the following example: (defn select-keys "Returns a map containing only those entries in map

Re: fitness

2009-03-05 Thread Dan
Thanks for the advice, I never noticed delay existed! It turns out I cannot put the fitness directly into the struct that contains individuals. It would mean that every mutating function would need to "reset" the fitness computation to avoid propagating a misleading fitness and that's clearly not

Re: Chrono date library

2009-03-05 Thread Phil Hagelberg
Allen Rohner writes: > I strongly recommend that you make sure you understand where and why > Joda differs from the Java standard lib. If you don't handle the cases > that Joda already does, you *will* have bugs. Interesting. So far everyone I've talked to who recommended Joda did so because th

clojuredev switch to lazy-seq version of clojure

2009-03-05 Thread Laurent PETIT
(sorry for posting this on the main clojure ml, but it seems that some if not a lot of clojuredev users have not subscribed to the more focused clojuredev-user ml) Hello clojuredev users, Would you mind if, in the next days, I switch clojuredev's internal code to work with a lazyseq enabled (e.g.

Re: Chrono date library

2009-03-05 Thread Allen Rohner
On Mar 5, 5:49 pm, Phil Hagelberg wrote: > Cosmin Stejerean writes: > > I like the API so far, although I'll probably have to wait for > > timezone support before I can start using this. > > Would love some suggestions on what you'd expect the API to look like > for this. Failing test cases wo

Re: Chrono date library

2009-03-05 Thread Phil Hagelberg
Cosmin Stejerean writes: > I like the API so far, although I'll probably have to wait for > timezone support before I can start using this. Would love some suggestions on what you'd expect the API to look like for this. Failing test cases would be even better. I haven't given it much thought ye

Re: Clojure's syntax design: macros vs functions

2009-03-05 Thread Elena
On 5 Mar, 02:22, Matt Revelle wrote: > Was their a situation where not knowing if a form was a macro bit > you? Considering that many frequently used built-ins > are implemented as macros, capitalizing or otherwise annotating-in- > name would be annoying. No. What bothers me is not being able

Re: Chrono date library

2009-03-05 Thread Cosmin Stejerean
On Thu, Mar 5, 2009 at 5:08 PM, Phil Hagelberg wrote: > > The code is available in either mine or Phil's github forks of clojure- > > contrib: > > > > http://github.com/cooldude127/clojure-contrib/ > > http://github.com/technomancy/clojure-contrib/ > > > > We'd like to hear opinions and whether p

Re: Chrono date library

2009-03-05 Thread Phil Hagelberg
> The code is available in either mine or Phil's github forks of clojure- > contrib: > > http://github.com/cooldude127/clojure-contrib/ > http://github.com/technomancy/clojure-contrib/ > > We'd like to hear opinions and whether people are willing to admit > this into clojure-contrib. Phil has alrea

Chrono date library

2009-03-05 Thread Matt Moriarity
This was posted about a little while ago, but a great deal more has happened. Basically, Phil Hagelberg and I have been working on a nice little date library for Clojure that doesn't rely on anything but the Java date APIs. Last time I posted about this, a few people brought up Joda time, which we

First Clojure Application, Light Text Editor in Clojure/SWT

2009-03-05 Thread BerlinBrown
http://code.google.com/p/lighttexteditor/ * Simple text editor. * Simple File Manager for accessing important files quickly. * Search tools using Linux or Win32 applications (unxutils). * Built on Java 1.5 and the Clojure programming language. It is a simple text editor and one critical feature

Re: :use feature requests

2009-03-05 Thread Laurent PETIT
2009/3/5 Jonathan Tran > > On Mar 5, 9:24 am, Chouser wrote: > > > So the least-breaking change proposed here would be simply that if > > :use is given an :as parameter, that it no longer also refer all the > > other symbols directly. > > > > Rich seemed to want to reduce the breakage here as mu

Re: Clojure + Terracotta: We Have REPL!

2009-03-05 Thread Nabib El-Rahman
awesome Paul :) On Thu, Mar 5, 2009 at 12:23 PM, Paul Stadig wrote: > > I had one last, major hurdle, and was helped by Chouser (thank you!). > > http://paul.stadig.name/2009/03/clojure-terracotta-we-have-repl.html > > Still lots more to do, and probably some simple changes that could be > rolle

Clojure + Terracotta: We Have REPL!

2009-03-05 Thread Paul Stadig
I had one last, major hurdle, and was helped by Chouser (thank you!). http://paul.stadig.name/2009/03/clojure-terracotta-we-have-repl.html Still lots more to do, and probably some simple changes that could be rolled back into the Clojure codebase. However, I feel as though I've finally reached t

Re: :use feature requests

2009-03-05 Thread Stuart Sierra
On Mar 5, 10:50 am, Jonathan Tran wrote: > No!!!  Please, not _another_ namespace function.  I find all the > namespace stuff in Clojure to be overly complicated already.  To > newcomers, it must be utterly confusing... with ns, use, import, > require, refer, and then all the ns-* and *-ns stuff.

Re: Questions about nested associative structures

2009-03-05 Thread Stuart Sierra
On Mar 5, 3:28 am, Mark Engelberg wrote: > 3. What would you predict to be the most efficient way to implement a > (non-destructive) double-dimensioned array?: >     a) A vector of vectors. >     b) A hash map that correlates [i j] pairs with values. >     c) A flat vector, and write lookup and a

Re: Monad tutorial, part 1

2009-03-05 Thread jim
Interesting take on explaining monads. I hadn't articulated the link between 'let' and 'domonad' . Looking forward to part 2. On Mar 5, 12:21 pm, Konrad Hinsen wrote: > For those who are interested in monads but don't want to learn   > Haskell first to understand the Haskell-based monad tutori

Re: Monad tutorial, part 1

2009-03-05 Thread jim
Konrad, I just finished a tutorial last week. It'll be interesting to compare notes. I'm waiting for my shiny new web server to get here, so I can put it on line. Jim Konrad Hinsen wrote: > For those who are interested in monads but don't want to learn > Haskell first to understand the Haskel

Re: -anchor functions

2009-03-05 Thread Mark Volkmann
On Thu, Mar 5, 2009 at 12:32 PM, Meikel Brandmeyer wrote: > Hi, > > Am 05.03.2009 um 19:15 schrieb Mark Volkmann: > >> >> Do the special-form-anchor and syntax-symbol-anchor functions have a >> use outside the doc macro? >> On cursory glance it seems that those should be private functions and >>

Re: Monad tutorial, part 1

2009-03-05 Thread Cosmin Stejerean
On Thu, Mar 5, 2009 at 12:21 PM, Konrad Hinsen wrote: > > For those who are interested in monads but don't want to learn > Haskell first to understand the Haskell-based monad tutorials, I have > started to write a Clojure monad tutorial. Part 1 is now available: > >http://onclojure.com/200

Re: -anchor functions

2009-03-05 Thread Meikel Brandmeyer
Hi, Am 05.03.2009 um 19:15 schrieb Mark Volkmann: Do the special-form-anchor and syntax-symbol-anchor functions have a use outside the doc macro? On cursory glance it seems that those should be private functions and not included in the API documentation. Currently they are used in the macro

Monad tutorial, part 1

2009-03-05 Thread Konrad Hinsen
For those who are interested in monads but don't want to learn Haskell first to understand the Haskell-based monad tutorials, I have started to write a Clojure monad tutorial. Part 1 is now available: http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure- programmers-part-1/

-anchor functions

2009-03-05 Thread Mark Volkmann
Do the special-form-anchor and syntax-symbol-anchor functions have a use outside the doc macro? On cursory glance it seems that those should be private functions and not included in the API documentation. -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--

Re: :use feature requests

2009-03-05 Thread Jonathan Tran
On Mar 5, 9:24 am, Chouser wrote: > So the least-breaking change proposed here would be simply that if > :use is given an :as parameter, that it no longer also refer all the > other symbols directly. > > Rich seemed to want to reduce the breakage here as much as possible, > and IMHO this is pret

google notebook -> delicious thanks to Clojure

2009-03-05 Thread rb
Hi, My first useful code writted in Clojure is a migration script from Google Notebook to Delicious. It's available at http://www.nsa.be/nb_exporter/ (complete package to download) and code is at http://github.com/raphinou/nb_exporter. It is code developed on the pre-lazy clojure. Here are some

Compojure File I/O

2009-03-05 Thread Sean
This is repeated from the compojure group. Hi, I'm developing an app that lets users upload files. I checked the docs and tests, and I didn't notice anything about uploading files. Is there a standard way of doing this in compojure, or do I need to interact with the java servlet directly? --~--~-

Re: :use feature requests

2009-03-05 Thread Chouser
On Thu, Mar 5, 2009 at 9:00 AM, Stephen C. Gilardi wrote: > > On Mar 5, 2009, at 8:50 AM, Chouser wrote: > >> Aren't there already no-arg options like :reload and :verbose? > > Those apply to the entire :use or :require clause. They are flags that are > peers with libspecs, not within them. Fair

Re: :use feature requests

2009-03-05 Thread Stephen C. Gilardi
On Mar 5, 2009, at 8:50 AM, Chouser wrote: Aren't there already no-arg options like :reload and :verbose? Those apply to the entire :use or :require clause. They are flags that are peers with libspecs, not within them. --Steve smime.p7s Description: S/MIME cryptographic signature

Re: :use feature requests

2009-03-05 Thread Chouser
On Thu, Mar 5, 2009 at 12:00 AM, Stephen C. Gilardi wrote: > > On Mar 4, 2009, at 11:46 PM, Chouser wrote: > >> Adding an :all option as Steve suggests would clean this up even more: >> >>  (ns util >>   (:use [really.long.namespace.util :as util :all])) > > I looked into this further after sugge

Re: Accessing ASM?

2009-03-05 Thread Robert Feldt
On Mar 5, 1:48 am, MikeM wrote: > > I meant if ASM is already coming with clojure since it is used by > > clojure when generating bytecode. Maybe I am missing something... ;) > > You can look at genclass.clj for an example of using the ASM that is > bundled with Clojure. > Ah, of course... Than

Re: Modular composition/plugin architecture

2009-03-05 Thread Adrian Cuthbertson
Thanks Itay, that's exactly what I need. On Thu, Mar 5, 2009 at 1:15 PM, Itay Maman wrote: > > Here's how plugin support is implemented in Waterfront: > > The last expression in each plugin is the "plguin init function": a > function (can be anonymous) that takes a single parameter (a map) and >

Re: Modular composition/plugin architecture

2009-03-05 Thread Itay Maman
Here's how plugin support is implemented in Waterfront: The last expression in each plugin is the "plguin init function": a function (can be anonymous) that takes a single parameter (a map) and returns new map. The load-plugin function takes a strings (specifying the path to a .clj file), and per

Re: fitness

2009-03-05 Thread Meikel Brandmeyer
Hi, Am 05.03.2009 um 10:13 schrieb bOR_: Is there a reason why delay needs a force to be calculated? delay creates a Delay object (Promise in Scheme). This can be passed around like eg. a Vector. When you want to retrieve the value, you have to use force, like get for a map. The first time th

Re: Synchronous watches

2009-03-05 Thread Anand Patil
I've managed to create weird race conditions by adding watches while actions are running. Are there guarantees about the scheduling of actions and adding/ removing watches? If I add or remove a watch on an agent while an action is running, what happens? So to summarize, my feedback that still may b

Re: Synchronous watches

2009-03-05 Thread Anand Patil
Excellent point. Yes, get-watches seems like a better option. Anand On Thu, Mar 5, 2009 at 3:33 AM, Timothy Pratley wrote: > > I forgot to mention the reason I don't feel it should be an error to > remove a non-existent watch > user=> (dissoc {:a 1 :b 2} :c) > {:a 1, :b 2} > > > > > --~--~--

Re: fitness

2009-03-05 Thread bOR_
Didn't know of the existence of delay yet. Thanks for pointing that out :). Is there a reason why delay needs a force to be calculated? > > >    {:fitness (delay (compute-my-fitness))} > > > > And when you access the value use force. > > > >    (-> my-thing :fitness force) > --~--~-~--~

Re: Clojure's syntax design: macros vs functions

2009-03-05 Thread Joshua Fox
> expressions get evaluated and which don't, at least when you are dealing with side effects. I think that this is the key point. The Clojure syntax is built around its pure-functional core. Side effects are dangerous, and the rule there is "mutator beware." Joshua --~--~-~--~~---

Re: Roman Numerals

2009-03-05 Thread David Sletten
On Mar 4, 2009, at 8:29 PM, Tom Faulhaber wrote: > > BTW, cl-format (my Common Lisp format function for Clojure), supports > the ~...@r directive for converting Arabic to Roman (but nothing to go > the other way around. I didn't spend too much time thinking about > stylistic issues when I wrote

Re: Clojure's syntax design: macros vs functions

2009-03-05 Thread Konrad Hinsen
On 05.03.2009, at 02:03, Elena wrote: > I wonder if Clojure does employ the same syntax either for macros and > functions by design or it's just a remainder of Lisp. I think that a I am sure it's by design, just as for Lisp. Remember that Lisp has been around for 50 years and has been used by

Questions about nested associative structures

2009-03-05 Thread Mark Engelberg
1. What is the most elegant way to create/initialize a nested vector, such as to represent a double-dimensioned array? 2. There's get-in for nested structures and get for flat. There's update-in for nested structures, why not plain update for flat? 3. What would you predict to be the most effici

Re: :use feature requests

2009-03-05 Thread Jason Wolfe
Thanks, Steve and Chouser! > Well, there's been two proposals. In my original less radical one, > I already addressed this requirement. For your example: > > (ns util >(:use [really.long.namespace.util :as util :exclude ()])) > That would be perfectly fine with me. I just wanted to menti