Re: Namespaced symbols, and errors

2013-03-09 Thread Gary Verhaegen
The reader basically transforms :: into :namespace/, which means that
the remaining part must be an unqualified symbol (i.e. no / in it).
The character / is not allowed in unqualified symbols. As the
documentation [1] says : "'/' has special meaning, it can be used once
in the middle of a symbol to separate the namespace from the name,
e.g. my-namespace/foo. '/' by itself names the division function."

Your notation ::junk/junk, assuming your type in namespace
my.namespace.junk, would result in the keyword
:my.namespace.junk/junk/junk, which is invalid (two /'s). Hence the
implied restriction that ::symbol cannot contain a / character.

I'm not really sure what you mean about aliases. Keywords stand by
themselves (they are literals that evaluate to themselves), they are
not aliases for something else.

[1] http://clojure.org/reader

On 8 March 2013 16:56, nick rothwell  wrote:
> Typing the following at a REPL:
>
> (str ::junk/junk)
>
> (where there's no alias for junk) gives me:
>
> RuntimeException Invalid token: ::junk/junk
> clojure.lang.Util.runtimeException (Util.java:219)
> RuntimeException Unmatched delimiter: )  clojure.lang.Util.runtimeException
> (Util.java:219)
>
> A couple of things:
>
> (i) Invalid token seems a bit curt: doesn't it mean something like "no such
> namespace alias"?
> (ii) A complete aside, but: the interactive REPL obviously isn't
> disregarding the rest of the line when it gets a token error.
>
> Another aside: why does Clojure require "::" for aliases but only ":" for
> namespace-qualified keywords? Under what circumstance would I use :junk/junk
> in any way other than to mean ::junk/junk (or :my.namespace.junk/junk, given
> the appropriate alias)?
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Windows Installation

2013-03-09 Thread BJG145
Perhaps this general anti-Windows attitude is what Windows-based newcomers 
to Clojure find off-putting... 


On Saturday, March 9, 2013 3:55:59 AM UTC, James Ashley wrote:
>
> Since I've seen a few recent posts about this experience, I figured I'd 
> share mine:
>
> 0a) Install cygwin. I don't understand how any programmer stuck using 
> windows can get by without it
> 1) Install the Oracle JDK
> 1a) Add javac to my PATH (I added a symbolic link to javac.exe inside 
> cygwin in a directory that was already in my 
> PATH: ~/bin)
> 2) Download the lein "install" script as text from the leiningen home page.
> 3) Copy it over to my cygwin directory
> 4) Search/replace to replace the HTML entities with the real thing. I 
> think this was a matter of & and >
> 5) It was already executable, so just run it (naming it lein.sh rather 
> than lein.bat was important). I got errors about
> certificates and permissions. They mentioned instructions about setting up 
> an environment variable (something
> about something like `export DOWNLOAD="curl --trusting %1"`...that wasn't 
> it, but it was along the same lines).
> I believe that it's some weirdness in the account settings (I have other 
> issues along the same lines in totally 
> unrelated packages), but I suppose I could have just installed some 
> horrible virus. Oh, well.
> 6) Create a new project
> 7) Change project.clj to use clojure 1.5
> 8) `lein repl` inside cygwin didn't work correctly. CLASSPATH was all 
> windows-style, which confused cygwin. So
> basic clojure.core pieces weren't found.
> 8a) I suspect I could have set up, say, powershell, to make this work. But 
> that's stupid, and I don't have time
> to waste on it.
> 9) nrepl-jack-in inside emacs worked fine.
> 9a) I'm using an init.el from other systems that already have clojure set 
> up. But there isn't anything fancy or
> special or customized about it. Just standard configuration stuff that 
> I've found on bare-minimal blog posts
> 10) Add a symlink to lein in ~/bin.
>
> I guess that probably looks big and scary. Windows users are used to a 
> pretty GUI that they ignore and click
> "Next" a lot. I dont have a lot of sympathy.
>
> I haven't done anything meaningful here at all. But the bare-bones part of 
> the installation process Just Worked.
>
> Thank you *so* much to all the people who have worked so hard to make this 
> as simple as it is!
>
> Respectfully,
> James
>
>

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




Re: Windows Installation

2013-03-09 Thread Jonathan Fischer Friberg
My experience:

1. Download lein.bat
2. Run it

Jonathan



On Sat, Mar 9, 2013 at 10:23 AM, BJG145  wrote:

> Perhaps this general anti-Windows attitude is what Windows-based newcomers
> to Clojure find off-putting...
>
>
> On Saturday, March 9, 2013 3:55:59 AM UTC, James Ashley wrote:
>>
>> Since I've seen a few recent posts about this experience, I figured I'd
>> share mine:
>>
>> 0a) Install cygwin. I don't understand how any programmer stuck using
>> windows can get by without it
>> 1) Install the Oracle JDK
>> 1a) Add javac to my PATH (I added a symbolic link to javac.exe inside
>> cygwin in a directory that was already in my
>> PATH: ~/bin)
>> 2) Download the lein "install" script as text from the leiningen home
>> page.
>> 3) Copy it over to my cygwin directory
>> 4) Search/replace to replace the HTML entities with the real thing. I
>> think this was a matter of & and >
>> 5) It was already executable, so just run it (naming it lein.sh rather
>> than lein.bat was important). I got errors about
>> certificates and permissions. They mentioned instructions about setting
>> up an environment variable (something
>> about something like `export DOWNLOAD="curl --trusting %1"`...that wasn't
>> it, but it was along the same lines).
>> I believe that it's some weirdness in the account settings (I have other
>> issues along the same lines in totally
>> unrelated packages), but I suppose I could have just installed some
>> horrible virus. Oh, well.
>> 6) Create a new project
>> 7) Change project.clj to use clojure 1.5
>> 8) `lein repl` inside cygwin didn't work correctly. CLASSPATH was all
>> windows-style, which confused cygwin. So
>> basic clojure.core pieces weren't found.
>> 8a) I suspect I could have set up, say, powershell, to make this work.
>> But that's stupid, and I don't have time
>> to waste on it.
>> 9) nrepl-jack-in inside emacs worked fine.
>> 9a) I'm using an init.el from other systems that already have clojure set
>> up. But there isn't anything fancy or
>> special or customized about it. Just standard configuration stuff that
>> I've found on bare-minimal blog posts
>> 10) Add a symlink to lein in ~/bin.
>>
>> I guess that probably looks big and scary. Windows users are used to a
>> pretty GUI that they ignore and click
>> "Next" a lot. I dont have a lot of sympathy.
>>
>> I haven't done anything meaningful here at all. But the bare-bones part
>> of the installation process Just Worked.
>>
>> Thank you *so* much to all the people who have worked so hard to make
>> this as simple as it is!
>>
>> Respectfully,
>> James
>>
>>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Namespaced symbols, and errors

