Re: Code structure/design problems

2011-07-28 Thread Oskar
On Jul 27, 5:07 pm, Benny Tsai benny.t...@gmail.com wrote:
 Hi Oskar,

 I just came across this article yesterday, which I thought you may find
 useful.  It's a 4-part series where the author discusses his experience
 implementing games in a functional style:

 http://prog21.dadgum.com/23.html

 He was using Erlang, but I think many of the same ideas apply here as well.
  Hope this helps.

Hm it seems like what he did was a bit extreme. Would you do it that
way? In Clojure you could just use atoms and all would be well, right?
My game is going to be quite a bit more complex than Pac-Man, the game-
state is going to be way more complex.

I have a hard time coming up reasons why this would be better. My
function that I wanted that checks if two characters are close enough
to each other is just a very small part of my game. And I could make
just that function fuctional and my list of benefits would be nil.
Sure, immutable data structures is great, for example, but in this
case, I don't see how making the game purely functional would make the
code better. But I could be wrong of course. It's kind of hard to
imagine. If enough people say Yes, do it! I might try 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: format and printf can't be used with BigInt

2011-07-28 Thread Tom Faulhaber
FWIW, clojure.pprint.cl-format handles this fine in 1.3:

(cl-format nil ~d 2N)
= 2

On Jul 27, 11:45 am, Andrea Tortorella elian...@gmail.com wrote:
 Hi everyone,
 I don't know where to post about bugs (if this is a bug).
 Anyway in clojure 1.3 with the new numerics:

 (format %d 2N)

 throws IllegalFormatConversionException, is it a bug? are there any
 workarounds?

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

2011-07-28 Thread Sean Corfield
On Wed, Jul 27, 2011 at 5:56 PM, Ken Wesson kwess...@gmail.com wrote:
 In Clojure 1.2:

 (type (bigint 2)) = java.math.BigInteger

 In Clojure 1.3:

 (type (bigint 2)) = clojure.lang.BigInt
 (type 2N) = clojure.lang.BigInt

 What the devil? Why was this done? Seems like wheel reinvention to me.

Chas has already pointed you at the rationale / discussion but I'm a
bit surprised you reacted as if this was news - the numeric changes in
1.3 have been discussed at great length in a number of threads here
dating back over a year (and you, yourself, were active in at least
one such discussion back in December 2010).

 And format should account for it.

I can see arguments on both sides. format is clearly documented to be
a thin wrapper around java.lang.String.format so by that measure we
shouldn't expect it to handle Clojure's BigInt. OTOH, it's reasonable
to expect BigInt to behave just like any other regular numeric type
in Clojure and therefore Clojure's own format function should treat
BigInt as valid for %d.

Might be worth opening a JIRA ticket for enhancing format, yes?
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: format and printf can't be used with BigInt

2011-07-28 Thread Sean Corfield
On Wed, Jul 27, 2011 at 11:48 PM, Tom Faulhaber tomfaulha...@gmail.com wrote:
 FWIW, clojure.pprint.cl-format handles this fine in 1.3:

 (cl-format nil ~d 2N)
 = 2

Wow, I just spent the last 30 minutes reading Common Lisp the
Language, 2nd Ed, chapter 22 which describes how powerful and
mind-bending that is...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


protocols and records -- use when?

2011-07-28 Thread Oskar
Hi!

I have not heard much about records and protocols. What is a typical
use case in idiomatic Clojure code for them? Is it a good idea, for
example, to make a Character protocol and Player and Monster
records or something in a game. It feels a bit too much like OOP for
me to be comfortable with it, but I can't immediately see why that
would be bad. I just don't know how they are supposed to be used.

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

2011-07-28 Thread OGINO Masanori
I agree with Oskar.

We can separate codes into state managers and others and move
something to the latter if we find its state is unnecessary.
After all, it is good enough--it might be not best, but good
enough--if it seems that state managers are small enough, IMO.
Of course, if there is no state without great difficulty, it is also OK.

(comment
However, probably I need to spend a bit of time diving into methods
unfamiliar to me: purely FP, logic programming, constraint
programming, etc.
I guess some problems may have been solved with them simply.
)

-- 
Name:  OGINO Masanori (荻野 雅紀)
E-mail: masanori.og...@gmail.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


passing value to functions

2011-07-28 Thread Tuba Lambanog
Hello,

I'm trying to pass a variable through a series of functions, which may
change the value of the variable. However, the next function in line
uses the original value, rather than the changed value. Here's a
pseudo-code of what I'm doing.

(defn process-1 [s]
; change value of s then return it
  s)

(def s something)
(do
  (process-1 s)  ; variable s is changed here
  (process-2 s)); process-2 uses the original value of s, not the
return value from process-1

Thanks for the help.

Perhaps a sub-forum for beginners? Kind of embarrassing to ask here
questions that are so newbie-ish.

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

2011-07-28 Thread Baishampayan Ghose
 I'm trying to pass a variable through a series of functions, which may
 change the value of the variable. However, the next function in line
 uses the original value, rather than the changed value. Here's a
 pseudo-code of what I'm doing.

 (defn process-1 [s]
 ; change value of s then return it
  s)

 (def s something)
 (do
  (process-1 s)      ; variable s is changed here
  (process-2 s))    ; process-2 uses the original value of s, not the
 return value from process-1

There is no idiomatic way to do this in Clojure. If you explain the
problem (and not your proposed solution) we might be able to find a
nice and clean way of solving the problem.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

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


Re: passing value to functions

2011-07-28 Thread OGINO Masanori
http://clojure.org/state may help you to know Clojure's value.
; AFAIK Java's string is also immutable...isn't it?

-- 
Name:  OGINO Masanori (荻野 雅紀)
E-mail: masanori.og...@gmail.com

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


Re: passing value to functions

2011-07-28 Thread Laurent PETIT
Hi,

2011/7/28 Tuba Lambanog tuba.lamba...@gmail.com

 Hello,

 I'm trying to pass a variable through a series of functions, which may
 change the value of the variable. However, the next function in line
 uses the original value, rather than the changed value. Here's a
 pseudo-code of what I'm doing.

 (defn process-1 [s]
 ; change value of s then return it
  s)

 (def s something)
 (do
  (process-1 s)  ; variable s is changed here
  (process-2 s)); process-2 uses the original value of s, not the
 return value from process-1


beware, change in the clojure world means computing a new value based on
an old one (as opposed to creating a new value almost from scratch).

So for example, when you add an element to a map :
(def m1 {:a 1})
(def m2 (assoc m1 :b 2))

you're really creating a new value.
People will sometimes say they change m1, but it's not true, it's more to
say that m2 is derived from m1 (sharing most things with m1).

So you need to pipe the return value of process-1 into process-2.

The manual way to do the pipe :
(let [s-p1 (process-1 s)
  s-p2 (process-2 s-p1)]
  s-p2)

The short way (preferred in your case) :
(- s process-1 process-2)

HTH,

-- 
Laurent


 Thanks for the help.

 Perhaps a sub-forum for beginners? Kind of embarrassing to ask here
 questions that are so newbie-ish.

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

2011-07-28 Thread Alex Osborne
Hi Oskar!

Excellent questions.  I totally agree with you that writing a simulation
in a purely functional style is not the (only) answer in Clojure.  After
all the primary goal of the language is to deal with (necessary) state
well, not to get rid of it or hide it.

Oskar oskar.kv...@gmail.com writes:

 For the monsters' AI to work, the AI needs to know the state of the
 world, i.e. the characters. My current solution is to (declare
 characters) and then have a
 (defn init-ai [characters] (def characters characters))
 function in ai.clj that I call from the main file at the start of the
 game. It works, but it doesn't feel quite right. I don't want to have
 to pass the characters as an argument all the time, that seems a
 little bit too verbose to me. It seems somehow unnecessary to have to
 just pass the same atom around to all the functions.

I agree.  How about putting the game state in another file which
everything that needs access to can refer to?

;; state.clj

(ns game.state)

(def app (atom nil))
(def characters (atom nil))


;; ai.clj

(ns game.ai
  (:require [game.state :as state]))

(defn do-some-ai-thing [...]
  (swap! state/characters ...))


;; gfx.clj

(ns game.gfx
  (:require [game.state :as state]))

(defn paint [...]
  (let [window (.getWindow @app)]
(doseq [char @state/characters]
  ...)))


;; main.clj

(ns game.main
  (:require [game.state :as state]))

(defn main []
  (reset! state/characters (make-characters))
  (reset! state/app (make-app)))


 I have a function called physical-attack (the one I mentioned above)
 that takes the id of the attacker and the id of the target. Then it
 calculates how much damage the attack is supposed to do, and updates
 the target's health in the 'characters' atom. Sure, it could return
 the amount of damage instead, that would be one step towards purity.
 But to be really pure it would have to take the actual maps as
 arguments too. It may work in this case, but it's not always so easy
 to make the functions pure. The function that calls physical-attack,
 for example, also updates the attacker (he now has to wait before he
 can attack again), and returning both of the updated characters is not
 as nice as returning one. And the update still has to happen
 somewhere, because attacking *has* a side effect (in the game), so
 maybe it's ok. It's just that now the updates are spread out all over,
 and I thought that maybe it was better to have them in a special place
 in the code, for sturcture and sanity.

;; state.clj

(def characters
  (atom {:alice {:health100
 :tiredness 0}
 :bob   {:health100
 :tiredness 0}}))

;; main.clj