2013-03-09 Thread Bronsa
Gary, ::foo/bar is valid syntax if foo is a valid namespace alias.

Try:
(alias 'foo 'clojure.core)
::foo/bar
Il giorno 09/mar/2013 09.36, "Gary Verhaegen"  ha
scritto:

> The reader basically transforms :: into :namespace/, which means that
> the remaining part must be an unqualified symbol (i.e. no / in it).
> The character / is not allowed in unqualified symbols. As the
> documentation [1] says : "'/' has special meaning, it can be used once
> in the middle of a symbol to separate the namespace from the name,
> e.g. my-namespace/foo. '/' by itself names the division function."
>
> Your notation ::junk/junk, assuming your type in namespace
> my.namespace.junk, would result in the keyword
> :my.namespace.junk/junk/junk, which is invalid (two /'s). Hence the
> implied restriction that ::symbol cannot contain a / character.
>
> I'm not really sure what you mean about aliases. Keywords stand by
> themselves (they are literals that evaluate to themselves), they are
> not aliases for something else.
>
> [1] http://clojure.org/reader
>
> On 8 March 2013 16:56, nick rothwell  wrote:
> > Typing the following at a REPL:
> >
> > (str ::junk/junk)
> >
> > (where there's no alias for junk) gives me:
> >
> > RuntimeException Invalid token: ::junk/junk
> > clojure.lang.Util.runtimeException (Util.java:219)
> > RuntimeException Unmatched delimiter: )
>  clojure.lang.Util.runtimeException
> > (Util.java:219)
> >
> > A couple of things:
> >
> > (i) Invalid token seems a bit curt: doesn't it mean something like "no
> such
> > namespace alias"?
> > (ii) A complete aside, but: the interactive REPL obviously isn't
> > disregarding the rest of the line when it gets a token error.
> >
> > Another aside: why does Clojure require "::" for aliases but only ":" for
> > namespace-qualified keywords? Under what circumstance would I use
> :junk/junk
> > in any way other than to mean ::junk/junk (or :my.namespace.junk/junk,
> given
> > the appropriate alias)?
> >
> > --
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> your
> > first post.
> > To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an
> > email to clojure+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Windows Installation

2013-03-09 Thread BJG145
As long as you have wget, that works fine. Only problem I've found so far 
is that "lein new app" followed by "lein check" throws an error, but it 
looks like people are on the case.

https://github.com/technomancy/leiningen/issues/863



On Saturday, March 9, 2013 11:24:04 AM UTC, Jonathan Fischer Friberg wrote:
>
> My experience:
>
> 1. Download lein.bat
> 2. Run it
>
> Jonathan
>
>
>
> On Sat, Mar 9, 2013 at 10:23 AM, BJG145 
> > wrote:
>
>> Perhaps this general anti-Windows attitude is what Windows-based 
>> newcomers to Clojure find off-putting... 
>>
>>
>> On Saturday, March 9, 2013 3:55:59 AM UTC, James Ashley wrote:
>>>
>>> Since I've seen a few recent posts about this experience, I figured I'd 
>>> share mine:
>>>
>>> 0a) Install cygwin. I don't understand how any programmer stuck using 
>>> windows can get by without it
>>> 1) Install the Oracle JDK
>>> 1a) Add javac to my PATH (I added a symbolic link to javac.exe inside 
>>> cygwin in a directory that was already in my 
>>> PATH: ~/bin)
>>> 2) Download the lein "install" script as text from the leiningen home 
>>> page.
>>> 3) Copy it over to my cygwin directory
>>> 4) Search/replace to replace the HTML entities with the real thing. I 
>>> think this was a matter of & and >
>>> 5) It was already executable, so just run it (naming it lein.sh rather 
>>> than lein.bat was important). I got errors about
>>> certificates and permissions. They mentioned instructions about setting 
>>> up an environment variable (something
>>> about something like `export DOWNLOAD="curl --trusting %1"`...that 
>>> wasn't it, but it was along the same lines).
>>> I believe that it's some weirdness in the account settings (I have other 
>>> issues along the same lines in totally 
>>> unrelated packages), but I suppose I could have just installed some 
>>> horrible virus. Oh, well.
>>> 6) Create a new project
>>> 7) Change project.clj to use clojure 1.5
>>> 8) `lein repl` inside cygwin didn't work correctly. CLASSPATH was all 
>>> windows-style, which confused cygwin. So
>>> basic clojure.core pieces weren't found.
>>> 8a) I suspect I could have set up, say, powershell, to make this work. 
>>> But that's stupid, and I don't have time
>>> to waste on it.
>>> 9) nrepl-jack-in inside emacs worked fine.
>>> 9a) I'm using an init.el from other systems that already have clojure 
>>> set up. But there isn't anything fancy or
>>> special or customized about it. Just standard configuration stuff that 
>>> I've found on bare-minimal blog posts
>>> 10) Add a symlink to lein in ~/bin.
>>>
>>> I guess that probably looks big and scary. Windows users are used to a 
>>> pretty GUI that they ignore and click
>>> "Next" a lot. I dont have a lot of sympathy.
>>>
>>> I haven't done anything meaningful here at all. But the bare-bones part 
>>> of the installation process Just Worked.
>>>
>>> Thank you *so* much to all the people who have worked so hard to make 
>>> this as simple as it is!
>>>
>>> Respectfully,
>>> James
>>>
>>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Model-View-Controller in Clojure?