(defn physical-attack [characters attacker-id victim-id]  
  (let [cost 5
damage   20]
(- characters
(update-in [victim-id   :health]- damage)
(update-in [attacker-id :tiredness] + cost

(swap! state/characters physical-attack :alice :bob)

Okay but perhaps things are getting more complex.  We have more pieces
of state in play, the current turn of the game.  This might be an
indication that we really need coordination, which would mean a switch
from atoms to refs:

;; state.clj

(def characters
  (ref {:alice (ref {:health100
 :next-turn 0})
:bob   (ref {:health100
 :next-turn 0})}))

(def current-turn (ref 0))


;; combat.clj

(defn physical-attack [attacker victim]  
  (let [delay3
damage   20]
(dosync
 (alter victim   update-in [:health] - damage)
 (alter attacker assoc :next-turn (+ (ensure current-turn)
 delay)

(physical-attack (@state/characters :alice) (@state/characters :bob))

So our physical-attack now contains a transaction (dosync) which causes
both the victom and attacker to be updated atomically.  This way is more
sustainable as the simulation becomes more complicated.  For example a
weapon's wear level might need to be updated as well, perhaps also the
room's rowdyness level, nearby civilian NPCs could panic and run away
from the fighting while Bob's allies jump to his aid and so on.

Note that nested transactions are OK.  Basically everything just commits
at the end of the outermost dosync.  So if you want your AI code
toperform an attack AND update it's own state in the same transaction
you can do something like:

;; ai.clj

(defn ai-act [ai]
  (dosync   
   (physical-attack (:character @ai) (:target @ai))
   (alter ai assoc :target (choose-a-target

I hope this gives you some ideas! :-)

Alex

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts 

Re: protocols and records -- use when?

2011-07-28 Thread abp
Have a look at this:

http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/

Now, as far as i understood, you define a protocol and the extend it
on types defined via defrecord.

That's more like Character is a protocol that defines functions for
movement, attacks and other things and then you extend this protocol
to Player, Monster etc. records and provide protocol-implementations
for each of these types.

It's less like packing all things into one class, more like
behavioural composition.
Your could also extend an AI protocol on your Monster-record. Then you
have a Monster, moving like a Character, controlled by an AI.

On 28 Jul., 10:12, Oskar oskar.kv...@gmail.com wrote:
 Hi!

 I have not heard much about records and protocols. What is a typical
 use case in idiomatic Clojure code for them? Is it a good idea, for
 example, to make a Character protocol and Player and Monster
 records or something in a game. It feels a bit too much like OOP for
 me to be comfortable with it, but I can't immediately see why that
 would be bad. I just don't know how they are supposed to be used.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Generated nodejs code from ClojureScript doesn't include some functions

2011-07-28 Thread Brenton
Anthony,

Did you try deleting the output directory where generated JavaScript
files are stored? If core lib JavaScript files exist in this directory
they will not be re-compiled.

On Jul 27, 10:59 pm, Anthony Grimes disciplera...@gmail.com wrote:
 I guess I should have added that it's not just rand that isn't being
 included. It's all of the recently added functions. Check the commit log.

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

2011-07-28 Thread Thorsten Wilms

On 07/28/2011 11:29 AM, Tuba Lambanog wrote:


I'm trying to pass a variable through a series of functions, which may
change the value of the variable. However, the next function in line
uses the original value, rather than the changed value. Here's a
pseudo-code of what I'm doing.


I think you should provide more context. Why, if that is the case at 
all, do you want to pass an argument through functions that do not work 
with it?


How many arguments does each fn in the line take (and what do they 
evaluate to)?


Is it a fixed or a variable number of functions?



Perhaps a sub-forum for beginners? Kind of embarrassing to ask here
questions that are so newbie-ish.


Really no reason to feel embarrassed and I doubt the experts here would 
like to monitor an additional space ...



--
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/

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


Re: protocols and records -- use when?

2011-07-28 Thread Alex Osborne
Oskar oskar.kv...@gmail.com writes:

 I have not heard much about records and protocols. What is a typical
 use case in idiomatic Clojure code for them? Is it a good idea, for
 example, to make a Character protocol and Player and Monster
 records or something in a game. It feels a bit too much like OOP for
 me to be comfortable with it, but I can't immediately see why that
 would be bad. I just don't know how they are supposed to be used.

The primary purpose of protocols is efficient, extensible polymorphism:
handling different data types using a uniform interface.

Rather than a composite idea like Character it is preferable to use
many fine-grained protocols that each cover a single indivisible
concept.  Depending on the mechanics in your game you might have
protocols like Damagable, Listener, Throwable, Describable, Capturable,
Clickable, Edible, Castable and Container.

(defprotocol Damagable
  (alive? [damagable])
  (damage [damagable weapon]))

(defprotocol Describable
  (describe [describable]))

(defrecord Monster [strength color]
  Damagable
(alive? [m] (pos? health)
(damage [m weapon] (update-in m [:health] - (weapon :power
  Describable
(describe [m] (str (if ( health 90) a healthy  an injured )
   (if ( strength 50) powerful  weak )
   color  monster)))

(defrecord Tree [age species]
  Describable
(describe [t] (str (when ( age 100) an ancient  a )
   species  tree)))

One of the lovely things about protocols is that they are very
extensible.  Suppose you want to write some graphics code for drawing
different game entities.  You can define a rendering protocol and extend
it to your entities all in a different file.  You don't have to clutter
up your game logic files with the ugly drawing code.

;; gfx.clj

(ns game.gfx
  (:require [game.enemies :as enemies]
[game.scenary :as scenary]))

(defprotocol Renderable
  (paint [x canvas])
  (pixel-width [x]))

(extend-protocol Renderable
  scenary/Rock
(paint [tree canvas] (blit canvas rock.png))
(pixel-width [tree] 30)
  scenary/Tree
(paint [tree canvas] (blit canvas tree.png))
(pixel-width [tree] 150)
  enemies/Monster
(paint [m canvas] (blit canvas (get icons (:activity m
(pixel-width [m] 70))

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

2011-07-28 Thread Andrea Tortorella
Thanks for your replies,

+1 for enhancing format

Maybe it could handle also rationals, converting them to doubles, but
it could be to much.

On Jul 28, 9:47 am, Sean Corfield seancorfi...@gmail.com wrote:
 On Wed, Jul 27, 2011 at 11:48 PM, Tom Faulhaber tomfaulha...@gmail.com 
 wrote:
  FWIW, clojure.pprint.cl-format handles this fine in 1.3:

  (cl-format nil ~d 2N)
  = 2

 Wow, I just spent the last 30 minutes reading Common Lisp the
 Language, 2nd Ed, chapter 22 which describes how powerful and
 mind-bending that is...
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View --http://corfield.org/
 World Singles, LLC. --http://worldsingles.com/
 Railo Technologies, Inc. --http://www.getrailo.com/

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

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


Re: Basic Data Structure Question

2011-07-28 Thread semperos
@Ken

Thanks for taking the time to walk through all of that. I had considered 
recursive approaches, but was hoping to avoid a naive approach given the 
size of the root map and all its children. The [key1 key2 key3] as id won't 
be possible in this context, but thanks for the multiple options.

@amalloy

That makes sense, thanks for the feedback.

@Alex Miller

Those two lib's, clojure.zip and clojure.walk, are excellent for dealing 
with tree-like structures, but in general they expect a knowledge of the 
structure. I need to be able to search for an arbitrary map located at an 
arbitrary depth, but that definitely has a unique identifier.


All of this has been very helpful, thank you everyone. I'll go back and play 
with things, and bug the list further if/when I make progress.

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

2011-07-28 Thread Andrea Tortorella
As I said tweaking `format` to work on rationals could be too much,
and i can restate that as it is too much.

Nevertheless, extending it to work on bigint doesn't seem to me really
an edge case, given that i could get a bigint out of any function that
uses autopromotion, so:

(printf %d (autopromoting-factorial N))

would work only for small enough inputs. That's a bit surprising, so i
keep my +1 while I learn cl-format.

Then, if cl-format, is the true formatting function for clojure, why
isn't it in core?

On Jul 28, 2:48 pm, Chas Emerick cemer...@snowtide.com wrote:
 Tweaking `format` so that it accounts for all sorts of edge cases almost 
 certainly isn't going to happen, and would be a horrible kludge in any case.

 To extend Tom's point, if you really want a format that knows about all of 
 Clojure's scalars and data structures, cl-format is what you want, and it 
 comes with the language.  If you don't want to learn about cl-format, then a 
 local wrapper around `format` that does whatever you like re: coercions to 
 standard Java numeric types would be ~3 lines.

 - Chas

 On Jul 28, 2011, at 7:52 AM, Andrea Tortorella wrote:







  Thanks for your replies,

  +1 for enhancing format

  Maybe it could handle also rationals, converting them to doubles, but
  it could be to much.

  On Jul 28, 9:47 am, Sean Corfield seancorfi...@gmail.com wrote:
  On Wed, Jul 27, 2011 at 11:48 PM, Tom Faulhaber tomfaulha...@gmail.com 
  wrote:
  FWIW, clojure.pprint.cl-format handles this fine in 1.3:

  (cl-format nil ~d 2N)
  = 2

  Wow, I just spent the last 30 minutes reading Common Lisp the
  Language, 2nd Ed, chapter 22 which describes how powerful and
  mind-bending that is...

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


Re: format and printf can't be used with BigInt

2011-07-28 Thread Stuart Halloway
 What the devil? Why was this done? Seems like wheel reinvention to me.


Understanding the motivation for such a decision requires taking the time to 
understand the limitations of what Java provides. Java provides no wheel here 
-- BigInteger's hash is broken. 

The draft docs are here: 
http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics. These should 
be made better and placed in a more prominent place before 1.3 goes final.

Stu

Stuart Halloway
Clojure/core
http://clojure.com

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

Re: Generated nodejs code from ClojureScript doesn't include some functions

2011-07-28 Thread Rich Hickey


On Jul 28, 2011, at 6:54 AM, Brenton wrote:


Anthony,

Did you try deleting the output directory where generated JavaScript
files are stored? If core lib JavaScript files exist in this directory
they will not be re-compiled.



This is an ongoing source of problems and should probably work  
differently (date/time check?)


Rich

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


Re: Basic Data Structure Question

2011-07-28 Thread Laurent PETIT
Hello,

Is the hierarchy always done with the same key ?
If so, you can use zippers.
Of course, without indexation of the position of your map, you may well end
up walking the tree in O(n) more than necessary, which could or could not
become the perf. bottleneck of your application, depending on how central
this map of map.

This could look something like this:

= (def a {:id 1 :c [{:id 2} {:id 3 :c [{:id 4}]}]})
#'user/a
= (def make-zipper (partial zip/zipper (constantly true) :c #(assoc %1 :c
(vec %2
#'user/make-zipper
= (defn rmv [a k]
 (let [z (make-zipper a)
   n-seq (take-while (complement zip/end?) (iterate zip/next z))]
   (if-let [loc (first (drop-while #(not= k (:id (zip/node %))) n-seq))]
 (when (not= a (zip/node loc))
   (zip/root (zip/remove loc)))
 a)))
#'user/rmv
= (rmv a 1)
nil
= (rmv a 4)
{:id 1, :c [{:id 2} {:id 3, :c []}]}
= (rmv a 3)
{:id 1, :c [{:id 2}]}


2011/7/28 semperos daniel.l.grego...@gmail.com

 Darn tabbing...apologies for the previous post.

 Here's my full question:

 I have a map of maps, arbitrarily nested. Every individual map has a
 key/value entry that acts as a unique identifier for that map. I need to be
 able to write a function that, given the whole map of maps and the value of
 that unique ID, can dissoc the map with that unique ID.

 I feel like I'm missing something basic. I'm aware of things like assoc-in
 and update-in for dealing with nested structures, but those require knowing
 the structure ahead of time. I need to be able to pass in a unique ID which
 could be at any level of maps within the map and dissoc it once it's
 found.

 My question: Is there a method or approach using plain Clojure maps that's
 eluding me? If not and this requires some kind of searching, is there a
 better data structure to use?

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

2011-07-28 Thread OGINO Masanori
Many thanks, abp and Alex.

Additionally I think this post (and original discussion here) is also
worth reading:
http://kotka.de/blog/2011/07/Separation_of_concerns.html
though the conclusion is not the community consensus (for now).

-- 
Name:  OGINO Masanori (荻野 雅紀)
E-mail: masanori.og...@gmail.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


ClojureScript mailing list?

2011-07-28 Thread Wolodja Wentland
Hi all,

given the recent interest in ClojureScript and the resulting influx of mails
regarding it I was wondering if a distinct mailing list for it would make
sense. What do you think?
-- 
Wolodja babi...@gmail.com

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA  36B2 8B7F 7D30 CAF1 4EFC


signature.asc
Description: Digital signature


Re: Basic Data Structure Question

2011-07-28 Thread semperos
@lpetit Thanks for that, that's a nice complete example of using zippers and 
easy to follow. O(n) time is fine at this stage of the application (due to 
smaller amounts of data and a shallow tree), but definitely won't scale over 
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

Clojurescript - Javascript constructor and namespace with the same name problem

2011-07-28 Thread Marko Kocić
Hi all,

When dealing with ClojureScript and Closure library it happens pretty often 
that Closure namespace is in the same time constructor for some object.

Take a look for this example:

(ns notepad
  (:require 
 [goog.dom :as dom]
 [goog.ui.Zippy :as Zippy]))

First, require forces me to require goog.ui.Zippy as Zippy and later in the 
code I have to use fully qualified name instead of provided one.

This works
(goog.ui.Zippy. headerElement contentElement)

This doesn't work, since Zippy is namespace declaration
(Zippy. headerElement contentElement)

I know that we can't have both namespace and function with the same name, 
but this is pretty frequent situation in Closure library, and is a bit 
awkward.
One solution would be that namespace :as symbol is specialcased so that 
without namespace prefix Zippy and Zippy. works like a regular function, and 
when in place of namespace prefix, it works as a namespace prefix. That 
would be pretty in line with Closure library itselfi.

Then we would be able to use
(require [goog.ui.Zippy :as Zippy])
(def z (Zippy. ttt sss)) ;; same as calls goog.ui.Zippy.
(Zippy/someMethod x) ;; same as goog.ui.Zippy

What would be your proposal for this?

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

Re: Code structure/design problems

2011-07-28 Thread Michael Gardner
On Jul 28, 2011, at 1:44 AM, Oskar wrote:

 I have a hard time coming up reasons why this would be better. My
 function that I wanted that checks if two characters are close enough
 to each other is just a very small part of my game. And I could make
 just that function fuctional and my list of benefits would be nil.
 Sure, immutable data structures is great, for example, but in this
 case, I don't see how making the game purely functional would make the
 code better. But I could be wrong of course. It's kind of hard to
 imagine. If enough people say Yes, do it! I might try it.

I'd say yes if only for the experience of writing a purely functional game 
(minus the I/O, of course). I wrote a Pong clone in a similar way, though I 
don't share that author's dislike for passing the whole world to each mover 
function. That lets you do neat things like:

(reduce
(fn [world mover]
(merge world (mover world dt))) 
[world
move-players
move-ball   
collide-player
collide-wall
collide-goal])

where each of the mover functions returns an updated partial world hash. One 
advantage to this approach is that you can see exactly what changes to the 
world each function is making, which is great for testing and debugging. Of 
course you can use an atom in much the same way, but to me passing a world 
argument around my program isn't a big deal.

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

2011-07-28 Thread Jack Moffitt
 Hm it seems like what he did was a bit extreme. Would you do it that
 way? In Clojure you could just use atoms and all would be well, right?
 My game is going to be quite a bit more complex than Pac-Man, the game-
 state is going to be way more complex.

His stated goal was to provide examples of non-trivial programs
written in a pure functional manner. These kinds of examples are few
and far between, and most examples people show either hand picked
simple things (like beautiful lazy sort) or compilers.  He's a game
programmer so he used a non-trivial example from a domain he's
intimately familiar with.

If you read the rest of his blog (it's very good, btw) you'll notice
he's quite the pragmatist, so I don't think his intention was to
recommend writing games this way, but rather to get examples out there
to encourage discussion of the pros and cons of pure functional
programming.

jack.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Generated nodejs code from ClojureScript doesn't include some functions

2011-07-28 Thread Brenton
 This is an ongoing source of problems and should probably work  
 differently (date/time check?)

 Rich

There is now an issue for this. CLJS-41.

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


Java 7 is out!

2011-07-28 Thread Daniel Gagnon
So, what does it means for Clojure?

Faster execution? Some new interesting stuff in the standard Java library?

And I remember there was something about forkjoin that would be good for
Clojure, what about 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: protocols and records -- use when?

2011-07-28 Thread Oskar
Thank you Alex and abp!

Your posts certainly contains valuable information. But I have
questions still. One might say that you explained how to use
protocols, but the questions I have left are: Why protocols (and
records)? What benefits do I get? Alex mentioned polymorphism; how is
this different from/related to multimethods?

Let's take the game example again. Say I have (which I do) a map of
characters in my game that contains both monsters and players.

A monster:
{:type :mob :pos [x y] :hp 30 :max-hp 30 :dmg 5 :name an orc
pawn :attacking false :last-attack 0 :attack-delay 1500 :target
nil :path nil :speed 2.5 :ai ai/attack-nearest}
A player:
{:type :player :name Bill :pos [0 0]  :hp 100 :max-hp 100 :dmg
10  :attacking false :last-attack 0 :attack-delay 1500 :target nil}

And I have a few things I want to do to them. Like attack, draw them,
take damage, die and respawn, etc. Right now all those things work
exactly the same way for both types. Partly because they are so
similar, but also because the game is not nearly done yet. For
example, I might want to draw them differently, or have them take
damage differently, or whatever. I use the type mostly to filter the
map, for example monsters can only attack players.

Is it a good idea to use protocols (and records?) for me in this
situation (now or in the future when I might want them to behave
differently)? How can I benefit from them?





On Jul 28, 1:46 pm, Alex Osborne a...@meshy.org wrote:
 Oskar oskar.kv...@gmail.com writes:
  I have not heard much about records and protocols. What is a typical
  use case in idiomatic Clojure code for them? Is it a good idea, for
  example, to make a Character protocol and Player and Monster
  records or something in a game. It feels a bit too much like OOP for
  me to be comfortable with it, but I can't immediately see why that
  would be bad. I just don't know how they are supposed to be used.

 The primary purpose of protocols is efficient, extensible polymorphism:
 handling different data types using a uniform interface.

 Rather than a composite idea like Character it is preferable to use
 many fine-grained protocols that each cover a single indivisible
 concept.  Depending on the mechanics in your game you might have
 protocols like Damagable, Listener, Throwable, Describable, Capturable,
 Clickable, Edible, Castable and Container.

     (defprotocol Damagable
       (alive? [damagable])
       (damage [damagable weapon]))

     (defprotocol Describable
       (describe [describable]))

     (defrecord Monster [strength color]
       Damagable
         (alive? [m] (pos? health)
         (damage [m weapon] (update-in m [:health] - (weapon :power
       Describable
         (describe [m] (str (if ( health 90) a healthy  an injured )
                            (if ( strength 50) powerful  weak )
                            color  monster)))

     (defrecord Tree [age species]
       Describable
         (describe [t] (str (when ( age 100) an ancient  a )
                            species  tree)))

 One of the lovely things about protocols is that they are very
 extensible.  Suppose you want to write some graphics code for drawing
 different game entities.  You can define a rendering protocol and extend
 it to your entities all in a different file.  You don't have to clutter
 up your game logic files with the ugly drawing code.

     ;; gfx.clj

     (ns game.gfx
       (:require [game.enemies :as enemies]
                 [game.scenary :as scenary]))

     (defprotocol Renderable
       (paint [x canvas])
       (pixel-width [x]))

     (extend-protocol Renderable
       scenary/Rock
         (paint [tree canvas] (blit canvas rock.png))
         (pixel-width [tree] 30)
       scenary/Tree
         (paint [tree canvas] (blit canvas tree.png))
         (pixel-width [tree] 150)
       enemies/Monster
         (paint [m canvas] (blit canvas (get icons (:activity m
         (pixel-width [m] 70))

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

2011-07-28 Thread Daniel Gagnon

 Javascript is simply painful to use functionally. The verbosity of
 anonymous functions, the lack of crucial HOFs like map/filter/reduce, the
 lack of functional data structures, the lack of macros (not strictly a
 functional feature, but especially useful with functional code)... You can
 fix these to varying degrees with libraries; but in any case the overall
 superiority of Clojure syntax and data structures must be obvious to anyone
 interested in ClojureScript, since those are the sole advantages it provides
 over Javascript.


The verbosity of anonymous function (and much more) is fixed by CoffeeScript
and Coco[1] and the lack of crucial HOFs is fixed by underscore.js

1: Coco is a CoffeeScript fork that fixes the main issues CoffeeScript have
(example: CoffeeScript's scope is broken).

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

2011-07-28 Thread Tuba Lambanog
I'm trying to write a spelling 'standardizer' for a language that has
no standardized spelling. There are about 25 spelling rules, and a few
more may be added. . The input words, streamed one at a time from a
text file, go through these rules, and may change if conditions are
met. To take English examples, wouldn't would be converted to
would, labour to labor (assuming a particular spelling
standard), criticise to criticize, prolog to prologue. My knee-
jerk reaction is to implement the rules as individual functions (what
a joy to do this in Clojure!). The functions may be called in
different orders depending on, say, the number of syllables of the
input word).

As suggested by Masanori, I read up on Clojure state -- and what a
revelation that was. I understood it enough to say I don't understand
it, because, my initial blockheaded reaction was, so how's sending
back a value different from the Clojure way, since the value sent back
is the state of the identify x at that point in time.

I will try Laurent's suggestion.

Thanks for the enlightenment!

tuba

On Jul 28, 5:03 am, Thorsten Wilms t...@freenet.de wrote:
 On 07/28/2011 11:29 AM, Tuba Lambanog wrote:

  I'm trying to pass a variable through a series of functions, which may
  change the value of the variable. However, the next function in line
  uses the original value, rather than the changed value. Here's a
  pseudo-code of what I'm doing.

 I think you should provide more context. Why, if that is the case at
 all, do you want to pass an argument through functions that do not work
 with it?

 How many arguments does each fn in the line take (and what do they
 evaluate to)?

 Is it a fixed or a variable number of functions?

  Perhaps a sub-forum for beginners? Kind of embarrassing to ask here
  questions that are so newbie-ish.

 Really no reason to feel embarrassed and I doubt the experts here would
 like to monitor an additional space ...

 --
 Thorsten Wilms

 thorwil's design for free software:http://thorwil.wordpress.com/

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


Re: Alright, fess up, who's unhappy with clojurescript?

2011-07-28 Thread Daniel Gagnon

 I like CoffeeScript. But CoffeeScript is largely syntactic sugar. Hardly
 anything in the way of new semantics. And it encourages traditional stateful
 OOP and classical inheritance.

 Underscore.js does what it can, but it's goals are largely trumped by
 CoffeeScript.

 David

 CoffeeScript and Coco are largely Javascript. I'm just saying they are a
fairer comparison than naked Javascript. Especially when we speak about how
awkward it is to write Javascript.

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

2011-07-28 Thread Tuba Lambanog
Hi, Thorsten,

Why, if that is the case at
 all, do you want to pass an argument through functions that do not work
 with it?


The determination of whether a called function will apply is left as a
responsibility of the function itself, rather than the calling
function. The motivation is that a function may be called from a
number of places. Perhaps there's a better way?

Thanks for the encouragement to ask questions here.

tuba

On Jul 28, 5:03 am, Thorsten Wilms t...@freenet.de wrote:
 On 07/28/2011 11:29 AM, Tuba Lambanog wrote:

  I'm trying to pass a variable through a series of functions, which may
  change the value of the variable. However, the next function in line
  uses the original value, rather than the changed value. Here's a
  pseudo-code of what I'm doing.

 I think you should provide more context. Why, if that is the case at
 all, do you want to pass an argument through functions that do not work
 with it?

 How many arguments does each fn in the line take (and what do they
 evaluate to)?

 Is it a fixed or a variable number of functions?

  Perhaps a sub-forum for beginners? Kind of embarrassing to ask here
  questions that are so newbie-ish.

 Really no reason to feel embarrassed and I doubt the experts here would
 like to monitor an additional space ...

 --
 Thorsten Wilms

 thorwil's design for free software:http://thorwil.wordpress.com/

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


Re: Alright, fess up, who's unhappy with clojurescript?

2011-07-28 Thread ronen
Im not a javascript guru but from my experience JQuery isn't suitable
for large web application, starting with the JQueryUi immaturity and
the plethora of plugins that sometime work and sometime don't.

Rich and the rest of the core team, don't be discouraged by such
comments, if it wasn't for your work id wouldn't be so much excited
with javascript as I am now!

Iv bought the Closure book and I can't wait to see all the cool stuff
that the Clojure community will bring to this arena!

Ronen

On Jul 25, 10:38 am, Mark Derricutt m...@talios.com wrote:
 Oracle announced/talked about Nashorn at the recent JVM Languages summit, 
 this is an Invoke Dynamic based Javascript runtime which is (aiming) for 
 inclusion in JDK8.

 I do so hope however that someone manages to pull that out for a lets run 
 this NOW on Java 7 as that would be a great improvement over rhino.

 On 25/07/2011, at 3:54 AM, Stuart Halloway wrote:

  Rhino is an implementation detail of the development platform. That 
  implementation detail could and probably should change.



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

2011-07-28 Thread Islon Scherer
Hi Oskar, I've been a game programmer for more than 5 years going from 
simple card games to 3D MMORPGs.
Even though you can make a simple game in a functional way it would be a big 
challenge to do the same with a moderately complex game.
Games are all about state, your character if full of state, the enemies have 
state, the world, the AI, the physics, etc.
If you're creating a complex game the language you chose is the least of 
your concerns, the graphics engine, physics engine, AI engine is what really 
matters.
I'm not saying you can't create a game in clojure(I already did) and if your 
main objective is to learn clojure go ahead, but don't be afraid to model 
stateful entities.
However, if you're thinking about making a complex/commercial game I 
strongly advise you use a game engine, there are good free game engines out 
there and it will make your game 2 or 3 orders of magnitude faster to 
finish.

Islon

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

2011-07-28 Thread Oskar
Wow, thank you everyone! Lots of great responses. I'm going to take
some time to let it all sink in.

 I'd say yes if only for the experience of writing a purely functional 
 game (minus the I/O, of course). I wrote a Pong clone in a similar way, 
 though I don't share that author's dislike for passing the whole world to 
 each mover function. That lets you do neat things like: ...

Yes, maybe you are right. You all may have gotten the impression that
I think code size is the worst problem of all, but that is not true.
And of course, one more argument is not a big deal.

My greatest concern is that my code is more complex than it needs to
be. I find myself thinking a lot about how the code I'm writing will
affect other parts of the application, and how it all holds together.
Functional programming is supposed to be the cure for that, so I
thought that it might be a good idea to ask for advice.

I regret now that I mentioned code size and verbosity so much, because
that is not really something I should be thinking so much about. I
just try to strive for brevity in other languages where functional
programming is hardly possible. If you let my apparent preferences for
succinct code and the familiarity of global state influence your
advice, please let me know.


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

2011-07-28 Thread Oskar









On Jul 28, 6:40 pm, Islon Scherer islonsche...@gmail.com wrote:
 Hi Oskar, I've been a game programmer for more than 5 years going from
 simple card games to 3D MMORPGs.
 Even though you can make a simple game in a functional way it would be a big
 challenge to do the same with a moderately complex game.
 Games are all about state, your character if full of state, the enemies have
 state, the world, the AI, the physics, etc.

Hi Islon! Thanks for your response!

Yes, of course games are often stateful. But the state can come
through arguments.

 If you're creating a complex game the language you chose is the least of
 your concerns

Well I don't think so. It would be horrible to not be able to use
Clojure.

 the graphics engine, physics engine, AI engine is what really
 matters.

 I am using a graphics/game engine and a networking lib already. I
have no interest in making my own graphics engine or networking lib.

 I'm not saying you can't create a game in clojure(I already did) and if your
 main objective is to learn clojure go ahead, but don't be afraid to model
 stateful entities.

I'm not afraid. I just want to be open minded and maybe try new
approaches.

 However, if you're thinking about making a complex/commercial game I
 strongly advise you use a game engine, there are good free game engines out
 there and it will make your game 2 or 3 orders of magnitude faster to
 finish.

I don't know why you assumed that I'm not using a game engine. But I
am.



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

2011-07-28 Thread Phil Hagelberg
On Thu, Jul 28, 2011 at 6:53 AM, Wolodja Wentland babi...@gmail.com wrote:
 given the recent interest in ClojureScript and the resulting influx of mails
 regarding it I was wondering if a distinct mailing list for it would make
 sense. What do you think?

I'll inc that.

-Phil

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


Re: ClojureScript mailing list?

2011-07-28 Thread David Nolen
On Thu, Jul 28, 2011 at 1:04 PM, Phil Hagelberg p...@hagelb.org wrote:

 On Thu, Jul 28, 2011 at 6:53 AM, Wolodja Wentland babi...@gmail.com
 wrote:
  given the recent interest in ClojureScript and the resulting influx of
 mails
  regarding it I was wondering if a distinct mailing list for it would make
  sense. What do you think?

 I'll inc that.

 -Phil


I'll dec that.

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: format and printf can't be used with BigInt

2011-07-28 Thread Perry James
Hi,
   Is there any way to get to those docs?  First I had to crate a user
account, then I was told that
You cannot view this page
Page level restrictions have been applied that limit access to this page.
   Thanks,
   Perry

==
This must be Thursday. I never could get the hang of Thursdays -- Arthur
Dent


On Thu, Jul 28, 2011 at 9:24 AM, Stuart Halloway
stuart.hallo...@gmail.comwrote:

 ...
 The draft docs are here:
 http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics. These
 should be made better and placed in a more prominent place before 1.3 goes
 final.
 ...


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

2011-07-28 Thread Devin Walters
I don't think there has been a significant enough influx of mail on the list to 
warrant the creation of a new, separate list. There are so many similarities 
between the two that I think we'd run into situations where people felt that 
the ClojureScript list was getting too much Clojure in it. The division between 
the two is thin enough to make me think we should keep one list.

In addition, almost all of the mail I've seen on the Clojure list has been 
relevant to both Clojure and ClojureScript in general. There are some 
exceptions for items I believe fit the clojure-dev list better, and some 
exceptions for items I don't believe fit this (or any) list at all, but I have 
a feeling these are just some minor growing pains that will work themselves out 
as time goes on.

After all, the announcement is pretty fresh. Let's let the dust settle a bit 
before we go and try to grow another head.

Devin

On Jul 28, 2011, at 12:10 PM, David Nolen wrote:

 On Thu, Jul 28, 2011 at 1:04 PM, Phil Hagelberg p...@hagelb.org wrote:
 On Thu, Jul 28, 2011 at 6:53 AM, Wolodja Wentland babi...@gmail.com wrote:
  given the recent interest in ClojureScript and the resulting influx of mails
  regarding it I was wondering if a distinct mailing list for it would make
  sense. What do you think?
 
 I'll inc that.
 
 -Phil
 
 I'll dec that.
 
 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: Calling clojure from java.

2011-07-28 Thread mmwaikar
Thanks again Meikel. Where can I read about things like bindRoot, intern or 
to be precise java-clojure interop?

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

2011-07-28 Thread Bill Robertson
Hello Stu,

I think the clear no options getting started path should include a
tutorial and focus on the repl and using a *generic* text editor. A
downloadable archive file (zip and tar) that included things like
jline, clojure jars, and some scripts (.sh *and* .bat) to just start
it would allow somebody to party right away.

This package should include a basic tutorial on how to use the repl,
including

* The basics of the repl - simple expressions, functions, simple Java
interaction
* a repl cheat sheet
* Any nifty (extra) features bundled with it, e.g: how to javadoc
* Explain why a repl is beneficial
* Some higher level strategies for benefiting from the repl

Then include zero or more tutorials on clojure itself with the
package. Zero might be best, and just put the basic tutorials online.

This package should be stable. Don't change it willy-nilly. Don't fix
it unless its broken. Don't upgrade for the sake of upgrading. If
people want to move on to Emacs and swank or slime or whatever, or an
ide or start using a build tool, then they will seek those out, but
right now that's all a lot of noise that gets in the way of starting
with the language because there's so much flux in the state of
tooling, which is not a bad thing for the experienced, but it leads to
tail chasing on the part of noob.

If its stable, then other people can write other tutorials/guides that
build off of it w/o worrying about them becoming obsolete.

I think I could put together a zip that had a basic environment, but I
know I don't know enough to know what else belongs in it.

Thanks,
Bill

On Jul 22, 5:22 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
 I am working through a few of the pages on clojure.org with two goals:

 (1) remove or fix anything that is outdated or incorrect

 (2) move to the community site (dev.clojure.org) things that should be 
 maintained by the community.

 As a first pass, I have trimmedhttp://clojure.org/getting_started, and quite 
 clearly linked out tohttp://dev.clojure.org/display/doc/Getting+Startedfor 
 advice on tools, IDEs, etc.

 The community getting started page could be much better. In particular, 
 people have opined that there should be a clear, no-choices-to-make path For 
 Newbies section.Help welcome!

 Stu

 Stuart Halloway
 Clojure/corehttp://clojure.com

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


Re: Calling clojure from java.

2011-07-28 Thread .Bill Smith
It may also be useful to read up on primitives, since primitive support is 
often a source of impedance mismatch when software in one language talks to 
software in another.  Would someone mind supplying a link to a description 
of how Clojure works with Java primitives in the 1.2.1 and 1.3 releases?

Bill

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

2011-07-28 Thread Meikel Brandmeyer
Hi,

Am 28.07.2011 um 19:43 schrieb mmwaikar:

 Thanks again Meikel. Where can I read about things like bindRoot, intern or 
 to be precise java-clojure interop?

There are only a few things you must know:

- RT.var to get a variable from a namespace
- v.invoke to invoke a function stored in a Var

That's it. Then do the normal clojure stuff. bindRoot, intern and such are none 
of our concerns. (I don't know anything about them, either.)

So to load a namespace, you would say in Clojure:

(require 'some.name.space)

In Java, you to the same with more boilerplate:

RT.var(clojure.core, require).invoke(RT.var(clojure.core, 
symbol).invoke(some.name.space))

This is my last information on how the officially blessed way to interface with 
Clojure from Java looks like. I'm not sure about RT.map.

If the thing you want to call is a macro, you have to hope that the library 
other provided the logic as star function (as in Nicolas' case). If there is no 
function containing the actual logic, you have to re-implement the macro in 
Java. cf. 
http://stackoverflow.com/questions/6672934/how-to-call-clojure-macros-from-java/6674923#6674923

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: protocols and records -- use when?

2011-07-28 Thread Andreas Liljeqvist
I would say that protocols are a subset of multimethod functionality.

You want protocols because they are faster and simpler.

Protocols only does dispatch on the type, with multimethods you can do
dispatch on several args of whatever.

2011/7/28 Oskar oskar.kv...@gmail.com

 Thank you Alex and abp!

 Your posts certainly contains valuable information. But I have
 questions still. One might say that you explained how to use
 protocols, but the questions I have left are: Why protocols (and
 records)? What benefits do I get? Alex mentioned polymorphism; how is
 this different from/related to multimethods?

 Let's take the game example again. Say I have (which I do) a map of
 characters in my game that contains both monsters and players.

 A monster:
 {:type :mob :pos [x y] :hp 30 :max-hp 30 :dmg 5 :name an orc
 pawn :attacking false :last-attack 0 :attack-delay 1500 :target
 nil :path nil :speed 2.5 :ai ai/attack-nearest}
 A player:
 {:type :player :name Bill :pos [0 0]  :hp 100 :max-hp 100 :dmg
 10  :attacking false :last-attack 0 :attack-delay 1500 :target nil}

 And I have a few things I want to do to them. Like attack, draw them,
 take damage, die and respawn, etc. Right now all those things work
 exactly the same way for both types. Partly because they are so
 similar, but also because the game is not nearly done yet. For
 example, I might want to draw them differently, or have them take
 damage differently, or whatever. I use the type mostly to filter the
 map, for example monsters can only attack players.

 Is it a good idea to use protocols (and records?) for me in this
 situation (now or in the future when I might want them to behave
 differently)? How can I benefit from them?





 On Jul 28, 1:46 pm, Alex Osborne a...@meshy.org wrote:
  Oskar oskar.kv...@gmail.com writes:
   I have not heard much about records and protocols. What is a typical
   use case in idiomatic Clojure code for them? Is it a good idea, for
   example, to make a Character protocol and Player and Monster
   records or something in a game. It feels a bit too much like OOP for
   me to be comfortable with it, but I can't immediately see why that
   would be bad. I just don't know how they are supposed to be used.
 
  The primary purpose of protocols is efficient, extensible polymorphism:
  handling different data types using a uniform interface.
 
  Rather than a composite idea like Character it is preferable to use
  many fine-grained protocols that each cover a single indivisible
  concept.  Depending on the mechanics in your game you might have
  protocols like Damagable, Listener, Throwable, Describable, Capturable,
  Clickable, Edible, Castable and Container.
 
  (defprotocol Damagable
(alive? [damagable])
(damage [damagable weapon]))
 
  (defprotocol Describable
(describe [describable]))
 
  (defrecord Monster [strength color]
Damagable
  (alive? [m] (pos? health)
  (damage [m weapon] (update-in m [:health] - (weapon :power
Describable
  (describe [m] (str (if ( health 90) a healthy  an injured )
 (if ( strength 50) powerful  weak )
 color  monster)))
 
  (defrecord Tree [age species]
Describable
  (describe [t] (str (when ( age 100) an ancient  a )
 species  tree)))
 
  One of the lovely things about protocols is that they are very
  extensible.  Suppose you want to write some graphics code for drawing
  different game entities.  You can define a rendering protocol and extend
  it to your entities all in a different file.  You don't have to clutter
  up your game logic files with the ugly drawing code.
 
  ;; gfx.clj
 
  (ns game.gfx
(:require [game.enemies :as enemies]
  [game.scenary :as scenary]))
 
  (defprotocol Renderable
(paint [x canvas])
(pixel-width [x]))
 
  (extend-protocol Renderable
scenary/Rock
  (paint [tree canvas] (blit canvas rock.png))
  (pixel-width [tree] 30)
scenary/Tree
  (paint [tree canvas] (blit canvas tree.png))
  (pixel-width [tree] 150)
enemies/Monster
  (paint [m canvas] (blit canvas (get icons (:activity m
  (pixel-width [m] 70))

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

ClojureScript browser-oriented REPL

2011-07-28 Thread Chris Granger
Hey Guys,

I set out and built a clojurescript REPL that uses the browser as it's
execution environment instead of rhino (yes, you can pop up all the
alerts you want!). I'm sure there might be rough edges here and there,
but it currently provides a much better experience than the current
REPL:

- uses rlwrap
- doesn't fail on reader exceptions
- adds a (require ...) function
- allows you to drive visual changes from the browser

https://github.com/ibdknox/brepl

Have fun!

Cheers,
Chris.

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

2011-07-28 Thread Matthew Gilliard
I can confirm that this is awesome!

Thanks Chris

  mg

On Thu, Jul 28, 2011 at 7:40 PM, Chris Granger ibdk...@gmail.com wrote:
 Hey Guys,

 I set out and built a clojurescript REPL that uses the browser as it's
 execution environment instead of rhino (yes, you can pop up all the
 alerts you want!). I'm sure there might be rough edges here and there,
 but it currently provides a much better experience than the current
 REPL:

 - uses rlwrap
 - doesn't fail on reader exceptions
 - adds a (require ...) function
 - allows you to drive visual changes from the browser

 https://github.com/ibdknox/brepl

 Have fun!

 Cheers,
 Chris.

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

2011-07-28 Thread Brian Marick

On Jul 27, 2011, at 7:26 PM, Brian Marick wrote:
 How *does* one provide dates to ClojureQL for transmission to Postgres?  I 
 want to do something like this:
 
 (ql/conj! (ql/table :animals) {:official_name fred :added_to_service 
 something that counts as a SQL Date})

Boy I was dumb yesterday:


user (ql/conj! (ql/table :animals)
{:official_name fred
:added_to_service (Date. (.getMillis (DateMidnight.)))})


-
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
www.exampler.com, www.twitter.com/marick

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


Re: ClojureQL: debugging generated SQL / Dates

2011-07-28 Thread Meikel Brandmeyer
Hi,

Am 28.07.2011 um 21:10 schrieb Brian Marick:

 
 On Jul 27, 2011, at 7:26 PM, Brian Marick wrote:
 How *does* one provide dates to ClojureQL for transmission to Postgres?  I 
 want to do something like this:
 
 (ql/conj! (ql/table :animals) {:official_name fred :added_to_service 
 something that counts as a SQL Date})
 
 Boy I was dumb yesterday:
 
 
 user (ql/conj! (ql/table :animals)
{:official_name fred
:added_to_service (Date. (.getMillis (DateMidnight.)))})

Maybe just (.toDate (DateMidnight.))?

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: passing value to functions

2011-07-28 Thread Alan Malloy
On Jul 28, 12:22 pm, Thorsten Wilms t...@freenet.de wrote:
 On 07/28/2011 06:34 PM, Tuba Lambanog wrote:

  The determination of whether a called function will apply is left as a
  responsibility of the function itself, rather than the calling
  function. The motivation is that a function may be called from a
  number of places. Perhaps there's a better way?

 The called function cannot decide to not be applied, but it may either
 evaluate to its argument (assuming unary), or a value derived from that
 argument.

 I guess pattern matching would be nice here, but even without, you could
 perhaps split the conditions from the actions. Is there any reason to
 test additional rules after one matches, or would it be beneficial to
 stop after a match? That would make it similar to URL routing like e.g.
 Moustache does it.

  From your description, it did sound like you want to call the 2nd
 function with the original argument, not the result of the 1st function.
 But how would you accumulate all the results, then?

You don't need to change the original value at all - you just want
to compute a new value, which, as Thorsten says, may be the same as
the original, or not. Then pass that new value to another function
that may decide to change it again, or not, and then...


(defn fix-ou [word]
  (clojure.string/replace word #ou o))

(defn fix-ize [word]
  (clojure.string/replace word #ise ize))

(defn apply-all-fixes [word]
  (fix-ize (fix-ou word)))

(defn fix-whole-sentence [words]
  (for [word words]
(apply-all-fixes word)))

user (fix-whole-sentence [don't criticise the labour
party])
(don't criticize the labor party)

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

2011-07-28 Thread kjeldahl
Following up on my own confusion, I'll contribute some comments about
potential improvements to either the ClojureScript compiler itself, or
documentation about it's usage in development mode, where everything
is not stuffed into one single js file.

First of all, the options to the compiler. I'll base my comments on
the example found on:

  https://github.com/clojure/clojurescript/wiki/Quick-Start

My apologies in advance if I mess it up, as I'm trying to rewire
experiences from my own code to apply to that example.

If you want to invoke the compiler from within a repl environment, or
your own traditional (JVM based) clojure program, the following syntax
is used:

(cljsc/build samples/hello/src {:output-dir samples/hello/
out :output-to samples/hello/hello.js})

Doing this will put the google closure library in the
samples/hello/out directory, together with a hello.js which is the
output of the clojurescript compilation phase, i.e. your clojurescript
program in javascript.

In addition, it will output another hello.js file in the
samples/hello directory. This file is just an include file, that
effectively pulls in the other stuff, including the identically named
hello.js file found below the out directory.

All these javascript files need to be accessible to your web browser,
and assuming you are fine with having samples/hello in your web
server documentroot or similar, I guess that should work
fine. But that also means that your clojure source code can be found
inside the documentroot (the src directory).

I worked around this in my own source by telling the clojurescript
compiler to write it's output beneath the out directory and giving it
a totally uniqe name, i.e. :output-to samples/hello/out/add-deps.js
.

I want it in the out directory to make it easy to make it simple to
put everything into the documentroot, which in this case could be done
simply by symlinking/copying the whole out directory to the
documentroot.

There is some magic in the clojurescript compiler that look up and
add the path references in the closure (see add-dep-string inside
closure.clj), which probably works fine if you run everything as
written in the docs. But if you try to get fancy with symlinking the
out directory and the one level up hello.js, this magic can be
pretty confusing and make it really hard to get right.

My workaround by putting the output-to destination into the out
directory with a unique name makes this stuff a lot easier I believe.

There's also another gotcha that I noticed, related to how javascript
works. Assuming you've followed my example, your out/add-deps.js
file looks something like this:

goog.addDependency(../cljs/core.js, ['cljs.core'], ['goog.string',
'goog.string.StringBuffer', 'goog.object', 'goog.array']);
goog.addDependency(../hello.js, ['hello'], ['cljs.core']);

Taking the example from the docs, extending it naively like I did,
your index.html might look something like this:

script type=text/javascript src=out/goog/base.js/script
script type=text/javascript src=out/add-deps.js/script
script
  goog.require('hello');
  alert(hello.greet(Hello world!));
/script

Unfortunately, that does not work. This does however:

script type=text/javascript src=out/goog/base.js/script
script type=text/javascript src=out/add-deps.js/script
script
  goog.require('hello');
/script
script
  alert(hello.greet(Hello world!));
/script

This is related to some inner workings of the closure library, which I
believe this is explained on the following page:

http://code.google.com/closure/library/docs/gettingstarted.html

With this in place, things are running smoothly at my end, and my
clojure ring+jetty based server, with pasted code from
https://github.com/maxweber/cljs-devmode, happily recompiles any
clojurescript client side modules to javascript whenever the cljs
source file changes.

Thanks,

Marius K.

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

2011-07-28 Thread Resty Cena
Hi, Thorsten,

Yes, you're right, once inside a function, the function is already being
applied. I mean that within the function, there's a test for whether the
input variable needs to be changed or not. Sort of vacuous application if
conditions are not met.

Yes, an enriched facility for pattern matching would be nice. I use a bit of
regular expression, a last resort for me.

 Is there any reason to test additional rules after one matches, or would
it be beneficial to stop after a match? 

Yes, the input may violate more than one spelling rule. So it is essential
that the output of a function feeds the next one.

Thanks for the help.

Tuba



On Thu, Jul 28, 2011 at 1:22 PM, Thorsten Wilms t...@freenet.de wrote:

 On 07/28/2011 06:34 PM, Tuba Lambanog wrote:

  The determination of whether a called function will apply is left as a
 responsibility of the function itself, rather than the calling
 function. The motivation is that a function may be called from a
 number of places. Perhaps there's a better way?


 The called function cannot decide to not be applied, but it may either
 evaluate to its argument (assuming unary), or a value derived from that
 argument.

 I guess pattern matching would be nice here, but even without, you could
 perhaps split the conditions from the actions. Is there any reason to test
 additional rules after one matches, or would it be beneficial to stop after
 a match? That would make it similar to URL routing like e.g. Moustache does
 it.

 From your description, it did sound like you want to call the 2nd function
 with the original argument, not the result of the 1st function. But how
 would you accumulate all the results, then?


 --
 Thorsten Wilms

 thorwil's design for free software:
 http://thorwil.wordpress.com/

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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: ClojureScript mailing list?

2011-07-28 Thread Stefan Kamphausen
dec

I'd like to follow all that in one place and it's not that much, yet.  Maybe 
that will change with time.  

When the subject lines don't tell which dialect is meant, it may be time to 
create a dedicated list.  But even then, some questions will clearly regard 
both dialects.

Regards,
Stefan

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

Re: Bizarre ClojureScript issue

2011-07-28 Thread Anthony Grimes
Absolutely.

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

2011-07-28 Thread Resty Cena
Hi, Alan,

I can see that your suggestion will work. The key, as I understand it, is
the embedding of functions, thus:

 (fix-ize (fix-ou word)))

which is indeed a Lisp-y way of doing things. It seems imperatively I miss
elegant one-liners such as this.

I'm right now close to getting Laurent's approach to work.

Thanks much for your help.

Tuba

On Thu, Jul 28, 2011 at 1:56 PM, Alan Malloy a...@malloys.org wrote:

 On Jul 28, 12:22 pm, Thorsten Wilms t...@freenet.de wrote:
  On 07/28/2011 06:34 PM, Tuba Lambanog wrote:
 
   The determination of whether a called function will apply is left as a
   responsibility of the function itself, rather than the calling
   function. The motivation is that a function may be called from a
   number of places. Perhaps there's a better way?
 
  The called function cannot decide to not be applied, but it may either
  evaluate to its argument (assuming unary), or a value derived from that
  argument.
 
  I guess pattern matching would be nice here, but even without, you could
  perhaps split the conditions from the actions. Is there any reason to
  test additional rules after one matches, or would it be beneficial to
  stop after a match? That would make it similar to URL routing like e.g.
  Moustache does it.
 
   From your description, it did sound like you want to call the 2nd
  function with the original argument, not the result of the 1st function.
  But how would you accumulate all the results, then?

 You don't need to change the original value at all - you just want
 to compute a new value, which, as Thorsten says, may be the same as
 the original, or not. Then pass that new value to another function
 that may decide to change it again, or not, and then...


 (defn fix-ou [word]
  (clojure.string/replace word #ou o))

 (defn fix-ize [word]
  (clojure.string/replace word #ise ize))

 (defn apply-all-fixes [word]
  (fix-ize (fix-ou word)))

 (defn fix-whole-sentence [words]
  (for [word words]
(apply-all-fixes word)))

 user (fix-whole-sentence [don't criticise the labour
 party])
 (don't criticize the labor party)

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

2011-07-28 Thread Ken Wesson
On Thu, Jul 28, 2011 at 3:05 AM, Sean Corfield seancorfi...@gmail.com wrote:
 On Wed, Jul 27, 2011 at 5:56 PM, Ken Wesson kwess...@gmail.com wrote:
 In Clojure 1.2:

 (type (bigint 2)) = java.math.BigInteger

 In Clojure 1.3:

 (type (bigint 2)) = clojure.lang.BigInt
 (type 2N) = clojure.lang.BigInt

 What the devil? Why was this done? Seems like wheel reinvention to me.

 Chas has already pointed you at the rationale / discussion but I'm a
 bit surprised you reacted as if this was news - the numeric changes in
 1.3 have been discussed at great length in a number of threads here
 dating back over a year (and you, yourself, were active in at least
 one such discussion back in December 2010).

Discussions about primitive arithmetic, not BigInteger arithmetic.

 And format should account for it.

 I can see arguments on both sides. format is clearly documented to be
 a thin wrapper around java.lang.String.format so by that measure we
 shouldn't expect it to handle Clojure's BigInt. OTOH, it's reasonable
 to expect BigInt to behave just like any other regular numeric type
 in Clojure and therefore Clojure's own format function should treat
 BigInt as valid for %d.

That'd be my position, yes. Also, backward compatibility: format works
in 1.2 with (* 4000 4000 4000) so it should
work in 1.3 with (* 4000 4000 4000).

 Might be worth opening a JIRA ticket for enhancing format, yes?

You go ahead. I don't have an account there.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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

2011-07-28 Thread Anthony Grimes
Going to have to dec. A lot of ClojureScript questions in the future (after 
there are less bugs and everything is more stable) will probably be 
answerable by plain ol' Clojure programmers, since most of them will likely 
be normal Clojure problems unrelated to JavaScript. I think it should stay 
here for maximum exposure.

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

2011-07-28 Thread Stefan Kamphausen
Hi,

may I humbly suggest to come up with the most common user stories and put 
links to pages for those users right after the introductory paragraph.  The 
typical scenarios will probably combine a few things, e.g. setting up maven 
and CCW.  Further down the page the links to the detailed topics may be put.

Suggestions for user stories

* You just heard about Clojure and want to try a few things without getting 
into real projects.  Maybe you bought a book on Clojure and want to follow 
along the examples

Leads to

- Some very easy setup, maybe lein repl or clojure.main with JLine or a more 
one-clickish setup (mind the people with low bandwith though)
- An intro to REPL
- I'd love to point the readers of our book to that options for the second 
edition ;-)

* You are a Java programmer and use Eclipse and Maven for your current 
projects.  You'd like to setup this environment to be able to create 
stand-alone Clojure projects to test this new programming language.  Later 
you will be able to combine Clojure and Java yourself.

Leads to

- Counterclockwise
- ... (I am not from that groups, don't know what to put there)

* You are just the Java programmer from the previous item, but you prefer 
Netbeans or IntelliJ?
- Link to Enclojure-Intro
- Link to La Clojure setup

* You come from older Lisps and use Emacs and SLIME.  You view Clojure as an 
interesting new Lisp, but want to try it even more, because it may allow you 
to create Java programms with fewer LoC

Leads to:

- Leiningingen, swank-clojure, gotchas with SLIME installation and finally, 
M-x slime-connect.  
- Some explanations on what Maven is all about, how ~/.m2 is a local repo, 
the CLASSPATH story and the like



... all that being said, I think the current starting page on 
dev.clojure.org is rather good. :-)


Regards,
Stefan

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

Libraries and build management hell

2011-07-28 Thread Michal B
Why does it have to be so complicated to use libraries?

To use libraries, you need to learn how to operate half a dozen build tools 
and git because each library author distributes their library differently. 
If figuring out how to install an IDE with clojure wasn't bad enough, now 
you need to figure out how to install and use each of the tools with it.

I'm not saying build tools are useless, on the contrary. It's just that most 
of the time, we want to sling two or three libraries together and code. 
Right? There is no need to start a project with a bunch of template files 
and an elaborate directory structure and to start configuring dependencies 
and to rely on some magic happening that makes your program run.

I think we over-engineered the build process to support the big projects and 
forgot the common case. Most projects are simple.

Let's remove this incidental complexity by returning to simplicity. Keep the 
build tools for the heavyweights and get back in touch with your libraries.

Instead of having a complicated installation guide for your library, have a 
Download section in your site. Have there a link to the latest stable 
version of your library as a jar file or, if necessary, a zip file with your 
jar and and all the necessary dependency jars (sane library authors won't 
mind). For a zip, shortly describe what's in it - library names and 
versions, and links to their sites. That's it.

I think most JVM users know or can quickly figure out how to take jars and 
put them in their project's classpath. It's simple to do with all IDEs (or 
without one) and there is no need to learn or install additional software or 
edit configuration files. Starter scripts should include in the classpath 
all jars in the current directory or jars/ directory by default.

Instead of managing libraries inside a dependencies file, you do it directly 
with the jar files. If the project gets too big, bring in the build tools.

What are your thoughts on this issue?

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

2011-07-28 Thread Timothy Baldridge
 Why does it have to be so complicated to use libraries?

I used to think it was hard until I read up on lein. Can't get much
simpler than clojars and lein:

http://clojars.org/
http://alexott.net/en/clojure/ClojureLein.html

Now I'm starting to think that I actually like the lein method over
python easy_install or ruby gems.

Timothy


-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

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

2011-07-28 Thread gaz jones
i would agree with all that if i were writing plain java (a lib dir
for dependencies and a couple of shell scripts for building etc), but
leiningen makes it so easy for clojure that its more work _not_ to use
it... at least that has been my experience.

On Thu, Jul 28, 2011 at 4:23 PM, Michal B mibu.cloj...@gmail.com wrote:
 Why does it have to be so complicated to use libraries?

 To use libraries, you need to learn how to operate half a dozen build tools
 and git because each library author distributes their library differently.
 If figuring out how to install an IDE with clojure wasn't bad enough, now
 you need to figure out how to install and use each of the tools with it.

 I'm not saying build tools are useless, on the contrary. It's just that most
 of the time, we want to sling two or three libraries together and code.
 Right? There is no need to start a project with a bunch of template files
 and an elaborate directory structure and to start configuring dependencies
 and to rely on some magic happening that makes your program run.

 I think we over-engineered the build process to support the big projects and
 forgot the common case. Most projects are simple.

 Let's remove this incidental complexity by returning to simplicity. Keep the
 build tools for the heavyweights and get back in touch with your libraries.

 Instead of having a complicated installation guide for your library, have a
 Download section in your site. Have there a link to the latest stable
 version of your library as a jar file or, if necessary, a zip file with your
 jar and and all the necessary dependency jars (sane library authors won't
 mind). For a zip, shortly describe what's in it - library names and
 versions, and links to their sites. That's it.

 I think most JVM users know or can quickly figure out how to take jars and
 put them in their project's classpath. It's simple to do with all IDEs (or
 without one) and there is no need to learn or install additional software or
 edit configuration files. Starter scripts should include in the classpath
 all jars in the current directory or jars/ directory by default.

 Instead of managing libraries inside a dependencies file, you do it directly
 with the jar files. If the project gets too big, bring in the build tools.

 What are your thoughts on this issue?

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

2011-07-28 Thread Tuba Lambanog
Hi, Laurent,

Your suggestion of manually piping intermediate results works. Thank you
very much!

Tuba

On Thu, Jul 28, 2011 at 3:44 AM, Laurent PETIT laurent.pe...@gmail.comwrote:

 Hi,

 2011/7/28 Tuba Lambanog tuba.lamba...@gmail.com

 Hello,

 I'm trying to pass a variable through a series of functions, which may
 change the value of the variable. However, the next function in line
 uses the original value, rather than the changed value. Here's a
 pseudo-code of what I'm doing.

 (defn process-1 [s]
 ; change value of s then return it
  s)

 (def s something)
 (do
  (process-1 s)  ; variable s is changed here
  (process-2 s)); process-2 uses the original value of s, not the
 return value from process-1


 beware, change in the clojure world means computing a new value based on
 an old one (as opposed to creating a new value almost from scratch).

 So for example, when you add an element to a map :
 (def m1 {:a 1})
 (def m2 (assoc m1 :b 2))

 you're really creating a new value.
 People will sometimes say they change m1, but it's not true, it's more to
 say that m2 is derived from m1 (sharing most things with m1).

 So you need to pipe the return value of process-1 into process-2.

 The manual way to do the pipe :
 (let [s-p1 (process-1 s)
   s-p2 (process-2 s-p1)]
   s-p2)

 The short way (preferred in your case) :
 (- s process-1 process-2)

 HTH,

 --
 Laurent


 Thanks for the help.

 Perhaps a sub-forum for beginners? Kind of embarrassing to ask here
 questions that are so newbie-ish.

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

2011-07-28 Thread nil
Until you find someone, one site you can look at is the clojure euler
site. It has some math examples written by folks who know clojure to
varying degrees. You can see different ways of tackling a given
problem.

On Jul 28, 1:26 pm, Jay Vyas jayunit...@gmail.com wrote:
 Hi guys (and hello to my beloved london-clojurians) : My name is jay and I
 want to pair program some Clojure scripts against REPL  with a moderate to
 good clojure tutor.  If anyone is intersted I'd be willing to pay an hourly
 fee.  Want to work on some mathematical libraries  for my Phd Thesis.
 Thanks !

 Jay

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


Re: Problem with ClojureScript and Node.js

2011-07-28 Thread Anthony Grimes
I'm all of a sudden getting this exact same error on OS X 10.6.8. And I do 
mean all of a sudden. I actually updated to this version of OS X last night 
and today it isn't working. Is this happening to any OS X users on an older 
Snow Leopard? This is the only thing that has changed in my setup, so I'm 
actually starting to wonder if it might have something to do with 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

clojure.contrib.command-line

2011-07-28 Thread octopusgrabbus
Are there any command-line examples or documentation other than what's
up on clojure.org or ClojureDocs?

I'm using

(defn -main [ args]
  (with-command-line args
Get csv file name
[[in-file-name .csv input file name  resultset.csv ]]
[[in-file-name .csv input file name  1]]

(println in-file-name:, in-file-name)

If I specify a file name it does not get used. Only resultset.csv is
used.

tnx
cmn

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


dynamically generated let bindings

2011-07-28 Thread Sam Aaron
Hi there,

I'm trying to create a fn which does the following:

* returns a fn which takes an arbitrary number of args
* calls a helper fn, passing the incoming args returning a vector of 
alternating symbols and vals
* creates a let form using the vector of alternating symbols and vals returned 
by the helper fn as the bindings
* contains some inner form that makes use of the bindings

i.e. is it possible to implement something that allows the following to work:

(defn binding-vec 
  [args]
  ['size (count args)])

(defn mk-dynamically-bound-fn
  [form]
  ;; returns a fn with sign [ args] which
  ;; uses binding-vec to create a the vec for
  ;; which a let statement binds around form
  )

(def a (mk-dynamically-bound-fn '(+ size 10)))

(a 1 2 3 4) ;= 14 (the number of args + 10)


Please let me know if I'm being a bit crazy with the question. It's totally 
possible that I'm barking up the wrong tree with this line of enquiry.

Sam

---
http://sam.aaron.name

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

2011-07-28 Thread uMany
I'm a total newbie with Clojure/Lisp/Java/Cake/Lein/Emacs etc.
But I want to help translating to Spanish.
If you tell me where can I find instructions to do it I will with
pleasure.

By the way, I've been fighting with Emacs/Clojure and everything else.
It has been frustrating but I've learn a lot and I like to learn. So
for me, I don't give up. I wont give up. I just want to program in
Clojure no matter what just because I like it.

Manuel

On Jul 22, 5:22 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
 I am working through a few of the pages on clojure.org with two goals:

 (1) remove or fix anything that is outdated or incorrect

 (2) move to the community site (dev.clojure.org) things that should be 
 maintained by the community.

 As a first pass, I have trimmedhttp://clojure.org/getting_started, and quite 
 clearly linked out tohttp://dev.clojure.org/display/doc/Getting+Startedfor 
 advice on tools, IDEs, etc.

 The community getting started page could be much better. In particular, 
 people have opined that there should be a clear, no-choices-to-make path For 
 Newbies section.Help welcome!

 Stu

 Stuart Halloway
 Clojure/corehttp://clojure.com

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


Re: Problem with ClojureScript and Node.js

2011-07-28 Thread Anthony Grimes
Actually, it seems to be caused by this 
commit: 
https://github.com/clojure/clojurescript/commit/954e8529b1ec814f40af77d6035f90e93a9126ea

If I checkout before that, everything is peachy. I guess I'll submit a bug 
report.

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

2011-07-28 Thread Sean Corfield
On Thu, Jul 28, 2011 at 8:54 AM, Daniel Gagnon redalas...@gmail.com wrote:
 So, what does it means for Clojure?

It's not going to mean anything for a long time. Clojure still
supports Java 5 so it is probably going to be years before Java 7 is
mainstream enough that Clojure can _require_ it.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: clojure.contrib.command-line

2011-07-28 Thread Anthony Grimes
command-line is deprecated in favor of tools.cli now. 
http://github.com/clojure/tools.cli

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

2011-07-28 Thread Sean Corfield
On Thu, Jul 28, 2011 at 1:53 PM, Ken Wesson kwess...@gmail.com wrote:
 Chas has already pointed you at the rationale / discussion but I'm a
 Discussions about primitive arithmetic, not BigInteger arithmetic.

I take it you didn't actually bother to read the page he linked to?
Let me quote the relevant part for you since I know how averse you are
to spending any time reading more than the first few lines of any
material that people link to:

* new clojure.lang.BigInt class
* BigInts do not auto-reduce, and are contagious (akin to doubles)
  * BigInts will enable optimizations when fits in long
* optimzations not yet in place
  * unlike BigInteger, BigInt has consistent hashcodes with Long,
through range of long

 That'd be my position, yes. Also, backward compatibility: format works
 in 1.2 with (* 4000 4000 4000) so it should
 work in 1.3 with (* 4000 4000 4000).

Kinda hard since that expression is not valid in 1.3 anyway:

ArithmeticException integer overflow
clojure.lang.Numbers.throwIntOverflow (Numbers.java:1374)

So that code breaks explicitly in 1.3 and in many ways (format) is
then the least of your worries...

 Might be worth opening a JIRA ticket for enhancing format, yes?
 You go ahead. I don't have an account there.

Ah, that's right... the contributor process is too much work for
you... Maybe one of the kind souls who've taken the time to go thru
that process might feel inclined to open such a ticket for you? If
they agree with your position, of course.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: format and printf can't be used with BigInt

2011-07-28 Thread Sean Corfield
I think one of the authors / core members needs to change the
permissions. I have edit access on the parent page
http://dev.clojure.org/display/doc/Enhanced+Primitive+Support and the
sibling page http://dev.clojure.org/display/doc/Bit+Operations but,
like you, don't have view access to the Numerics page.

Sean

On Thu, Jul 28, 2011 at 7:27 AM, Perry James perry.ja...@computer.org wrote:
    Is there any way to get to those docs?  First I had to crate a user
 account, then I was told that
 You cannot view this page
 Page level restrictions have been applied that limit access to this page.

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

2011-07-28 Thread Kenny Stone
Can clojure take advantage of  some features if they are available?  I know
the JRuby dudes are pretty excited about invoke dynamic...

Kenny

On Thu, Jul 28, 2011 at 6:14 PM, Sean Corfield seancorfi...@gmail.comwrote:

 On Thu, Jul 28, 2011 at 8:54 AM, Daniel Gagnon redalas...@gmail.com
 wrote:
  So, what does it means for Clojure?

 It's not going to mean anything for a long time. Clojure still
 supports Java 5 so it is probably going to be years before Java 7 is
 mainstream enough that Clojure can _require_ it.
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/
 Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


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

2011-07-28 Thread Sean Corfield
+1 to (dec op-suggestion) for the reasons that Devin, Stefan and Anthony gave...

Also on #clojure (IRC) one of the core team said discussion about
ClojureScript would happen here so I don't think there would be much
management support for splitting ClojureScript out.

Sean

On Thu, Jul 28, 2011 at 1:59 PM, Anthony Grimes disciplera...@gmail.com wrote:
 Going to have to dec. A lot of ClojureScript questions in the future (after
 there are less bugs and everything is more stable) will probably be
 answerable by plain ol' Clojure programmers, since most of them will likely
 be normal Clojure problems unrelated to JavaScript. I think it should stay
 here for maximum exposure.

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


Re: Problem with ClojureScript and Node.js

2011-07-28 Thread Rich Hickey
Could you please use quoting in your messages? Otherwise they have no  
context.


Thanks,

Rich

On Jul 28, 2011, at 7:10 PM, Anthony Grimes wrote:


Actually, it seems to be caused by this commit: 
https://github.com/clojure/clojurescript/commit/954e8529b1ec814f40af77d6035f90e93a9126ea

If I checkout before that, everything is peachy. I guess I'll submit  
a bug report.




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

2011-07-28 Thread OGINO Masanori
Laurent's way and Alan's way have different surfaces, but same mean.

(- word fix-ou fix-ize)
(fix-ize (fix-ou word))

You can check it using clojure.walk/macroexpand-all.

user= (macroexpand-all '(- labour fix-ou fix-ize))
(fix-ize (fix-ou labour))

Indeed you can choose only one way, I suggest considering two ways.
Sometimes using - is easy to read, and sometimes it is hard to do.
(Readability is the matter in this case, right?)

-- 
Name:  OGINO Masanori (荻野 雅紀)
E-mail: masanori.og...@gmail.com

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


Re: format and printf can't be used with BigInt

2011-07-28 Thread Ken Wesson
On Thu, Jul 28, 2011 at 7:28 PM, Sean Corfield seancorfi...@gmail.com wrote:
 On Thu, Jul 28, 2011 at 1:53 PM, Ken Wesson kwess...@gmail.com wrote:
 Chas has already pointed you at the rationale / discussion but I'm a
 Discussions about primitive arithmetic, not BigInteger arithmetic.

 I take it you didn't actually bother to read the page he linked to?

You take it wrong. I remember that discussion, evidently better than you do.

 I know how averse you are to spending any time reading more than
 the first few lines of any material

Wrong again. Are you quite done littering the list with pointless ad
hominem remarks?

 That'd be my position, yes. Also, backward compatibility: format works
 in 1.2 with (* 4000 4000 4000) so it should
 work in 1.3 with (* 4000 4000 4000).

 Kinda hard since that expression is not valid in 1.3 anyway:

 ArithmeticException integer overflow
 clojure.lang.Numbers.throwIntOverflow (Numbers.java:1374)

Bah. It really should work, but we've had that discussion before.
Others in this thread have also pointed out that there is a backward
compatibility problem if format used to work with bignums and then
stops doing so, so you're outvoted.

 ... too much work for you...

This is not an appropriate venue for you to vent bile about other
fellow users. If you have some kind of personal issue with me, please
take it up by private email or simply keep it to yourself. Thank you.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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

2011-07-28 Thread Kent
I'm not sure what you're trying to do with this and, based on that
ignorance, I'm not sure I think it's a great idea. Maybe you are being
a bit crazy, and maybe your a genius.  Who am I to say?

Here is a function that does what you want.  The only difference is
that my function also takes the binding-vec function as an argument.


(defn mdbf [form binding-func]
  (fn [ args]
(eval `(let ~(binding-func args) ~form

Here it is used in your example.

(defn binding-vec
  [args]
   ['size (count args)]

(def a (mdbf '(+ size 10) binding-vec))

(a 1 2 3 4) = 14

Kent.

On Jul 28, 3:48 pm, Sam Aaron samaa...@gmail.com wrote:
 Hi there,

 I'm trying to create a fn which does the following:

 * returns a fn which takes an arbitrary number of args
 * calls a helper fn, passing the incoming args returning a vector of 
 alternating symbols and vals
 * creates a let form using the vector of alternating symbols and vals 
 returned by the helper fn as the bindings
 * contains some inner form that makes use of the bindings

 i.e. is it possible to implement something that allows the following to work:

 (defn binding-vec
   [args]
   ['size (count args)])

 (defn mk-dynamically-bound-fn
   [form]
   ;; returns a fn with sign [ args] which
   ;; uses binding-vec to create a the vec for
   ;; which a let statement binds around form
   )

 (def a (mk-dynamically-bound-fn '(+ size 10)))

 (a 1 2 3 4) ;= 14 (the number of args + 10)

 Please let me know if I'm being a bit crazy with the question. It's totally 
 possible that I'm barking up the wrong tree with this line of enquiry.

 Sam

 ---http://sam.aaron.name

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

2011-07-28 Thread Sean Corfield
On Thu, Jul 28, 2011 at 2:23 PM, Michal B mibu.cloj...@gmail.com wrote:
 Why does it have to be so complicated to use libraries?

I can't imagine it being much simpler than using Leiningen...

 To use libraries, you need to learn how to operate half a dozen build tools

Just one: Leiningen. You can learn Cake or Maven instead if you want, I guess.

 and git because each library author distributes their library differently.

Hmm, I haven't needed git for anything I'm not actually contributing
to - with the exception of ClojureScript itself (and given the state
of that, I think a build from source approach is acceptable for
now).

 Right? There is no need to start a project with a bunch of template files
 and an elaborate directory structure and to start configuring dependencies
 and to rely on some magic happening that makes your program run.

Well, you could download JAR files and then use the java command with
the appropriate classpath and other arguments to run your script...
but that seems more work to me than telling Leiningen which libraries
I want and then telling Leiningen to run my -main function - with
Leiningen handling all of the dependencies and the classpath stuff
etc.

I don't think I'd choose to not use Leiningen, even on a single file
project that used no additional libraries:

lein new thing
cd thing
vi s[tab][tab][tab]
...sling together some code... ZZ
lein run -m thing.core

Done!

(I know, the heresy of using 'vi'... :)
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: Problem with ClojureScript and Node.js

2011-07-28 Thread Anthony Grimes
Oh! I apologize. I was replying via the google interface and didn't realize 
it wasn't quoting. Here is a link to the topic for 
context: https://groups.google.com/d/topic/clojure/ZyVrCxmOFTM/discussion

I've also filed a bug here: http://dev.clojure.org/jira/browse/CLJS-43

Sorry. :)

On Thursday, July 28, 2011 6:40:39 PM UTC-5, Rich Hickey wrote:

 Could you please use quoting in your messages? Otherwise they have no  
 context.

 Thanks,

 Rich

 On Jul 28, 2011, at 7:10 PM, Anthony Grimes wrote:

  Actually, it seems to be caused by this commit: 
 https://github.com/clojure/clojurescript/commit/954e8529b1ec814f40af77d6035f90e93a9126ea
 
  If I checkout before that, everything is peachy. I guess I'll submit  
  a bug report.
 



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

2011-07-28 Thread Ken Wesson
On Thu, Jul 28, 2011 at 1:58 PM, Meikel Brandmeyer m...@kotka.de wrote:
 If the thing you want to call is a macro, you have to hope that the library 
 other provided the logic as star function (as in Nicolas' case). If there is 
 no function containing the actual logic, you have to re-implement the macro 
 in Java. cf. 
 http://stackoverflow.com/questions/6672934/how-to-call-clojure-macros-from-java/6674923#6674923

There's also the eval(read(whatever)) route, if you need to resort to it.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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

2011-07-28 Thread Ken Wesson
On Thu, Jul 28, 2011 at 6:48 PM, Sam Aaron samaa...@gmail.com wrote:
 Hi there,

 I'm trying to create a fn which does the following:

 * returns a fn which takes an arbitrary number of args
 * calls a helper fn, passing the incoming args returning a vector of 
 alternating symbols and vals
 * creates a let form using the vector of alternating symbols and vals 
 returned by the helper fn as the bindings
 * contains some inner form that makes use of the bindings

You probably want a macro rather than a normal function here, which is
used in the body of a function or else in a manner similar to defn.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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

2011-07-28 Thread Tal Liron
I have to agree with this. In fact, it would be much easier to
integrate into Clojure than JRuby (or other JVM languages).

I know the Clojure Java source code pretty well, and wouldn't mind
playing with it a bit to see how feasible it is.

The ideal deployment solution would be to have an extra jar with the
JVM7 stuff that does not interfere with the core code. I'll have to
see how feasible that is.

-Tal

On Jul 28, 6:32 pm, Kenny Stone kennethst...@gmail.com wrote:
 Can clojure take advantage of  some features if they are available?  I know
 the JRuby dudes are pretty excited about invoke dynamic...

 Kenny

 On Thu, Jul 28, 2011 at 6:14 PM, Sean Corfield seancorfi...@gmail.comwrote:







  On Thu, Jul 28, 2011 at 8:54 AM, Daniel Gagnon redalas...@gmail.com
  wrote:
   So, what does it means for Clojure?

  It's not going to mean anything for a long time. Clojure still
  supports Java 5 so it is probably going to be years before Java 7 is
  mainstream enough that Clojure can _require_ it.
  --
  Sean A Corfield -- (904) 302-SEAN
  An Architect's View --http://corfield.org/
  World Singles, LLC. --http://worldsingles.com/
  Railo Technologies, Inc. --http://www.getrailo.com/

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

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

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

2011-07-28 Thread Ken Wesson
On Thu, Jul 28, 2011 at 7:32 PM, Kenny Stone kennethst...@gmail.com wrote:
 Can clojure take advantage of  some features if they are available?  I know
 the JRuby dudes are pretty excited about invoke dynamic...

I'm not really sure there's a single answer to that question.

On the one hand, assuming that Java 7 doesn't outright break anything,
just using it to run new or existing Clojure code gets you any new
Hotspot optimizations, the new G1 garbage collector, and (with new
Clojure code) access to new library functionality via interop.

On the other hand, invokedynamic won't instantly get you anything. If
Clojure can benefit from it at all, one *could* in principle modify
Compiler.java to try to detect whether it's running on a JVM that
supports the instruction or not, and to generate code that uses
invokedynamic only if it is.

As for using hypothetical new library functionality to implement parts
of clojure.core or clojure.lang, that would create a big backward
compatibility headache and should probably be avoided for now. Third
party libraries that provide functionality based on, say, fork-join
can certainly be made available though.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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

2011-07-28 Thread OGINO Masanori
AFAIK using InvokeDynamic *requires* Java7, so I think it will be done
if Java7 gets default and it fits for Clojure.

However, for example, new HotSpot gains more performance then Clojure
may also gain if you use Java7...
(but you can't force everyone to use Java7 of course.)

Also, you can call new libraries even if they are not used Clojure itself.
(You may tell users your code works with Java7)

-- 
Name:  OGINO Masanori (荻野 雅紀)
E-mail: masanori.og...@gmail.com

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


Re: protocols and records -- use when?

2011-07-28 Thread Alex Osborne
Oskar oskar.kv...@gmail.com writes:

 Why protocols (and records)? What benefits do I get? Alex mentioned
 polymorphism; how is this different from/related to multimethods?

As Andreas mentioned, yes protocols basically give you a subset of the
polymorphism functionality of multimethods.  But they also give you some
benefits that multimethods do not.  Otherwise they would not have been
added to the language. ;-)

There are a number of motivations which Rich lists here:

http://clojure.org/protocols
http://clojure.org/datatypes

I will try to cover the main ones with a bit of explanation.


1. Performance

Multimethods are not fast enough for writing high-performance data
structures in the computer science sense (hash tables, red-black trees
etc).  One of the motivations for adding types and protocols was that it
should be possible to write Clojure's persistent data structures in
an idiomatic, fast way in Clojure itself, rather than in Java.

ClojureScript is in part a validation of this idea.  The data structures
and core library of ClojureScript are written completely in
ClojureScript, not in JavaScript.

In the ideal case protocols can map to native Java interfaces and so
benefit from the JVMs optimizations.  Of course protocols can do things
which interfaces cannot (extend) so there is a gradual performance
degradation if they are used in more dynamic ways.

Similarly, records replace the earlier feature structs, which were
also high-performance record types.  Structs were designed to be used
with multimethods but unfortunately multimethods negated some of their
performance benefits.


2. Abstraction and organization

Rich lists the point Support the 90% case of multimethods while
providing higher-level abstraction/organization.

Single dispatch on type is by far the most common use of polymorphism.
This is why it is the only (native) polymorphism mechanism in many
languages.  Many use cases do not need the full power of multimethods.

One thing that Java's interfaces can do that multimethods cannot is
group a set of tightly related methods together.

For example, let's look at the ISeq protocol from ClojureScript.  (In
Clojure ISeq is a Java interface rather than a protocol for historical
reasons but the use case is the same.)

(defprotocol ISeq
  (-first [coll])
  (-rest [coll]))

ISeq contains two methods: -first and -rest.  To have meaningful seq
you really need both of them.  A seq with a rest but no first would
be pretty silly.

By grouping these two methods into a single protocol you communicate
to reader of your code they are tightly and indivisibly related and
should be implemented together.  This is not enforced of course, it's
about communicating your intentions, not restricting what the programmer
can do.


3. Host interoperability

Where possible types and protocols map to similar concepts in Java's
classes and interfaces.  A type can implement a Java interface and a
Java class can extend a Clojure protocol.

The mapping is of course not perfect.  For example you can't use
extend on a Java interface as Java doesn't have this concept.
Similarly you can't subclass a Java class with a Clojure type as by
design Clojure types do not have a notion of inheritance. 

While they do not cover all interop needs they do provide a useful, more
convenient and high performance replacement for some of the use cases of
earlier interop mechanisms like proxy and gen-class.

 Let's take the game example again. Say I have (which I do) a map of
 characters in my game that contains both monsters and players.

 A monster:
 {:type :mob :pos [x y] :hp 30 :max-hp 30 :dmg 5 :name an orc
 pawn :attacking false :last-attack 0 :attack-delay 1500 :target
 nil :path nil :speed 2.5 :ai ai/attack-nearest}
 A player:
 {:type :player :name Bill :pos [0 0]  :hp 100 :max-hp 100 :dmg
 10  :attacking false :last-attack 0 :attack-delay 1500 :target nil}

 And I have a few things I want to do to them. Like attack, draw them,
 take damage, die and respawn, etc. Right now all those things work
 exactly the same way for both types. Partly because they are so
 similar, but also because the game is not nearly done yet. For
 example, I might want to draw them differently, or have them take
 damage differently, or whatever. I use the type mostly to filter the
 map, for example monsters can only attack players.

 Is it a good idea to use protocols (and records?) for me in this
 situation (now or in the future when I might want them to behave
 differently)? How can I benefit from them?

You can of course use multimethods for these use cases and there is
nothing wrong with doing so.  However for those 90% of cases which
protocols do cover you may find they are a more natural fit and give you
some of the benefits I listed above.

For the remaining 10% where you need the additional power of
multimethods you can of course continue to use them.  They're not going
away.

The main use cases for the old structs feature on the 

Re: Alright, fess up, who's unhappy with clojurescript?

2011-07-28 Thread Tal Liron
James, your tone was unfortunate, but I do want do defend your
position *a little*.

Projects like ClojureScript (and CoffeeScript) -- and GWT and Vaadin
for that matter -- come from a certain anti-JavaScript attitude.
Though I sympathize, I would like to encourage all the JavaScript
haters to give JavaScript another chance. The C-syntax isn't great,
but the language itself shares with Lisps a minimalist core and the
ability to be truly multi-paradigm. If you like JS, you may find
yourself not *needing* something like ClojureScript, CoffeeScript,
etc.

(Although, James, the fact that you and I don't need or want it should
not cause us any disappointment with its existence! For die-hard JS
haters, ClojureScript is terrific.)

jQuery is not so much an elephant as it is a mammoth. It was one of
the first clientside-JS frameworks to reach a broad audience, but it
also one of the worst. It incorporates so many terrible JS practices,
performs miserably, and really can make anyone dislike JS. People have
mentioned other clientside frameworks. Let me mention also Ext JS,
which I believe knocks the socks off the rest. It is crafted with a
real appreciation of JS, and that love may rub off you a little as you
work with it.

And I'll also mention Prudence, which was announced on the list this
week:

http://threecrickets.com/prudence/

Prudence lets you mix both Clojure and JS (via Rhino) code on the
server, and also features good integration with Ext JS. It could be a
good platform for Clojure web development warriors to hone their JS
chops. (Disclosure: I'm the founder of Prudence.)

-Tal

On Jul 24, 10:19 am, James Keats james.w.ke...@gmail.com wrote:
 Alright, to be honest, I'm disappointed.

 First of all, congrats and good job to all involved in putting it out.
 On the plus side, it's a good way to use the Google Closure javascript
 platform.

 On the minus, imho, that's what's wrong with it.

 Google Closure is too Java. It's not idiomatic JavaScript. I find it
 disappointing that rather than porting from a functional language like
 Clojure straight to another functional language like Javascript, the
 google closure with its ugly Java-isms is right there obnoxiously in
 the middle.

 Then, there's the elephant in the room, and that elephant is Jquery. I
 believe any targetting-javascript tool that misses out on jquery-first-
 and-foremost is missing out on the realities of javascript in 2011.
 Jquery is huge in its community and plugins, and it has tons of books
 and tutorials. In much the same way that you can have lots of libs on
 the JVM, there are lots of plugins for jquery. So much so that the
 latest edition of Javascript: the Definitive Guide includes a chapter
 on it; quoted:

 Because the jQuery library has become so widely used, web developers
 should be fa-
 miliar with it: even if you don’t use it in your own code, you are
 likely to encounter it
 in code written by others.

 Then, the Google Closure compiler is a moot point. Everyone by now
 already has a copy of jquery from the Google CDN and linking to it in
 your code will not download it any further after your first visit to a
 website that does so. In any case, it's already small and fast.

 Then there's rhino/jvm. I would much rather an in-browser focus.

 I'm tempted to fork clojurescript and redo it in javascript perhaps
 so that seamless interop with jquery would be the main priority.

 Discuss?

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

2011-07-28 Thread JAX
I'm all for simplifying clojure.
Even if Lein is great... If clojure is heavily biased and saddled by yet 
another framework/build system , it will never go mainstream.

Jay Vyas 
MMSB
UCHC

On Jul 29, 2011, at 12:32 AM, clojure+nore...@googlegroups.com wrote:

   Today's Topic Summary
 Group: http://groups.google.com/group/clojure/topics
 
 format and printf can't be used with BigInt [2 Updates]
 clojure.contrib.command-line [2 Updates]
 Java 7 is out! [1 Update]
 Problem with ClojureScript and Node.js [2 Updates]
 better community docs: getting started [1 Update]
 dynamically generated let bindings [1 Update]
 Pair Coding over Skype [1 Update]
 passing value to functions [1 Update]
 Libraries and build management hell [3 Updates]
  Topic: format and printf can't be used with BigInt
 Sean Corfield seancorfi...@gmail.com Jul 28 04:28PM -0700 ^
  
  Chas has already pointed you at the rationale / discussion but I'm a
  Discussions about primitive arithmetic, not BigInteger arithmetic.
  
 I take it you didn't actually bother to read the page he linked to?
 Let me quote the relevant part for you since I know how averse you are
 to spending any time reading more than the first few lines of any
 material that people link to:
  
 * new clojure.lang.BigInt class
 * BigInts do not auto-reduce, and are contagious (akin to doubles)
 * BigInts will enable optimizations when fits in long
 * optimzations not yet in place
 * unlike BigInteger, BigInt has consistent hashcodes with Long,
 through range of long
  
  That'd be my position, yes. Also, backward compatibility: format works
  in 1.2 with (* 4000 4000 4000) so it should
  work in 1.3 with (* 4000 4000 4000).
  
 Kinda hard since that expression is not valid in 1.3 anyway:
  
 ArithmeticException integer overflow
 clojure.lang.Numbers.throwIntOverflow (Numbers.java:1374)
  
 So that code breaks explicitly in 1.3 and in many ways (format) is
 then the least of your worries...
  
  Might be worth opening a JIRA ticket for enhancing format, yes?
  You go ahead. I don't have an account there.
  
 Ah, that's right... the contributor process is too much work for
 you... Maybe one of the kind souls who've taken the time to go thru
 that process might feel inclined to open such a ticket for you? If
 they agree with your position, of course.
 -- 
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/
 Railo Technologies, Inc. -- http://www.getrailo.com/
  
 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)
  
 
 Sean Corfield seancorfi...@gmail.com Jul 28 04:30PM -0700 ^
  
 I think one of the authors / core members needs to change the
 permissions. I have edit access on the parent page
 http://dev.clojure.org/display/doc/Enhanced+Primitive+Support and the
 sibling page http://dev.clojure.org/display/doc/Bit+Operations but,
 like you, don't have view access to the Numerics page.
  
 Sean
  
  
 
  Topic: clojure.contrib.command-line
 octopusgrabbus octopusgrab...@gmail.com Jul 28 03:37PM -0700 ^
  
 Are there any command-line examples or documentation other than what's
 up on clojure.org or ClojureDocs?
  
 I'm using
  
 (defn -main [ args]
 (with-command-line args
 Get csv file name
 [[in-file-name .csv input file name resultset.csv ]]
 [[in-file-name .csv input file name 1]]
  
 (println in-file-name:, in-file-name)
  
 If I specify a file name it does not get used. Only resultset.csv is
 used.
  
 tnx
 cmn
  
 
 Anthony Grimes disciplera...@gmail.com Jul 28 04:24PM -0700 ^
  
 command-line is deprecated in favor of tools.cli now. 
 http://github.com/clojure/tools.cli
  
 
  Topic: Java 7 is out!
 Sean Corfield seancorfi...@gmail.com Jul 28 04:14PM -0700 ^
  
  So, what does it means for Clojure?
  
 It's not going to mean anything for a long time. Clojure still
 supports Java 5 so it is probably going to be years before Java 7 is
 mainstream enough that Clojure can _require_ it.
 -- 
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/
 Railo Technologies, Inc. -- http://www.getrailo.com/
  
 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)
  
 
  Topic: Problem with ClojureScript and Node.js
 Anthony Grimes disciplera...@gmail.com Jul 28 03:32PM -0700 ^
  
 I'm all of a sudden getting this exact same error on OS X 10.6.8. And I do 
 mean all of a sudden. I actually updated to this version of OS X last night 
 and today it isn't working. Is this happening to any OS X users on an older 
 Snow Leopard? This is the only thing that has changed in my setup, so I'm 
 actually starting to wonder if it might have something to do with that.
  
 
 Anthony Grimes disciplera...@gmail.com Jul 28 04:10PM -0700 ^
  
 Actually, it seems to be caused by this 
 commit: 
 

Re: Alright, fess up, who's unhappy with clojurescript?

2011-07-28 Thread Lars Rune Nøstdal
.. but isn't jQuery and ExtJS totally different things?

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

2011-07-28 Thread pmbauer
That wasn't called for.

Given Stu linked to the page (and is linked in the 1.3 release notes), it's 
reasonable to assume the permission error is merely a mistake and not some 
nefarious plot to withhold information from the Clojure community.

On Thursday, July 28, 2011 4:48:34 PM UTC-7, Ken Wesson wrote:

 On Thu, Jul 28, 2011 at 7:30 PM, Sean Corfield seanco...@gmail.com 
 wrote:
  I think one of the authors / core members needs to change the
  permissions. I have edit access on the parent page
  http://dev.clojure.org/display/doc/Enhanced+Primitive+Support and the
  sibling page http://dev.clojure.org/display/doc/Bit+Operations but,
  like you, don't have view access to the Numerics page.

  On Thu, Jul 28, 2011 at 7:27 AM, Perry James perry...@computer.org 
 wrote:

  You cannot view this page

 I can't think of a single good reason why any of these pages should
 not be world-readable. We're an open source project. It's not as if we
 have trade secrets or something.

 I have no problem, of course, with restricting *edit* privileges to
 those with accounts that have proven to be responsible adults.

 -- 
 Protege: What is this seething mass of parentheses?!
 Master: Your father's Lisp REPL. This is the language of a true
 hacker. Not as clumsy or random as C++; a language for a more
 civilized age.



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

2011-07-28 Thread Ken Wesson
On Thu, Jul 28, 2011 at 9:03 PM, pmbauer paul.michael.ba...@gmail.com wrote:
 That wasn't called for.

??

 Given Stu linked to the page (and is linked in the 1.3 release notes), it's
 reasonable to assume the permission error is merely a mistake and not some
 nefarious plot to withhold information from the Clojure community.

Did I say it was a nefarious plot?

The very fact that the web site is set up with a You cannot view this
page message dependent on your cookie-login and separate from the
low-level HTTP 403 error means that it's been set up to make some
information members-only. Whether that *particular* page on numerics
was intended to be members-only or not, the fact remains that
apparently some information there *is* intended to be members-only. It
is *that* that I am questioning.

Regardless, your that wasn't called for doesn't make much sense
since I merely stated a fact (I can't think of ...), another fact
(We're an open source project), another fact (we don't have trade
secrets), and one more fact (I have no problem, of course, with
...). If someone is taking mere *facts* (two of which are about *me*)
personally then I'd say there may be a problem but the problem isn't
mine. :)

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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

2011-07-28 Thread Alan Malloy
On Jul 28, 3:48 pm, Sam Aaron samaa...@gmail.com wrote:
 Hi there,

 I'm trying to create a fn which does the following:

 * returns a fn which takes an arbitrary number of args
 * calls a helper fn, passing the incoming args returning a vector of 
 alternating symbols and vals
 * creates a let form using the vector of alternating symbols and vals 
 returned by the helper fn as the bindings
 * contains some inner form that makes use of the bindings

 i.e. is it possible to implement something that allows the following to work:

 (defn binding-vec
   [args]
   ['size (count args)])

 (defn mk-dynamically-bound-fn
   [form]
   ;; returns a fn with sign [ args] which
   ;; uses binding-vec to create a the vec for
   ;; which a let statement binds around form
   )

 (def a (mk-dynamically-bound-fn '(+ size 10)))

 (a 1 2 3 4) ;= 14 (the number of args + 10)

 Please let me know if I'm being a bit crazy with the question. It's totally 
 possible that I'm barking up the wrong tree with this line of enquiry.

It's not clear how much of this is relevant to your actual problem, vs
the simple version you're posting here. If all you want to do is
automatically have the args counted for you, you could:

(defn wrap-counting [f]
  (fn [ args]
(apply f (count args) args)))

(def a (wrap-counting
(fn [size  args]
  (+ size 10

If you want something more general, that implicitly binds things for
you based on some code somewhere else (ew ew ew), then you need a
macro. This implementation is pretty gross; I suspect it could be
better, but you're trying to do something that seems weird to me.

(defn binding-vec []
  ['size '(count args)])

(defmacro magic-fn
  [ forms]
  `(fn [ ~'args]
 (let ~(binding-vec)
   ~@forms)))


user ((magic-fn (+ size 10)) 1 2)
12

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

2011-07-28 Thread Brent Millare
I have to chime in my solution to the problem, dj.

git://github.com/bmillare/dj.git

Acts more like a distro then a build tool though.

On Jul 28, 7:49 pm, Sean Corfield seancorfi...@gmail.com wrote:
 On Thu, Jul 28, 2011 at 2:23 PM, Michal B mibu.cloj...@gmail.com wrote:
  Why does it have to be so complicated to use libraries?

 I can't imagine it being much simpler than using Leiningen...

  To use libraries, you need to learn how to operate half a dozen build tools

 Just one: Leiningen. You can learn Cake or Maven instead if you want, I guess.

  and git because each library author distributes their library differently.

 Hmm, I haven't needed git for anything I'm not actually contributing
 to - with the exception of ClojureScript itself (and given the state
 of that, I think a build from source approach is acceptable for
 now).

  Right? There is no need to start a project with a bunch of template files
  and an elaborate directory structure and to start configuring dependencies
  and to rely on some magic happening that makes your program run.

 Well, you could download JAR files and then use the java command with
 the appropriate classpath and other arguments to run your script...
 but that seems more work to me than telling Leiningen which libraries
 I want and then telling Leiningen to run my -main function - with
 Leiningen handling all of the dependencies and the classpath stuff
 etc.

 I don't think I'd choose to not use Leiningen, even on a single file
 project that used no additional libraries:

 lein new thing
 cd thing
 vi s[tab][tab][tab]
 ...sling together some code... ZZ
 lein run -m thing.core

 Done!

 (I know, the heresy of using 'vi'... :)
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View --http://corfield.org/
 World Singles, LLC. --http://worldsingles.com/
 Railo Technologies, Inc. --http://www.getrailo.com/

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

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


Re: Digest for clojure@googlegroups.com - 14 Messages in 9 Topics

2011-07-28 Thread gaz jones
i would have to disagree with that. i hardly feel saddled with lein,
it frees me from thinking about any build stuff 95% of the time, and
as far as i know it is not the 'official' build system of clojure.
it's just extremely popular because it makes creating and building
projects so easy. you're free to use any tools you see fit to build
your projects -- i dont understand why having an awesome tool that
makes builds easy would in any way mean 'it will never go mainstream'?
O_o


On Thu, Jul 28, 2011 at 7:23 PM, JAX jayunit...@gmail.com wrote:
 I'm all for simplifying clojure.
 Even if Lein is great... If clojure is heavily biased and saddled by yet
 another framework/build system , it will never go mainstream.
 Jay Vyas
 MMSB
 UCHC
 On Jul 29, 2011, at 12:32 AM, clojure+nore...@googlegroups.com wrote:

   Today's Topic Summary

 Group: http://groups.google.com/group/clojure/topics

 format and printf can't be used with BigInt [2 Updates]
 clojure.contrib.command-line [2 Updates]
 Java 7 is out! [1 Update]
 Problem with ClojureScript and Node.js [2 Updates]
 better community docs: getting started [1 Update]
 dynamically generated let bindings [1 Update]
 Pair Coding over Skype [1 Update]
 passing value to functions [1 Update]
 Libraries and build management hell [3 Updates]

  Topic: format and printf can't be used with BigInt

 Sean Corfield seancorfi...@gmail.com Jul 28 04:28PM -0700 ^

 Chas has already pointed you at the rationale / discussion but I'm a
 Discussions about primitive arithmetic, not BigInteger arithmetic.

 I take it you didn't actually bother to read the page he linked to?
 Let me quote the relevant part for you since I know how averse you are
 to spending any time reading more than the first few lines of any
 material that people link to:

 * new clojure.lang.BigInt class
 * BigInts do not auto-reduce, and are contagious (akin to doubles)
 * BigInts will enable optimizations when fits in long
 * optimzations not yet in place
 * unlike BigInteger, BigInt has consistent hashcodes with Long,
 through range of long

 That'd be my position, yes. Also, backward compatibility: format works
 in 1.2 with (* 4000 4000 4000) so it should
 work in 1.3 with (* 4000 4000 4000).

 Kinda hard since that expression is not valid in 1.3 anyway:

 ArithmeticException integer overflow
 clojure.lang.Numbers.throwIntOverflow (Numbers.java:1374)

 So that code breaks explicitly in 1.3 and in many ways (format) is
 then the least of your worries...

 Might be worth opening a JIRA ticket for enhancing format, yes?
 You go ahead. I don't have an account there.

 Ah, that's right... the contributor process is too much work for
 you... Maybe one of the kind souls who've taken the time to go thru
 that process might feel inclined to open such a ticket for you? If
 they agree with your position, of course.
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/
 Railo Technologies, Inc. -- http://www.getrailo.com/

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



 Sean Corfield seancorfi...@gmail.com Jul 28 04:30PM -0700 ^

 I think one of the authors / core members needs to change the
 permissions. I have edit access on the parent page
 http://dev.clojure.org/display/doc/Enhanced+Primitive+Support and the
 sibling page http://dev.clojure.org/display/doc/Bit+Operations but,
 like you, don't have view access to the Numerics page.

 Sean




  Topic: clojure.contrib.command-line

 octopusgrabbus octopusgrab...@gmail.com Jul 28 03:37PM -0700 ^

 Are there any command-line examples or documentation other than what's
 up on clojure.org or ClojureDocs?

 I'm using

 (defn -main [ args]
 (with-command-line args
 Get csv file name
 [[in-file-name .csv input file name resultset.csv ]]
 [[in-file-name .csv input file name 1]]

 (println in-file-name:, in-file-name)

 If I specify a file name it does not get used. Only resultset.csv is
 used.

 tnx
 cmn



 Anthony Grimes disciplera...@gmail.com Jul 28 04:24PM -0700 ^

 command-line is deprecated in favor of tools.cli now.
 http://github.com/clojure/tools.cli



  Topic: Java 7 is out!

 Sean Corfield seancorfi...@gmail.com Jul 28 04:14PM -0700 ^

 So, what does it means for Clojure?

 It's not going to mean anything for a long time. Clojure still
 supports Java 5 so it is probably going to be years before Java 7 is
 mainstream enough that Clojure can _require_ it.
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/
 Railo Technologies, Inc. -- http://www.getrailo.com/

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



  Topic: Problem with ClojureScript and Node.js

 Anthony Grimes disciplera...@gmail.com Jul 28 03:32PM -0700 ^

 I'm all of a sudden getting this exact same 

Re: clojure.contrib.command-line

2011-07-28 Thread octopusgrabbus
Thanks. I'll switch over.

On Jul 28, 7:24 pm, Anthony Grimes disciplera...@gmail.com wrote:
 command-line is deprecated in favor of tools.cli 
 now.http://github.com/clojure/tools.cli

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

2011-07-28 Thread Luc Prefontaine
+1

We build a dozen projects here with a mix of Clojure and Java and we only use 
Leiningen.
The biggest effort was to consolidate the dependency libs pulled by Leiningen 
in our different
projects. You end up with multiple version of the same jar, a result of the 
dependency solving
done by Leiningen from the Maven world.

Copying the jar files pumped by Leiningen (cp */lib/*.jar) in a single folder 
and then pruning them
to retain the highest versions was the biggest challenge we faced.

All the libs we are referring to in dev, test and prod are stored in a single 
folder.
In dev we use Eclipse but have defined a number of user libraries to point to 
jars in this folder,
splitting them by purpose (Oracle, ...)

Since we want a stable slate we control the 75+ libs we monitor this closely 
and do not allow dependency resolution to
sc.. it up between different projects. If a newcomer is pulled by Leiningen in 
a project resulting from a change,
we just compare it with what we have and add it or not to it. It's definitively 
easier to do these days.

In Jan. 2009, when we went in prod, we we're not using Leiningen back then an 
we had around 140 libs,
all the dependencies were resolved/managed by hand... yurk !

Now the build process (we deliver our software AOT) is a piece of cake (no pun 
intended).
We defined a couple of generic scripts (lein-jar, lein-install) and call them 
from a simple
Bourne shell script to build the whole system.

We use Archiva internaly as a simple Maven repo so we can store the snapshots 
and stable
releases of our software and can refer to them in project.clj files.
It also caches all the external dependencies for us.

If we cannot find a maven artifact because an open source project did not push 
anything to Maven,
we build it from source and store it in Archiva et voilà ! We can then pull it 
from the Maven cloud
without changing anything.

Same thing if the jar exists apart from the Maven world. We just push it into 
Archiva.

Leiningen for us = less time to build, no more handcraft build scripts, ...

I cannot think about something simpler yet. If anyone has a suggestion, I am 
opened to it.

If I compare our build process and dependency management to other environments 
that I know (and I know a few),
it's still the most powerful thing I saw since sliced bread :)

BTWY, we use git for source control but that's a breeze compared to the hell we 
went through with the
build process before jumping in the Leiningen wagon.

Luc P.

On Thu, 28 Jul 2011 16:49:42 -0700
Sean Corfield seancorfi...@gmail.com wrote:

 On Thu, Jul 28, 2011 at 2:23 PM, Michal B mibu.cloj...@gmail.com
 wrote:
  Why does it have to be so complicated to use libraries?
 
 I can't imagine it being much simpler than using Leiningen...
 
  To use libraries, you need to learn how to operate half a dozen
  build tools
 
 Just one: Leiningen. You can learn Cake or Maven instead if you want,
 I guess.
 
  and git because each library author distributes their library
  differently.
 
 Hmm, I haven't needed git for anything I'm not actually contributing
 to - with the exception of ClojureScript itself (and given the state
 of that, I think a build from source approach is acceptable for
 now).
 
  Right? There is no need to start a project with a bunch of template
  files and an elaborate directory structure and to start configuring
  dependencies and to rely on some magic happening that makes your
  program run.
 
 Well, you could download JAR files and then use the java command with
 the appropriate classpath and other arguments to run your script...
 but that seems more work to me than telling Leiningen which libraries
 I want and then telling Leiningen to run my -main function - with
 Leiningen handling all of the dependencies and the classpath stuff
 etc.
 
 I don't think I'd choose to not use Leiningen, even on a single file
 project that used no additional libraries:
 
 lein new thing
 cd thing
 vi s[tab][tab][tab]
 ...sling together some code... ZZ
 lein run -m thing.core
 
 Done!
 
 (I know, the heresy of using 'vi'... :)



-- 
Luc P.


The rabid Muppet

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

2011-07-28 Thread Mark Rathwell
The problem with jar downloads as the default distribution method is that
non-Java people, and even plenty of Java people, seem to have problems
consistently setting classpaths correctly.  Seems much more straightforward
to just have lein take care of that for you.

As for complicated installation instructions, libraries meant to be used in
lein have installation instructions that generally look like this:

[compojure 0.6.4]

The other alternative is to have environment package managers like Python
with easy_install and Ruby with gems.  Then you need to bring virtualenv or
Ruby version manager into the picture to use different versions of the same
library in different apps.  The Java world has tended towards dependencies
being coupled with the application, rather than the environment.  There are
good arguments for both sides, but either way, I don't think it can get much
easier than lein.

 - Mark


On Thu, Jul 28, 2011 at 5:23 PM, Michal B mibu.cloj...@gmail.com wrote:

 Why does it have to be so complicated to use libraries?

 To use libraries, you need to learn how to operate half a dozen build tools
 and git because each library author distributes their library differently.
 If figuring out how to install an IDE with clojure wasn't bad enough, now
 you need to figure out how to install and use each of the tools with it.

 I'm not saying build tools are useless, on the contrary. It's just that
 most of the time, we want to sling two or three libraries together and code.
 Right? There is no need to start a project with a bunch of template files
 and an elaborate directory structure and to start configuring dependencies
 and to rely on some magic happening that makes your program run.

 I think we over-engineered the build process to support the big projects
 and forgot the common case. Most projects are simple.

 Let's remove this incidental complexity by returning to simplicity. Keep
 the build tools for the heavyweights and get back in touch with your
 libraries.

 Instead of having a complicated installation guide for your library, have a
 Download section in your site. Have there a link to the latest stable
 version of your library as a jar file or, if necessary, a zip file with your
 jar and and all the necessary dependency jars (sane library authors won't
 mind). For a zip, shortly describe what's in it - library names and
 versions, and links to their sites. That's it.

 I think most JVM users know or can quickly figure out how to take jars and
 put them in their project's classpath. It's simple to do with all IDEs (or
 without one) and there is no need to learn or install additional software or
 edit configuration files. Starter scripts should include in the classpath
 all jars in the current directory or jars/ directory by default.

 Instead of managing libraries inside a dependencies file, you do it
 directly with the jar files. If the project gets too big, bring in the build
 tools.

 What are your thoughts on this issue?

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

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

Re: clojure.contrib.command-line

2011-07-28 Thread OGINO Masanori
(defn -main [ args]
 (with-command-line args
   Get csv file name
   [[in-file-name .csv input file name  resultset.csv ]]
  (println in-file-name:, in-file-name)))

The second vector of vector seems unnecessary.

Or tools.cli way:

(ns foo.main
  (:gen-class)
  (:use [clojure.tools.cli :only (cli optional)]))

(defn parse-opts
  [args]
  (cli args
   (optional [--in-file-name
  .csv input file
  :default resultset.csv]
 identity)))

(defn -main
  [ args]
  (let [opts (parse-opts args)]
(println in-file-name: (:in-file-name opts

It might be verbose but I think it is more descriptive than
with-command-line one.
However, I'd like more documents and examples about tools.cli.

-- 
Name:  OGINO Masanori (荻野 雅紀)
E-mail: masanori.og...@gmail.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


  1   2   >