2013-03-09 Thread edward
So I understand that Clojure's data structures are immutable but I am not 
clear how that works with MVC.

So I have a view that displays a model. Other processes change that model 
and the View presents those changes.

However it's not clear to me how that would work with an immutable model.

Obviously I can't pass the model into the View, have the view store a 
reference to it and each time it's called on to render the model, do so. 
The model is immutable.

So I could have a global variable which points to the model, and whenever I 
'change' the model I re-point it to the updated version. Obviously the view 
would have to reference that global. This just smells bad. And would get 
worse for each model and view you needed in your application.

I suppose you could maintain some global map of models, but that doesn't 
look nice either, it's not that much different from having a pile of global 
models.

This must be a solved problem surely? Could someone point me to the 
solution please? Swing or Quil based would be fine but I assume it must be 
generally applicable.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Model-View-Controller in Clojure?

2013-03-09 Thread Jim - FooBar();
You need to store your model in a ref-type (atom,agent,or ref), and 
attach a watcher on it (a fn which is responsible for updating the 
view). Now, 'mutating' your model will trigger a View update...piece of 
cake :)


example:

(def board-history
"Log of the state of a game."
(atom []))

(defn log-board
"The logging function for the board ref. Will conj every new board-state 
into a vector."

[dest k r old n]
 (when-not (= n old)
  (swap! dest conj n)))

(def current-chessItems
"This is list that keeps track of moving chess pieces. Is governed by an 
atom and it changes after every move.
 All changes are being logged to 'board-history'. Starts off as nil but 
we can always get the initial board arrangement from core."

 (-> (atom nil)
   (add-watch  :log (partial core/log-board core/board-history)

HTH,

Jim

ps: my example does not involve GUI, but you get the idea...it it 
trivial to change the code so that it 'repaints' the canvas with the new 
board instead of conjing it



On 09/03/13 14:11, edw...@kenworthy.info wrote:
So I understand that Clojure's data structures are immutable but I am 
not clear how that works with MVC.


So I have a view that displays a model. Other processes change that 
model and the View presents those changes.


However it's not clear to me how that would work with an immutable model.

Obviously I can't pass the model into the View, have the view store a 
reference to it and each time it's called on to render the model, do 
so. The model is immutable.


So I could have a global variable which points to the model, and 
whenever I 'change' the model I re-point it to the updated version. 
Obviously the view would have to reference that global. This just 
smells bad. And would get worse for each model and view you needed in 
your application.


I suppose you could maintain some global map of models, but that 
doesn't look nice either, it's not that much different from having a 
pile of global models.


This must be a solved problem surely? Could someone point me to the 
solution please? Swing or Quil based would be fine but I assume it 
must be generally applicable.

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

To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Model-View-Controller in Clojure?

2013-03-09 Thread Jim - FooBar();
also see this for a discussion about why the need for design patterns 
almost disappears in Clojure:

http://stackoverflow.com/questions/8902113/clojure-model-view-controller-mvc-design

Jim

On 09/03/13 14:24, Jim - FooBar(); wrote:
You need to store your model in a ref-type (atom,agent,or ref), and 
attach a watcher on it (a fn which is responsible for updating the 
view). Now, 'mutating' your model will trigger a View update...piece 
of cake :)


example:

(def board-history
"Log of the state of a game."
(atom []))

(defn log-board
"The logging function for the board ref. Will conj every new 
board-state into a vector."

[dest k r old n]
 (when-not (= n old)
  (swap! dest conj n)))

(def current-chessItems
"This is list that keeps track of moving chess pieces. Is governed by 
an atom and it changes after every move.
 All changes are being logged to 'board-history'. Starts off as nil 
but we can always get the initial board arrangement from core."

 (-> (atom nil)
   (add-watch  :log (partial core/log-board core/board-history)

HTH,

Jim

ps: my example does not involve GUI, but you get the idea...it it 
trivial to change the code so that it 'repaints' the canvas with the 
new board instead of conjing it



On 09/03/13 14:11, edw...@kenworthy.info wrote:
So I understand that Clojure's data structures are immutable but I am 
not clear how that works with MVC.


So I have a view that displays a model. Other processes change that 
model and the View presents those changes.


However it's not clear to me how that would work with an immutable 
model.


Obviously I can't pass the model into the View, have the view store a 
reference to it and each time it's called on to render the model, do 
so. The model is immutable.


So I could have a global variable which points to the model, and 
whenever I 'change' the model I re-point it to the updated version. 
Obviously the view would have to reference that global. This just 
smells bad. And would get worse for each model and view you needed in 
your application.


I suppose you could maintain some global map of models, but that 
doesn't look nice either, it's not that much different from having a 
pile of global models.


This must be a solved problem surely? Could someone point me to the 
solution please? Swing or Quil based would be fine but I assume it 
must be generally applicable.

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

To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, 
send an email to clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.






--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Namespaced symbols, and errors

2013-03-09 Thread Gary Verhaegen
On 9 March 2013 12:27, Bronsa  wrote:
> Gary, ::foo/bar is valid syntax if foo is a valid namespace alias.
>
> Try:
> (alias 'foo 'clojure.core)
> ::foo/bar

I did not know that. Is that documented anywhere ? I was under the
impression that :: was just intended as a shorthand to create "local"
keywords so as to avoid clashing with other namespaces; that it does
namespace resolution looks to me more like a side-effect of symbols
and keywords sharing the same underlying implementation.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Windows Installation

2013-03-09 Thread Brent Millare
Does anyone see value in a wizard for lein? Does anyone know how to write a 
wizard, preferably with a scripting language, or xml, rather than c++? And 
can you alter system variables from within the wizard?

On Saturday, March 9, 2013 8:18:44 AM UTC-5, BJG145 wrote:
>
> As long as you have wget, that works fine. Only problem I've found so far 
> is that "lein new app" followed by "lein check" throws an error, but it 
> looks like people are on the case.
>
> https://github.com/technomancy/leiningen/issues/863
>
>
>
> On Saturday, March 9, 2013 11:24:04 AM UTC, Jonathan Fischer Friberg wrote:
>>
>> My experience:
>>
>> 1. Download lein.bat
>> 2. Run it
>>
>> Jonathan
>>
>>
>>
>> On Sat, Mar 9, 2013 at 10:23 AM, BJG145  wrote:
>>
>>> Perhaps this general anti-Windows attitude is what Windows-based 
>>> newcomers to Clojure find off-putting... 
>>>
>>>
>>> On Saturday, March 9, 2013 3:55:59 AM UTC, James Ashley wrote:

 Since I've seen a few recent posts about this experience, I figured I'd 
 share mine:

 0a) Install cygwin. I don't understand how any programmer stuck using 
 windows can get by without it
 1) Install the Oracle JDK
 1a) Add javac to my PATH (I added a symbolic link to javac.exe inside 
 cygwin in a directory that was already in my 
 PATH: ~/bin)
 2) Download the lein "install" script as text from the leiningen home 
 page.
 3) Copy it over to my cygwin directory
 4) Search/replace to replace the HTML entities with the real thing. I 
 think this was a matter of & and >
 5) It was already executable, so just run it (naming it lein.sh rather 
 than lein.bat was important). I got errors about
 certificates and permissions. They mentioned instructions about setting 
 up an environment variable (something
 about something like `export DOWNLOAD="curl --trusting %1"`...that 
 wasn't it, but it was along the same lines).
 I believe that it's some weirdness in the account settings (I have 
 other issues along the same lines in totally 
 unrelated packages), but I suppose I could have just installed some 
 horrible virus. Oh, well.
 6) Create a new project
 7) Change project.clj to use clojure 1.5
 8) `lein repl` inside cygwin didn't work correctly. CLASSPATH was all 
 windows-style, which confused cygwin. So
 basic clojure.core pieces weren't found.
 8a) I suspect I could have set up, say, powershell, to make this work. 
 But that's stupid, and I don't have time
 to waste on it.
 9) nrepl-jack-in inside emacs worked fine.
 9a) I'm using an init.el from other systems that already have clojure 
 set up. But there isn't anything fancy or
 special or customized about it. Just standard configuration stuff that 
 I've found on bare-minimal blog posts
 10) Add a symlink to lein in ~/bin.

 I guess that probably looks big and scary. Windows users are used to a 
 pretty GUI that they ignore and click
 "Next" a lot. I dont have a lot of sympathy.

 I haven't done anything meaningful here at all. But the bare-bones part 
 of the installation process Just Worked.

 Thank you *so* much to all the people who have worked so hard to make 
 this as simple as it is!

 Respectfully,
 James

  -- 
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with 
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@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 unsubscribe from this group and stop receiving emails from it, send 
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Namespaced symbols, and errors

2013-03-09 Thread nick rothwell
I understand that ::foo is a keyword bound into the local namespace.

I also understand (according to the docs) that

:my.namespace/foo is the keyword foo in the namespace my.namespace.

::nsalias/foo is the keyword foo in the namespace my.namespace if I've 
aliased my.namespace to nsalias.

But also: 

::my.namespace/foo is equivalent to :my.namespace/foo (as a convenience, I 
guess).

:nsalias/foo is not the same as ::nsalias/foo - in fact, I'm not sure what 
:nsalias/foo is - a call on str yields ":nsalias/foo".

This last point is the one that's confusing me.

On Saturday, March 9, 2013 8:36:30 AM UTC, Gary Verhaegen wrote:
>
> The reader basically transforms :: into :namespace/, which means that 
> the remaining part must be an unqualified symbol (i.e. no / in it). 
> The character / is not allowed in unqualified symbols. As the 
> documentation [1] says : "'/' has special meaning, it can be used once 
> in the middle of a symbol to separate the namespace from the name, 
> e.g. my-namespace/foo. '/' by itself names the division function." 
>
> Your notation ::junk/junk, assuming your type in namespace 
> my.namespace.junk, would result in the keyword 
> :my.namespace.junk/junk/junk, which is invalid (two /'s). Hence the 
> implied restriction that ::symbol cannot contain a / character. 
>
> I'm not really sure what you mean about aliases. Keywords stand by 
> themselves (they are literals that evaluate to themselves), they are 
> not aliases for something else. 
>
> [1] http://clojure.org/reader 
>
> On 8 March 2013 16:56, nick rothwell > 
> wrote: 
> > Typing the following at a REPL: 
> > 
> > (str ::junk/junk) 
> > 
> > (where there's no alias for junk) gives me: 
> > 
> > RuntimeException Invalid token: ::junk/junk 
> > clojure.lang.Util.runtimeException (Util.java:219) 
> > RuntimeException Unmatched delimiter: ) 
>  clojure.lang.Util.runtimeException 
> > (Util.java:219) 
> > 
> > A couple of things: 
> > 
> > (i) Invalid token seems a bit curt: doesn't it mean something like "no 
> such 
> > namespace alias"? 
> > (ii) A complete aside, but: the interactive REPL obviously isn't 
> > disregarding the rest of the line when it gets a token error. 
> > 
> > Another aside: why does Clojure require "::" for aliases but only ":" 
> for 
> > namespace-qualified keywords? Under what circumstance would I use 
> :junk/junk 
> > in any way other than to mean ::junk/junk (or :my.namespace.junk/junk, 
> given 
> > the appropriate alias)? 
> > 
> > -- 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@googlegroups.com 
> > Note that posts from new members are moderated - please be patient with 
> your 
> > first post. 
> > To unsubscribe from this group, send email to 
> > clojure+u...@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 unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to clojure+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Windows Installation

2013-03-09 Thread BJG145
...I dunno. As a Windows-addict-newbie, James has a valid point when he 
says that Windows users expect to be able to just "click next a lot", and I 
don't think that will get you very far with Clojure. The tools like 
Leiningen are pretty darn good, and not that difficult really. Simple, 
clear documentation is starting to emerge, and the most valuable next step 
would just be to get greater visibility for it.

On Saturday, March 9, 2013 4:28:47 PM UTC, Brent Millare wrote:
>
> Does anyone see value in a wizard for lein? 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Windows Installation

2013-03-09 Thread BJG145
(...I have to say that, from reading the above, Cygwin sounds like a 
nighmare and I certainly won't be troubling it...! If you want Linux on a 
Windows machine, Virtualbox sounds like a safer bet...)

On Saturday, March 9, 2013 8:31:56 PM UTC, BJG145 wrote:
>
> ...I dunno. As a Windows-addict-newbie, James has a valid point when he 
> says that Windows users expect to be able to just "click next a lot", and I 
> don't think that will get you very far with Clojure. The tools like 
> Leiningen are pretty darn good, and not that difficult really. Simple, 
> clear documentation is starting to emerge, and the most valuable next step 
> would just be to get greater visibility for it.
>
> On Saturday, March 9, 2013 4:28:47 PM UTC, Brent Millare wrote:
>>
>> Does anyone see value in a wizard for lein? 
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: clojure.core/protocol?

2013-03-09 Thread vemv
(defprototocol P ...) does two things: define a map on the current 
namespace, and generate an interface on a package that will have the same 
name as the current namespace.

(defprotocol P (x [_])) ;; -> P
(class P) ;; -> clojure.lang.PersistentArrayMap
(:on-interface P) ;; -> user.P
(.isInterface user.P) ;; true

With this knowledge, we can use heuristics to roll our own version of 
protocol?:

(defn protocol?
"If the argument is one of the artifacts emitted by defprotocol,
return its value (which will evaluate to logical true), else nil."
  [x]
  (cond
   (map? x)
   (if-let [i (:on-interface x)]
 (and (class? i) (.isInterface i) x))
   (class? x)
   (let [name (.getName x)
  protocol-reification-sym ;; "user.X" -> 'user/X
  (as-> n name
  (vec n)
  (assoc n (.lastIndexOf n ".") \/)
  (apply str n)
  (symbol n))]
 (try
   (if (:on-interface (eval protocol-reification-sym))
 (-> x .getName symbol eval))
   (catch Exception e)

(do (defprotocol P)
(map protocol? [(:on-interface P) P]))

As for why is clojure.core/protocol? private, my guess is there can't be a 
100% reliable way from telling Clojure-emitted maps/interfaces from regular 
maps/interfaces. Or in any case, protocol? hasn't a lot of use cases.

Hope it helps!

Victor

On Friday, March 8, 2013 1:53:52 PM UTC+1, solussd wrote:
>
> It appears that, as of Clojure 1.5, clojure.core/protocol? is private. 
> Does anyone know the reason for this? What's the proper way to tell if 
> something is a protocol?
>
> ---
> Joseph Smith
> j...@uwcreations.com 
> @solussd
>
>
>
>
>
>  
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to ensure consistency when accessing database?

2013-03-09 Thread vemv
On the Clojure side the only thing you can do is to serialize writes to the 
resouce (the db connection). So at most one thread can be performing an 
update operation, at a given time. You can increase concurrency by 
mantaining "read-only" db connections (most likely in an 
ad-hoc/by-convention manner) - they can be safely shared across threads.

As Akhil points out, agents are a good option for implementing serialized 
access. This doesn't scale very well though, particularly across machines.

A proper solution must necessarily come from using the transactionality 
provided by the database (if any - I'm not familiar with Mongo).

Finally, it's worth pointing out that implementing queues as database 
tables/objects is most likely a bad idea. There are better tools for the 
job.

On Wednesday, March 6, 2013 5:36:13 PM UTC+1, bruce li wrote:
>
> Hello,
> I'm working on a piece of code that uses congomongo to access mongodb. 
> What I want to implement is to use one collection of the DB as a 
> queue(let's say, it's called "task").
>
> Using congomongo, it's easy to fetch a task that is of status :queue : 
> (def t (fetch-one :task :where {:status :queue})), 
> and also it's simple to update it: (update! :task t (assoc t :status 
> :running))
>
> But how to make a safe and consistent "dequeue" operation in concurrent 
> context? A naive dequeue should look like this:
>
> (let [t (fetch-one:task :where {:status :queue})]
>   (update! :task t (assoc t :status :running))
>   t)
>
> But taking concurrency into consideration, this implementation is 
> error-prone, at least from my point of view. Consider this:
>
> When 2 threads are fetching the task, it's very likely that the task is 
> fetched twice using the previous piece of code and they would be executed 
> twice.
>
> Do we have something like transaction? Something that will enforce the 
> "fetch-one" and "update!" statement are both executed before another 
> “fetch-one" operation is adopted?
>
> What I can think of is to use an agent. And my code looks like this:
>
> (def db-agent (agent nil))
> (defn dequeue []
>   (letfn [(do-dequeue [da]
> (let [task (mongo/fetch-one :task :where {:status :queue})]
>   (when task
> (mongo/update! :task feed (assoc task :status :running)))
>   task))]
> (send db-agent do-dequeue)
> @db-agent)))
>
> However, I still doubt the correctness of this solution. Right before the 
> @db-agent is called, won't another thread call "dequeue", which will 
> involve another "send” and change the value of db-agent? 
>
> I'm wondering if anyone can help. Thanks.
>
>
>
>

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




Re: what is a good book about Java queues?

2013-03-09 Thread vemv
Two queues cover the 80% case: an implementation of BlockingQueue (array, 
linked list backed), and clojure.lang.PersistentQueue.

The former provides concurrency semantics: there are no 'stale values' 
issues associated to mutation, and you can choose whether your reads/writes 
are blocking (which is important, given that typically one wants bounded 
size queues) or not.

The latter, just like the other persistent data structures, must be wrapped 
in a reference type in order to express change.

There are also thread-unsafe queues (i.e. need locking), and 
SynchronousQueue, which while it's not actually a queue (it can never store 
a single element!), is a very handy reference type - like Clojure promises 
but reusable.

On Thursday, March 7, 2013 9:32:38 PM UTC+1, larry google groups wrote:
>
>
> At some point on this mailist, someone suggested that to best understand 
> concurrency in Java, once should read: 
>
> Java Concurrency In Practice
>
>
> http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601/ref=sr_1_1?ie=UTF8&qid=1362688125&sr=8-1&keywords=java+concurrency+in+practice
>
> So I read it, but I am surprised that it says fairly little about working 
> with queues. I am curious if anyone would recommend a book for learning 
> more about working with Java queues? 
>
> I suffer the problem that I learned Clojure without first learning Java, 
> and Clojure leans on Java rather heavily, so I am now trying to come up to 
> speed on Java. 
>
>
>
>
>
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Newbie requesting review

2013-03-09 Thread Craig Ching
Hi all,

I wrote some code to generate some example data for a web ui that I'm 
working on and I was wondering if I could get some advice about it to 
ensure I'm on the right track in my clojure learning.  Basically its a very 
simple program that generates a number of JSON files that contain 
information, I've modeled the problem as a teacher-student relationship 
where each teacher is a file that contains data about a number of students. 
 The inputs to the main function (gen) takes the number of teachers and the 
number of students per teacher and generates sample data that can be 
consumed by the web ui.  What I'm looking for is:

1. Am I doing things the "clojure way", is my program idiomatic?  If not, 
advice is appreciated.
2. Specifically the main function in the program (make-student-factory) 
I've modeled as a closure and I feel like there is probably a better way to 
do it, what are your thoughts on that?

Here is the code:

(ns teachers.core
  (:require [clj-json.core :as json]))

(defn- gen-items-json
  [students]
  (json/generate-string {"timestamp" 5000
 "items" students
 "identifier" "id"
 "label" "id"
 "rc" 200
 "msg" "Data retrieved successfully."}))

(defn- make-student
  [teacherName
   studentName
   age] {"id" (str teacherName "!" studentName)
   "TeacherName" teacherName
   "StudentName" studentName
   "age" age})

(defn- make-name [prefix n] (str prefix n))
(defn- make-teacher-name [n] (make-name "TEACHER" n))
(defn- make-student-name [n] (make-name "STUDENT" n))

(defn- make-student-factory
  "Returns a function allowing you to create a number
   of student definitions for the given teacher."
  [teacherName]
  (fn [n]
(make-student teacherName (make-student-name n) 0)))

(defn- make-students
  [teacherName n]
  (let [fac (make-student-factory teacherName)]
(map fac (range n

(defn- spit-json
  [teacherName n]
  (println "Creating " n " students for teacher: " teacherName)
  (spit (str teacherName ".json")
(gen-items-json (make-students teacherName n

(defn gen
  [numTeachers numStudents]
  (doseq [teacherName (map make-teacher-name (range numTeachers))]
(spit-json teacherName numStudents)))

Thanks for any comments!

Cheers,
Craig

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: :use an entire namespace full of protocols or stick with :require?

2013-03-09 Thread Korny Sietsma
[reviving a slightly old thread]
Note that as of clojure 1.4 you can also do:
  (:require foo.bar :refer :all)
in fact from comments I've seen elsewhere there is a general intention to
remove :use entirely?

It'd be good to have some clarity on this.  The vast majority of code
samples use :use, some with :only.  The docstring for ns doesn't even
mention :refer! The clojure cheatsheet points to
http://clojuredocs.org/clojure_core/clojure.core/ns which _does_ have the
new syntax, in the last couple of examples; and it links to the tutorial at
http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.htmlwhich
uses 'use' throughout, except for an easily missable update half way
through that says to use :refer.

So, to what extent are people actually deprecating :use ?  I'm introducing
a new team to clojure and trying to suggest that :refer is the way to go,
but it's tricky when every code sample out there uses :use.

Especially for the situation where you actually want to import a whole
namespace - should we be using:
(:use midje.sweet)
or:
(:require midje.sweet :refer :all)
?

- Korny


On 15 February 2013 00:26, Jim foo.bar  wrote:

>  I know that using a bare :use in the ns macro is generally frowned upon
> as it provides no hints about what is actually being used...
>
> However, I 've got 2 namespaces 'abstractions.clj' and
> 'concretions.clj'...concretions.clj will eventually use all the protocols
> defined in abstractions.clj...at the moment it doesn't but as I work
> through it I want to provide concrete records for *all* the protocols...
>
> Should I just go and :use the entire thing or should I stick with :require
> and keep typing 'pro/XXX' a million times? That specific namespace is very
> central to my work...
>
> Jim
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Kornelis Sietsma  korny at my surname dot com http://korny.info
"We do not quit playing because we grow old, we grow old because we quit
playing" - O.W. Holmes

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: :use an entire namespace full of protocols or stick with :require?

2013-03-09 Thread Travis Vachon
Speaking strictly for myself, but as someone who spends about half his
professional day writing Clojure: :use is dead, long live :require.

I've found using ":require [foo :refer :all]" rather than ":use foo"
has lead to cleaner, more consistent ns statements in my own code, and
I've made it a policy to convert old :use statements to ":refer :all"
whenever possible.

Travis



On Sat, Mar 9, 2013 at 6:00 PM, Korny Sietsma  wrote:
> [reviving a slightly old thread]
> Note that as of clojure 1.4 you can also do:
>   (:require foo.bar :refer :all)
> in fact from comments I've seen elsewhere there is a general intention to
> remove :use entirely?
>
> It'd be good to have some clarity on this.  The vast majority of code
> samples use :use, some with :only.  The docstring for ns doesn't even
> mention :refer! The clojure cheatsheet points to
> http://clojuredocs.org/clojure_core/clojure.core/ns which _does_ have the
> new syntax, in the last couple of examples; and it links to the tutorial at
> http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
> which uses 'use' throughout, except for an easily missable update half way
> through that says to use :refer.
>
> So, to what extent are people actually deprecating :use ?  I'm introducing a
> new team to clojure and trying to suggest that :refer is the way to go, but
> it's tricky when every code sample out there uses :use.
>
> Especially for the situation where you actually want to import a whole
> namespace - should we be using:
> (:use midje.sweet)
> or:
> (:require midje.sweet :refer :all)
> ?
>
> - Korny
>
>
> On 15 February 2013 00:26, Jim foo.bar  wrote:
>>
>> I know that using a bare :use in the ns macro is generally frowned upon as
>> it provides no hints about what is actually being used...
>>
>> However, I 've got 2 namespaces 'abstractions.clj' and
>> 'concretions.clj'...concretions.clj will eventually use all the protocols
>> defined in abstractions.clj...at the moment it doesn't but as I work through
>> it I want to provide concrete records for all the protocols...
>>
>> Should I just go and :use the entire thing or should I stick with :require
>> and keep typing 'pro/XXX' a million times? That specific namespace is very
>> central to my work...
>>
>> Jim
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
>
>
>
> --
> Kornelis Sietsma  korny at my surname dot com http://korny.info
> "We do not quit playing because we grow old, we grow old because we quit
> playing" - O.W. Holmes
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Composable mutual recursive function composition

2013-03-09 Thread Brent Millare
I recently asked about mutual referenced support in the prismatic library 
plumbing

https://github.com/Prismatic/plumbing

and currently its an open question about how to implement that.

So I made a proof-of-concept version of a "graph-like" library that 
supports mutual recursion.

https://github.com/bmillare/dj.compose

Note some differences:
* fnb are higher order functions, so its expected you use it to wrap an 
existing anonymous function
* functions in the bind-map are just plain functions and accept any number 
of arguments. They are not map oriented.

I encourage those interested to the read the sources, its only 1 macro, and 
1 function. Feedback appreciated.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




clojure.core/format localization problems

2013-03-09 Thread dabd
On my system I have:

> *clojure-version*
{:major 1, :minor 4, :incremental 0, :qualifier nil}

> (java.util.Locale/getDefault)
#


> (format "%.1f" 0.5)
"0,5"

> (java.lang.String/format (java.util.Locale/getDefault) "%.1f" (to-array 
[0.5]))
"0.5"

but 

> (java.lang.String/format  "%.1f" (to-array [0.5]))
"0,5"

How can I set clojure.core/format to display numbers with a dot decimal 
separator?
Why calling java.lang.String/format with the default locale returns a 
different value than calling it without specifying the locale (javadoc says 
it uses the default locale so they should return the same value)?

Thanks.


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




Datomic hack session at Clojure/West

2013-03-09 Thread Rich Morin
I'm organizing a Datomic hack session and dinner run at Clojure/West.
Drop-ins welcome; feel free to attend either or both events...

-r


What


This will be a low-key, informal chance for Datomic fans to meet and
chat, work on projects, etc.  Folks can spend their time on anything
they find interesting.  Here are some ideas, as starting points:

  *  a brainstorming session to come up with a set of tools
 (current and/or proposed) for using Datomic with Clojure

  *  independent and/or group hacking on personal projects

  *  a group project to create a "production" version of Codeq


When


  Sunday, March 17

~3 pm - hack session
~6 pm - dinner run


Where
-

  Courtyard Portland City Center
  550 SW Oak St; Portland, OR

The hotel's web site shows some comfy-looking couches in the lobby,
so that looks like the best place to meet.  Look around for a sign
(eg, "Datomic hack session"), as well as some cookie crumbs, eg:

  *  a relevant tweet

 The #datomic hack session at #clojurewest is located at ___.
 Look for the ___.

  *  a note on a message board and/or front desk

 Datomic hack session, 3 pm, ___

 -- 
http://www.cfcl.com/rdmRich Morin
http://www.cfcl.com/rdm/resume r...@cfcl.com
http://www.cfcl.com/rdm/weblog +1 650-873-7841

Software system design, development, and documentation


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




Re: clojure.core/format localization problems

2013-03-09 Thread Andy Fingerhut
What OS and version of Java are you using (output of "java -version", and if on 
Linux "lsb_release -a" and "uname -a").

Are you doing these commands one after another in a single REPL session?  If 
so, how did you start that REPL?

I've tried the commands you mention on these OS and JDK combos with Clojure 
1.4.0, and always saw "0.5" as the result, never "0,5".  My default locale was 
also en_US on all of these systems.

Mac OS X 10.6.8 + java version 1.6.0_43 (Oracle/Apple)
Ubuntu 11.10 with Linux kernel 3.0.0-31-generic + java version 1.6.0_27 
(OpenJDK)
Windows 7 + java version 1.7.0_07 (Oracle)

Andy

On Mar 9, 2013, at 4:39 PM, dabd wrote:

> On my system I have:
> 
> > *clojure-version*
> {:major 1, :minor 4, :incremental 0, :qualifier nil}
> 
> > (java.util.Locale/getDefault)
> #
> 
> 
> > (format "%.1f" 0.5)
> "0,5"
> 
> > (java.lang.String/format (java.util.Locale/getDefault) "%.1f" (to-array 
> > [0.5]))
> "0.5"
> 
> but 
> 
> > (java.lang.String/format  "%.1f" (to-array [0.5]))
> "0,5"
> 
> How can I set clojure.core/format to display numbers with a dot decimal 
> separator?
> Why calling java.lang.String/format with the default locale returns a 
> different value than calling it without specifying the locale (javadoc says 
> it uses the default locale so they should return the same value)?
> 
> Thanks.
> 
> 
> 
> -- 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: clojure.core/format localization problems

2013-03-09 Thread dabd
I am trying to run clojure on windows 7 with this java version:
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

The decimal separator used to be a dot but for some reason it changed to a 
comma recently.  I didn't change any OS locale settings.

On Sunday, March 10, 2013 1:27:49 AM UTC, Andy Fingerhut wrote:
>
> What OS and version of Java are you using (output of "java -version", and 
> if on Linux "lsb_release -a" and "uname -a").
>
> Are you doing these commands one after another in a single REPL session? 
>  If so, how did you start that REPL?
>
> I've tried the commands you mention on these OS and JDK combos with 
> Clojure 1.4.0, and always saw "0.5" as the result, never "0,5".  My default 
> locale was also en_US on all of these systems.
>
> Mac OS X 10.6.8 + java version 1.6.0_43 (Oracle/Apple)
> Ubuntu 11.10 with Linux kernel 3.0.0-31-generic + java version 1.6.0_27 
> (OpenJDK)
> Windows 7 + java version 1.7.0_07 (Oracle)
>
> Andy
>
> On Mar 9, 2013, at 4:39 PM, dabd wrote:
>
> On my system I have:
>
> > *clojure-version*
> {:major 1, :minor 4, :incremental 0, :qualifier nil}
>
> > (java.util.Locale/getDefault)
> #
>
>
> > (format "%.1f" 0.5)
> "0,5"
>
> > (java.lang.String/format (java.util.Locale/getDefault) "%.1f" (to-array 
> [0.5]))
> "0.5"
>
> but 
>
> > (java.lang.String/format  "%.1f" (to-array [0.5]))
> "0,5"
>
> How can I set clojure.core/format to display numbers with a dot decimal 
> separator?
> Why calling java.lang.String/format with the default locale returns a 
> different value than calling it without specifying the locale (javadoc says 
> it uses the default locale so they should return the same value)?
>
> Thanks.
>
>
>
> -- 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com 
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@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 unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com .
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: clojure.core/format localization problems

2013-03-09 Thread dabd
I installed the latest 1.7.0_17 and apparently the issue is gone but I 
still don't know what caused it.
Thanks.

On Sunday, March 10, 2013 3:22:21 AM UTC, dabd wrote:
>
> I am trying to run clojure on windows 7 with this java version:
> java version "1.7.0_05"
> Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
> Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
>
> The decimal separator used to be a dot but for some reason it changed to a 
> comma recently.  I didn't change any OS locale settings.
>
> On Sunday, March 10, 2013 1:27:49 AM UTC, Andy Fingerhut wrote:
>>
>> What OS and version of Java are you using (output of "java -version", and 
>> if on Linux "lsb_release -a" and "uname -a").
>>
>> Are you doing these commands one after another in a single REPL session? 
>>  If so, how did you start that REPL?
>>
>> I've tried the commands you mention on these OS and JDK combos with 
>> Clojure 1.4.0, and always saw "0.5" as the result, never "0,5".  My default 
>> locale was also en_US on all of these systems.
>>
>> Mac OS X 10.6.8 + java version 1.6.0_43 (Oracle/Apple)
>> Ubuntu 11.10 with Linux kernel 3.0.0-31-generic + java version 1.6.0_27 
>> (OpenJDK)
>> Windows 7 + java version 1.7.0_07 (Oracle)
>>
>> Andy
>>
>> On Mar 9, 2013, at 4:39 PM, dabd wrote:
>>
>> On my system I have:
>>
>> > *clojure-version*
>> {:major 1, :minor 4, :incremental 0, :qualifier nil}
>>
>> > (java.util.Locale/getDefault)
>> #
>>
>>
>> > (format "%.1f" 0.5)
>> "0,5"
>>
>> > (java.lang.String/format (java.util.Locale/getDefault) "%.1f" (to-array 
>> [0.5]))
>> "0.5"
>>
>> but 
>>
>> > (java.lang.String/format  "%.1f" (to-array [0.5]))
>> "0,5"
>>
>> How can I set clojure.core/format to display numbers with a dot decimal 
>> separator?
>> Why calling java.lang.String/format with the default locale returns a 
>> different value than calling it without specifying the locale (javadoc says 
>> it uses the default locale so they should return the same value)?
>>
>> Thanks.
>>
>>
>>
>> -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: what is a good book about Java queues?

2013-03-09 Thread Feng Shen
Yes, the javadoc is quite good, paste a link here:

http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html


On Friday, March 8, 2013 4:32:38 AM UTC+8, larry google groups wrote:
>
>
> At some point on this mailist, someone suggested that to best understand 
> concurrency in Java, once should read: 
>
> Java Concurrency In Practice
>
>
> http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601/ref=sr_1_1?ie=UTF8&qid=1362688125&sr=8-1&keywords=java+concurrency+in+practice
>
> So I read it, but I am surprised that it says fairly little about working 
> with queues. I am curious if anyone would recommend a book for learning 
> more about working with Java queues? 
>
> I suffer the problem that I learned Clojure without first learning Java, 
> and Clojure leans on Java rather heavily, so I am now trying to come up to 
> speed on Java. 
>
>
>
>
>
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Windows Installation

2013-03-09 Thread Phil Hagelberg

James Ashley writes:

> 2) Download the lein "install" script as text from the leiningen home page.
> 3) Copy it over to my cygwin directory
> 4) Search/replace to replace the HTML entities with the real thing. I think
> this was a matter of & and >

Can you explain how you downloaded bin/lein such that you had HTML
entities in it? Is that a quirk of the browser you used or something?

> 5) They mentioned instructions about setting up
> an environment variable (something
> about something like `export DOWNLOAD="curl --trusting %1"`...that wasn't
> it, but it was along the same lines).

Yeah, if the certificate store that curl is checking doesn't have the CA
for GitHub then you won't be able to download it securely. I'm not sure
whether this is a problem with Cygwin or Windows itself. Not much we can
do about this, but at least the error message explains one solution. Of
course fixing the certificate store would be better still.

> 7) Change project.clj to use clojure 1.5

This is fixed in master; hope to have the next release out in a few weeks.

> 8) `lein repl` inside cygwin didn't work correctly. CLASSPATH was all
> windows-style, which confused cygwin. So basic clojure.core pieces
> weren't found.

Good to know. Someone submitted some patches for Cygwin compatibility in
bin/lein, but it was a long time ago (over a year) so it probably needs
a refresh. Would be great to get a patch for this or even just a bug
report with details.

Thanks for the info.

-Phil

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