Re: swap! and atom behavior

2012-07-30 Thread Sean Corfield
On Mon, Jul 30, 2012 at 11:05 PM, Vinay D.E  wrote:
> I tried putting a print and it works as expected.

Because you are realizing the whole of i to print it.

> 1) I assumed that printing out [i @a] instead of [@a i] should realize 'i'

No, [i @a] creates a two-element vector of a lazy-seq and a value (the
deref of a). Then, when the REPL prints that vector, it realizes the
lazy-seq.

> 2) If I put a breakpoint in the predicate for take-while, it gets hit ( I

Yes, it is hit while i is being realized.

> 3) This is the strangest observation of all: In the debugger I can see that
> 'a' is getting incremented, its changing when the breakpoint is hit!  but
> the baffling thing is, when the result is printed out, I still get 0 as the
> value for a.

Because the value of @a is bound before i is realized, so 0 is bound
into the vector, and then i is realized during which process you see a
being incremented.

> Isn't (print i) the same as [i @a] ?  since i is realized first, shouldn't
> @a  be correctly printed?

No, see above.

> Why is the breakpoint showing me that a is changing ?

Because it _is_ changing but _after_ the top level of the vector has
been evaluated.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.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: swap! and atom behavior

2012-07-30 Thread Carlo Zancanaro
> 1) I assumed that printing out [i @a] instead of [@a i] should realize 'i'
> first and @a should be correctly displayed as 5. This does not happen, it
> simply prints [(1 2 3 4 5) 0] if the order is reversed.

So, this evaluates in two "stages".

First the terms `i` and `@a` are evaluated to get their values, so `i`
returns the lazy sequence it contains (not realised at all) and `@a`
returns the value inside the atom (which is 0).

Then the printing statement goes through each of those values and
tries to work out what it needs to print. For `i` this involves
realising the sequence (to get each value to print), but for `@a` it's
already got the value (0, from earlier), so it just prints that. For
the lazy sequence it didn't have a printable value, it just had
something saying "this is a sequence that will be generated when you
want it", so it has to do more work before it can print.

> 2) If I put a breakpoint in the predicate for take-while, it gets hit ( I
> was expecting it to not get hit if it was lazy)

The lazy sequence still gets realised, just not when you'd expect, so
you still hit the breakpoint, just after you've already retrieved the
value of the atom.

> 3) This is the strangest observation of all: In the debugger I can see that
> 'a' is getting incremented, its changing when the breakpoint is hit!  but
> the baffling thing is, when the result is printed out, I still get 0 as the
> value for a.

This is also explained by the above.


You're basically getting stung by precisely when a lazy sequence gets
realised. This sort of issue is why you should try to avoid having any
sort of side effects in the generation of lazy sequences.

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

2012-07-30 Thread Vinay D.E
Hi Evan, 
 Thanks for the reply. 
I tried putting a print and it works as expected.  

(let [a (atom 0)
  i (take-while (fn[x] (swap! a inc) 
  (< x 100))  [1 2 3 4 5])]
  (println i)
  [@a i]) ;; <== [5 (1 2 3 4 5)]

But, I still cant come up with a theory of what exactly is happening.
My understanding of laziness is not deep enough, but I had ruled it out 
initially for 2 reasons

1) I assumed that printing out [i @a] instead of [@a i] should realize 
*'i'*first and @a should be correctly displayed as 5. This does not happen, it 
simply prints [(1 2 3 4 5) 0] if the order is reversed.
2) If I put a breakpoint in the predicate for take-while, it gets hit ( I 
was expecting it to not get hit if it was lazy)
3) This is the strangest observation of all: In the debugger I can see that 
*'a' *is getting incremented, its changing when the breakpoint is hit!  but 
the baffling thing is, when the result is printed out, I still get 0 as the 
value for a.

Now if a print is added, I am seeing 5 correctly printed out, but I am not 
satisfied with any explanation I can make up. 

Isn't (print i) the same as [i @a] ?  since i is realized first, shouldn't 
@a  be correctly printed?

Why is the breakpoint showing me that a is changing ? What is totally 
strange is that '0' gets printed for @a in the end in spite of the change 
that I saw while debugging. I find this baffling as I was expecting the 
clojure runtime to have 'forgotten' about the earlier value since it is a 
single variable 'bound' to a single value (a --> 0) if a number gets 'put' 
as its value,  as then it would become (a --> 5) how did it go 'back' to 
becoming 0 again after I saw its value changing in the debugger ? 


Here is the code for this behavior ( with emacs / lein / swank  and a 
swank,core/break breakpoint)

(let [a (atom 0)
  i (take-while (fn[x] (swap! a inc) (swank.core/break) ;; <== this 
shows values like : a = #, a = #, a = 
# etc
  (< x 100))  [1 2 3 4 5])]
  [i @a]) ;; <==  But, this prints out [(1 2 3 4 5) 0]

I am reasonably sure there is no persistent data structure involved as it 
is an atom. By that reasoning, there should be no memory of '0'. Is there 
something else I am missing ? Is this normal lazy behavior ? 

Thanks
Vinay


On Tuesday, 31 July 2012 08:54:02 UTC+5:30, Evan Mezeske wrote:
>
> The problem is that take-while is lazy, so it does not actually perform 
> the "taking" operation until the lazy-seq it returns is realized, e.g. by 
> being printed.  So when your code binds the (take-while ...) expression to 
> "i", the anonymous function you provided is not yet being invoked, and thus 
> the atom's value is not being incremented.
>
> Since your code dereferences the "a" atom before it forces evaluation of 
> the "i" lazy-seq, it gets the value 0.  The "a" atom's value will only be 5 
> after "i" has been fully realized, which happens later.
>
> So, for example, if you changed your code to this:
>
>   (let [a (atom 0)
>   i (take-while (fn[x] (swap! a inc) (< x 100))  [1 2 3 4 5])]
> (println i)
> (println @a))
>
> You will see the result you expect, because println forces "i" to be fully 
> realized, and thus "a" will be changed as a side-effect.
>
> In general, performing side-effecty operations inside lazy code is not 
> usually advisable, because due to the nature of laziness, the results will 
> not be what you'd expect if you were coming from a, say, 
> imperative-language background. 
>
> Perhaps someone else can provide a link to some good reading material for 
> learning about laziness?
>
>>

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

2012-07-30 Thread Ben Smith-Mannschott
On Tue, Jul 31, 2012 at 7:00 AM, Ben Smith-Mannschott
 wrote:
> On Tue, Jul 31, 2012 at 1:08 AM, Aaron Cohen  wrote:
>> On Mon, Jul 30, 2012 at 6:55 PM, Moritz Ulrich  
>> wrote:
>>> (some identity ((juxt :k1 :k2) m)) is the first thing I can think of.
>>
>> For even more fun, try (some m [:k1 :k2]) :)
>
> The flip side of this proposal is:
>
> ((some-fn :k1 :k2) m)
>
> Which takes advantage of the fact that keywords can be called as
> functions. That means it will only work for keyword keys, but the
> upshot is that it will work for arbitrary functions (not just
> keywords) and m need not be a map.
>
> See also every-pred, which

((my new "truly ergonomic" keyboard is taking some getting used to -- this
is the second time I've mashed some keys and ended up sending a gmail
message earlier than intended.))

See also every-pred, which complements some-fn. Oh, and see complement
too. These three correspond to 'or', 'and' and 'not' respectively.

// ben

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

2012-07-30 Thread Ben Smith-Mannschott
On Tue, Jul 31, 2012 at 1:08 AM, Aaron Cohen  wrote:
> On Mon, Jul 30, 2012 at 6:55 PM, Moritz Ulrich  
> wrote:
>> (some identity ((juxt :k1 :k2) m)) is the first thing I can think of.
>
> For even more fun, try (some m [:k1 :k2]) :)

The flip side of this proposal is:

((some-fn :k1 :k2) m)

Which takes advantage of the fact that keywords can be called as
functions. That means it will only work for keyword keys, but the
upshot is that it will work for arbitrary functions (not just
keywords) and m need not be a map.

See also every-pred, which

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

2012-07-30 Thread Sean Corfield
On Fri, Jul 27, 2012 at 10:42 AM, Jestine Paul  wrote:
> I have raised a JIRA issue (JDBC-35) regarding the timezones returned from
> the ResultSet getter method.
> http://dev.clojure.org/jira/browse/JDBC-35

I'm a bit surprised no one has responded to this. Maybe no one else is
having this issue? I'd love to see some feedback on this.

> I have also attached a patch to this issue.
> http://dev.clojure.org/jira/secure/attachment/11394/resultset-timezone.diff

I hope there are better solutions suggested. Given that the patch just
provides a way for users to tell the library "these columns are
special", it seems like you might just as well map a column adjustment
function over the result set yourself? It feels very clunky.

It also looks like it can reorder columns. java.jdbc used to use
structmap to preserve column order but now uses regular maps -
although small maps use an array map which does in fact preserve
column ordering for reasonable numbers of columns. That didn't seem to
be particularly important for users at the time but gratuitous
partitioning of columns seems unnecessary...

Overall, I still think this problem arises because you're not
following best practices for managing timezones which is to have all
your servers operating on the same timezone and using NTP to sync
times - but I really do want to hear some feedback from other
java.jdbc users (which is why I haven't just closed the ticket).
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.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: ANN: Mongoika, a new Clojure MongoDB library

2012-07-30 Thread Sean Corfield
On Mon, Jul 30, 2012 at 7:14 PM, Tokusei NOBORIO  wrote:
> I have updated the feature comparison spreadsheet.  Is it okay now?

Thanx. It's still says 'n' for connection pooling - but that's built
into the Java driver that CongoMongo uses so I'm not sure how you're
defining that feature?

> Does CongoMongo have anything like Mongoika's map-after feature?
> https://github.com/yuushimizu/Mongoika

No, because it does not have a query DSL. It seems to me that a query
DSL, composable queries and map-after are all facets of one feature -
if you don't have a query DSL, you're not going to have any of the
other things...?
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.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:

2012-07-30 Thread Yoshinori Kohyama
Hi Nicolas,

The technique, using throw an Exception when succeeded in searching, 
strikes me!
Not idiomatic but very practical.
It's like a break in a loop of imperatives.
I may use it somewhere.
Thank you.

Regards,
Yoshinori Kohyama

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

2012-07-30 Thread Evan Mezeske
The problem is that take-while is lazy, so it does not actually perform the 
"taking" operation until the lazy-seq it returns is realized, e.g. by being 
printed.  So when your code binds the (take-while ...) expression to "i", 
the anonymous function you provided is not yet being invoked, and thus the 
atom's value is not being incremented.

Since your code dereferences the "a" atom before it forces evaluation of 
the "i" lazy-seq, it gets the value 0.  The "a" atom's value will only be 5 
after "i" has been fully realized, which happens later.

So, for example, if you changed your code to this:

  (let [a (atom 0)
  i (take-while (fn[x] (swap! a inc) (< x 100))  [1 2 3 4 5])]
(println i)
(println @a))

You will see the result you expect, because println forces "i" to be fully 
realized, and thus "a" will be changed as a side-effect.

In general, performing side-effecty operations inside lazy code is not 
usually advisable, because due to the nature of laziness, the results will 
not be what you'd expect if you were coming from a, say, 
imperative-language background. 

Perhaps someone else can provide a link to some good reading material for 
learning about laziness?

>

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

swap! and atom behavior

2012-07-30 Thread Vinay D.E
Hi,
I am a clojure newbie. I was working through some examples when I
discovered some behavior that I cant understand.
swap! behavior changes with the context it is used in.

If I put it in a 'take-while', swap! doesnt work :

  (let [a (atom 0)
  i (take-while (fn[x] (swap! a inc) (swank.core/break) (< x 100))  [1
2 3 4 5])]
  [@a i])

==>  [0 (1 2 3 4 5)]
The strange thing is, the breakpoint shows swap! incrementing a, but it
still becomes 0 in the end.


A more roundabout way, works  :

(let [a (atom 0)
  i (reduce
 (fn[l in]
   (if (or (nil? (last l)) (< (last l) 100))
 ((fn[] (swap! a inc) (conj l in)))
 l )) [] [1 2 3 4 5])]
  [@a i])

==> [5 [1 2 3 4 5]]

I could not get anything by looking at the source of take-while.
Why is this behaving differently ? How does the counter get reset when
using a take-while ?
I feel as if I am missing something basic. Any help/pointers would be great.

Thanks
Vinay

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

atom / swap! question

2012-07-30 Thread Vinay D.E
I am a newbie and was doing some exercises when I ran across something that 
I don't understand.
I am trying to count the number of elements in an array less than 100.

My first attempt didn't work. The counter returns 0

(let [a (atom 0)
  i (take-while (fn[x] (swap! a inc) (< x 100))  [1 2 3 4 5])]
  [@a i])  => [0 (1 2 3 4 5)]


I am not getting any insight from the source 
of 
'take-while' too. 
The strange thing is, if I set a break-point, I can see that the atom is 
getting incremented.

(let [a (atom 0)
  i (take-while (fn[x] (swap! a inc) *(swank.core/break) *(< x 100)) 
 [1 2 3 4 5])]
  [@a i])

whereas if I do this in a slightly more roundabout way, it works!

(let [a (atom 0)
  i (reduce
 (fn[l in]
   (if (or (nil? (last l)) (< (last l) 100))
 ((fn[] (swap! a inc) (conj l in)))
 l )) [] [1 2 3 4 5])]  
  [@a i]) => [5 [1 2 3 4 5]]

I tried reading docs, but I am unable to understand what is happening. If 
anyone could please point me in the right direction, it would be great.
Thanks in advance
Vinay

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

Re: ANN: Mongoika, a new Clojure MongoDB library

2012-07-30 Thread Tokusei NOBORIO
Thank you for explaining this to me.  I didn't know that CongoMongo
had these features.
I have updated the feature comparison spreadsheet.  Is it okay now?

Does CongoMongo have anything like Mongoika's map-after feature?
https://github.com/yuushimizu/Mongoika

2012/7/31 Sean Corfield :
> On Mon, Jul 30, 2012 at 5:12 PM, Tokusei NOBORIO  wrote:
>> I used CongoMongo in the past, And decided I need a library with more 
>> features.
>
> What features were missing? Always interested in making CongoMongo
> better - since there's a whole team of contributors :)
>
>> It seems to be more mature than Mongoika.
>
> FWIW, CongoMongo has been around since October 2009.
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.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



-- 
登尾 徳誠(Tokusei Noborio) {
 ニャンパス株式会社: http://nyampass.com/
 ニコ生: http://com.nicovideo.jp/community/co1281759
 Blog: http://tnoborio.blogspot.com/
 Twitter: http://twitter.com/tnoborio
}

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


Re: ANN: Mongoika, a new Clojure MongoDB library

2012-07-30 Thread Sean Corfield
On Mon, Jul 30, 2012 at 5:12 PM, Tokusei NOBORIO  wrote:
> I used CongoMongo in the past, And decided I need a library with more 
> features.

What features were missing? Always interested in making CongoMongo
better - since there's a whole team of contributors :)

> It seems to be more mature than Mongoika.

FWIW, CongoMongo has been around since October 2009.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.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: ANN: Mongoika, a new Clojure MongoDB library

2012-07-30 Thread Sean Corfield
On Mon, Jul 30, 2012 at 5:12 PM, Tokusei NOBORIO  wrote:
> Here is a comparison of the features of the three libraries.
> I hope people will correct any mistakes, and point out any important
> features I have forgotten.
>
> https://docs.google.com/spreadsheet/ccc?key=0AjcJV_bAT0m_dHVPY0lZZlZvbElyVGZqNFF4bzJJVnc#gid=0

CongoMongo definitely supports:
* WriteConcern
* GridFS
* Map-Reduce

Not sure what you mean by several other categories so it's hard to
tell whether CongoMongo supports them or not.
Multiple Connections? Depending on how you define this, CongoMongo may
well qualify.
Connection Pool? CongoMongo uses the Java driver which does connection
pooling internally already.
Indexing? CongoMongo has add-index! and drop-index! and can retrieve
indexes on a collection.
Heroku? Pretty sure folks are using CongoMongo on Heroku but I can't
confirm that.

CongoMongo's readme doesn't list a lot of the stuff it does but you
can see tests for most of the things mentioned above here:

https://github.com/aboekhoff/congomongo/blob/master/test/somnium/test/congomongo.clj

Hope that helps?
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.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: ANN: Mongoika, a new Clojure MongoDB library

2012-07-30 Thread Tokusei NOBORIO
> Have you taken a look
> at other libraries such as CongoMongo

I used CongoMongo in the past, And decided I need a library with more features.
This is why I wrote Mongoika.

> Monger also lets you work with query cursors as lazy sequences,
> uses Mongo shell "syntax" for queries with maps and supports a variety of
> GridFS operations.

I had not seen Monger before. I have looked at it just now.
It seems to be more mature than Mongoika.

Here is a comparison of the features of the three libraries.
I hope people will correct any mistakes, and point out any important
features I have forgotten.

https://docs.google.com/spreadsheet/ccc?key=0AjcJV_bAT0m_dHVPY0lZZlZvbElyVGZqNFF4bzJJVnc#gid=0

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

2012-07-30 Thread Michael Gardner
On Jul 30, 2012, at 6:08 PM, Aaron Cohen wrote:

> For even more fun, try (some m [:k1 :k2]) :)

Wow, that's perfect. It even works with string keys! Thanks, guys.

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

2012-07-30 Thread Aaron Cohen
On Mon, Jul 30, 2012 at 6:55 PM, Moritz Ulrich  wrote:
> (some identity ((juxt :k1 :k2) m)) is the first thing I can think of.

For even more fun, try (some m [:k1 :k2]) :)

--Aaron

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

2012-07-30 Thread Moritz Ulrich
(some identity ((juxt :k1 :k2) m)) is the first thing I can think of.

On Tue, Jul 31, 2012 at 12:48 AM, Michael Gardner  wrote:
> Is there an elegant way to say '(or (:k1 m) (:k2 m)), without repeating m? 
> Using a let can be awkward if the expression isn't already wrapped in one; 
> '(apply #(or %1 %2) (map m [:k1 :k2])) is similarly bad. Hopefully there's 
> something clever I'm missing; any ideas?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from 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


Alternative to (or (:k1 m) (:k2 m))

2012-07-30 Thread Michael Gardner
Is there an elegant way to say '(or (:k1 m) (:k2 m)), without repeating m? 
Using a let can be awkward if the expression isn't already wrapped in one; 
'(apply #(or %1 %2) (map m [:k1 :k2])) is similarly bad. Hopefully there's 
something clever I'm missing; any ideas?

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

2012-07-30 Thread Simon Holgate
Jim,

this is really great! I have joined the google group and I'm looking 
> forward to the next meetup! 

Great! Welcome to the group!

as the website suggests i will keep an eye on the time and place as it says 
> it is not always fixed...too bad I missed the clojurescript talk :( 
>

Yep, the ClojureScript talk was a real classic :) Well, it was my first 
ClojureScript talk anyway...

btw, have you talked about the reducers lib? It is the first thing on my 
> list to explore as soon as I return back to Manchester... 
>

Nope, but we would all be very keen to hear a talk on reducers ;) 

In case you missed it, the next talk is on August 13th 2012 - "An 
introduction to Applicative Functors in Haskell" by Ian Murray.

Simon
 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Experiences developing a crowdfunding site for open source projects in Clojure (from a Python background)

2012-07-30 Thread John Gabriele
On Sunday, July 29, 2012 3:45:00 PM UTC-4, Aaron Lebo wrote:

> Here's PEP 8 as an example of what I'm talking about:
> http://www.python.org/dev/peps/pep-0008/

Perhaps this might be useful: 
http://dev.clojure.org/display/design/Library+Coding+Standards

---John

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

2012-07-30 Thread Kevin Ilchmann Jørgensen
Hey

Does the part about numbers: http://clojure.org/data_structures  clear
it up for you?

>From (source +)  you should see that (+ 0.1 0.1M ...) is matched to
(. clojure.lang.Numbers (add x y)))
; (. clojure.lang.Numbers (add 0.1 0.1M)) =>0.2

and that (+ 0.1M 0.1M ...) is  (. clojure.lang.Numbers (add 0.1M 0.1M)) =>0.2M

So maybe the contagious nature of numbers are biting somewhere - you
should experiment around.

[(+ 0.9 0.1)  (+ 0.8 0.1)  (+ 0.7 0.1)]
[(+ 0.9 0.1M) (+ 0.8 0.1M) (+ 0.7 0.1M)]
[(+ 0.9M 0.1) (+ 0.8M 0.1) (+ 0.7M 0.1)]
[(+ 0.9M 0.1M) (+ 0.8M 0.1M) (+ 0.7M 0.1M)]


https://en.wikipedia.org/wiki/Arithmetic_precision

/Kevin


On Mon, Jul 30, 2012 at 5:04 PM, grahamke  wrote:
> I was testing some of the code in Miclael Fogus & Chris Houser's The Joy of
> Clojure and found this:
>
> Clojure 1.4.0
> user=> (let [a (+ 0.1 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M)]
>   (println (class a))
>   a)
> java.lang.Double
> 0.
> user=> (let [b (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1)]
>   (println (class b))
>   b)
> java.lang.Double
> 1.0
> user=>
>
> Can anyone help by explaining why a and b are not equal?  I figure it has
> something to do with the reduce1 function.
>
> Thanks!
>
> -Kevin
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from 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:

2012-07-30 Thread nicolas.o...@gmail.com
Another one. (The exception is for early termination)

(def found! (Exception.))

(defn has22 [l]
(try
   (reduce #(and (= 2 %2) (or (not %1) (throw found!))) false l)
   false
   (catch Exception e true)))

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


A question on Clojure precision

2012-07-30 Thread grahamke
I was testing some of the code in Miclael Fogus & Chris Houser's The Joy of 
Clojure and found this:
 
Clojure 1.4.0
user=> (let [a (+ 0.1 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M)]
  (println (class a))
  a)
java.lang.Double
0.
user=> (let [b (+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1)]
  (println (class b))
  b)
java.lang.Double
1.0
user=>
 
Can anyone help by explaining why a and b are not equal?  I figure it has 
something to do with the reduce1 function.
 
Thanks!
 
-Kevin

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

2012-07-30 Thread DeWitt Clinton
I really like the 'partition' technique. That said, as a non-expert, I find
the recursive approach marginally easier to read:

(defn has22 [coll]
  (when-let [s (seq coll)]
(or (= 2 (first s) (second s)) (recur (rest s)

In my microbenchmarks, the above technique runs about 5-10x faster for all
sequences.  Close enough that I suspect it is largely a matter of personal
preference, but still slightly faster on my machine.

As a footnote, using destructuring instead ran only about half as fast as
the above code:

(defn has22-destructing [coll]
  (when-let [[x & xs] (seq coll)]
(or (= 2 x (first xs)) (recur xs

Not entirely sure why that would be.

Best regards,

-DeWitt


On Sun, Jul 29, 2012 at 8:22 PM, Yoshinori Kohyama wrote:

> Hi John,
>
> 'partition' will be useful for you, as Moritz pointed out.
>
> (partition 2 1 [1 2 3 4]) -> ((1 2) (2 3) (3 4))
> (partition 2 1 [1 2 2 4]) -> ((1 2) (2 2) (2 4))
> (partition 2 1 [1 2 2 2]) -> ((1 2) (2 2) (2 2))
>
> (some #(= % [2 2]) (partition 2 1 [1 2 3 4])) -> nil
> (some #(= % [2 2]) (partition 2 1 [1 2 2 4])) -> true
> (some #(= % [2 2]) (partition 2 1 [1 2 2 2])) -> true
>
> (filter #(= % [2 2]) (partition 2 1 [1 2 3 4])) -> ()
> (filter #(= % [2 2]) (partition 2 1 [1 2 2 4])) -> ((2 2))
> (filter #(= % [2 2]) (partition 2 1 [1 2 2 2])) -> ((2 2) (2 2))
>
> I'm sorry I can't recognize whether you need a pair of 2s or two pairs of
> 2s.
>
> If you need one or more pairs of 2s, do
> (defn has22 [coll] (boolean (some #(= % [2 2]) (partition 2 1 coll
> (has22 [1 2 3 4]) -> false
> (has22 [1 2 2 4]) -> true
> (has22 [1 2 2 2]) -> true
>
> If you need two or more pairs of 2s, do
> (defn has222 [coll] (< 1 (count (filter #(= % [2 2]) (partition 2 1
> coll)
> (has222 [1 2 3 4]) -> false
> (has222 [1 2 2 4]) -> false
> (has222 [1 2 2 2]) -> true
>
> Regards,
> Yoshinori Kohyama
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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: Testing ClojureScript

2012-07-30 Thread David Nolen
Looks like Node.js is being aliased as SpiderMonkey. That won't work. I
suggest installing V8 from source. I'll update the ClojureScript Github
wiki with instructions for testing latest JavaScriptCore and SpiderMonkey.

David

On Monday, July 30, 2012, Timothy Baldridge wrote:

> I'm trying to run the tests for ClojureScirpt under Ubuntu 12.04. I
> installed libmozjs, set the spidermonkey_home variable then ran script/test
> and got this:
>
>
> tim@tim-desktop:~/clojurescript$ script/test
> V8_HOME not set, skipping V8 tests
> Testing with SpiderMonkey
> Error: unrecognized flag -m
> Try --help for options
>
> node.js:201
> throw e; // process.nextTick error, or 'error' event on first tick
>   ^
> ReferenceError: print is not defined
> at Object.
> (/home/tim/clojurescript/out/core-advanced-test.js:349:506)
> at Module._compile (module.js:441:26)
> at Object..js (module.js:459:10)
> at Module.load (module.js:348:32)
> at Function._load (module.js:308:12)
> at Array.0 (module.js:479:10)
> at EventEmitter._tickCallback (node.js:192:41)
> JSC_HOME not set, skipping JavaScriptCore tests
> Tested with $[ran+1] out of 3 possible js targets
> tim@tim-desktop:~/clojurescript$ cat script/test
>
>
> What's the best way to run tests under Ubuntu?
>
> Thanks,
>
> Timothy
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to 
> clojure@googlegroups.com 'clojure@googlegroups.com');>
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com  'clojure%2bunsubscr...@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:

2012-07-30 Thread Ben Smith-Mannschott
On Sun, Jul 29, 2012 at 3:07 PM, John Holland  wrote:
> I'm doing some exercises in coding that are meant for Java but I'm doing
> them in Clojure. I'm stuck on this one. The goal is
> to return true if an array of ints contains two consecutive 2s. I figured
> I'd use Stuart Halloway's by-pairs function to turn the sequence
> into pairs of numbers and check for a pair that is 2,2.  This code in has22
> below works if pasted into the REPL and evaluated but as a
> function it always returns false. If anyone can explain my error to me it'd
> be great.
>
>
>
>
>
>
>
> (  defn by-pairs [coll] (let [take-pair (fn [c]
>  (when (next c) (take 2 c)))]
> (when-let [pair (seq (take-pair coll))]
>
> (lazy-seq
>
> (cons pair (by-pairs (rest coll)))
>
> (defn has22 [a]   (if (some true? (map  #(= 2 (first %) (nth % 1)) (by-pairs
> [a]))) true false))
>
>
>
> user> (some true? (map  #(= 2 (first %) (nth % 1)) (by-pairs [1 2 2 2 ])))
> true
>
>
> user> (has22 [1 2 2 2])
> false
>

In an effort to increase the net amount of perversity in the universe,
I offer the following alternate solution:

(defn has22 [a]
  (->> (concat [""] (map str a) [""])
   (interpose " ")
   (apply str)
   (re-find #" 2 2 ")
   boolean))

;-)

// Ben

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Experiences developing a crowdfunding site for open source projects in Clojure (from a Python background)

2012-07-30 Thread Samrat Man Singh
I got an error when I went to the link, you posted in the original post.

On Monday, July 30, 2012 1:08:40 AM UTC+5:45, Aaron Lebo wrote:
>
> Hi Samrat.
>
> Could you explain how you are trying to access the site (address) and what 
> is happening?
>
> I started out in noir, and ended up using a lot of the design patterns and 
> validation library. I stopped using noir for two reasons: I like being able 
> to see the routes of all of my urls on a single page (noir binds them to 
> their function definition), and a lot of the tutorials out there concerning 
> different libraries are based on raw Ring or Compojure. I didn't want to 
> get stuck debugging some minor issue simply because I didn't understand the 
> differences between using a library with noir/Compojure, which did happen 
> once.
>
> I really enjoyed noir, though, particularly the validation, it is very 
> clever, though as I said earlier I'd love it if it did conversion as well 
> as validation.
>
> Using Compojure was a blast. It rarely got in the way, which, imo is what 
> a routing framework should do.
>
> On the templating side I used Hiccup. That might be one of my favorite 
> libraries in any language. I desire writing templates in Python because you 
> are stuck opening and closing every brace. It is tedious and error-prone. 
> Hiccup cuts down on that tremendously.
>
> 
>   
> test
>   
> yep
>   
> 
>
> turns into:
>
> [:div.row
>   [:div.eight.columns
> [:p#test "test"]]
>   [:div#yep.four.columns
> [:span "yep"]]]
>
> You can't beat that. Notice particularly how easy it is to define ids and 
> classes. Plus it is just Clojure, so you end being able to use the whole 
> power of the language templating.
>
> On the db side I used korma. It beats the hell out of writing raw db 
> statements, but it too stays out of the way. I really like the way that it 
> just inserts joins as part of your result hash maps.
>
> (defentity profile)
> (defentity user
>   (has-one profile))
>
> (select user (where {:id (*user* :id)}) (with profile))
>
> Something like that would automatically join profile to user and return a 
> single hash map.
>
> It is a contrived example, but you get the gist. Only problem I had with 
> it was that you end up writing by hand more complex stuff like unions. Not 
> a big deal but you want the same convenience.
>
> On Sat, Jul 28, 2012 at 12:12 AM, Samrat Man Singh <
> samratmansi...@gmail.com> wrote:
>
>> I can't access your site. Also, I wanted to ask whether you used Noir or 
>> used a lower-level option(Compojure,etc)? 
>>
>>
>> On Friday, July 27, 2012 1:44:46 AM UTC+5:45, Aaron Lebo wrote:
>>>
>>> Hello!
>>>
>>> Sometime around 2 and a half months ago, I started to work on a new 
>>> project using Clojure. I've been using Python heavily for about 6 six years 
>>> working for a small direct mail company and before that started programming 
>>> with Ruby on Rails. This new project was something out of left field, so I 
>>> had different options on what technology to use. I ended up choosing 
>>> Clojure, and my work on the site has been my first real experience using a 
>>> lisp, Clojure, and the JVM. I'd like to share my experiences and how that 
>>> has differed with my previous Python work.
>>>
>>> Before that, I'd like to make a little plug for my site. It is called 
>>> kodefund  (www.kodefund.com). The basic idea 
>>> is to take the familiar Kickstarter model but to really focus on applying 
>>> that to open source development. I feel that previous crowdfunding efforts 
>>> have shown that there is an interest by developers to fund projects that 
>>> they are enthusiastic about. When this works, everyone wins: the developer 
>>> working on the project can devote their full time and effort on the actual 
>>> project and still make a living and others get the benefits of the open 
>>> source software. I feel like it is preferable over selling licenses to 
>>> proprietary software or other efforts.
>>>
>>> So, every project on kodefund is required to be open source. This 
>>> differentiates it from other crowdfunding sites, and helps to apply a 
>>> filter: you know what you are getting when you go there instead of seeing 
>>> dozens of projects for unrelated stuff. 
>>>
>>> One other difference is that you can also start a project which is more 
>>> or less a "reverse" Kickstarter. This allows you to take an idea for a 
>>> project or issue you want fixed, raise funding, and find someone who will 
>>> actually implement the project. Other users get to submit "applications" 
>>> and you choose from them to find the most capable candidate. Once you chose 
>>> an application, that person takes over the project.
>>>
>>> Finally, one other push I want to make is to open up proprietary 
>>> software. Maybe your company has written some software in-house, but 
>>> there's no real incentive to release it. What if you could crowdfund the 
>>> software, get paid to release it, and t

Testing ClojureScript

2012-07-30 Thread Timothy Baldridge
I'm trying to run the tests for ClojureScirpt under Ubuntu 12.04. I
installed libmozjs, set the spidermonkey_home variable then ran script/test
and got this:


tim@tim-desktop:~/clojurescript$ script/test
V8_HOME not set, skipping V8 tests
Testing with SpiderMonkey
Error: unrecognized flag -m
Try --help for options

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
  ^
ReferenceError: print is not defined
at Object.
(/home/tim/clojurescript/out/core-advanced-test.js:349:506)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:41)
JSC_HOME not set, skipping JavaScriptCore tests
Tested with $[ran+1] out of 3 possible js targets
tim@tim-desktop:~/clojurescript$ cat script/test


What's the best way to run tests under Ubuntu?

Thanks,

Timothy

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

Re: help with lein-localrepo

2012-07-30 Thread Samrat Man Singh
Thanks, it's working now.

On Monday, July 30, 2012 4:07:12 AM UTC+5:45, Shantanu Kumar wrote:
>
>
>
> On Sunday, 29 July 2012 17:37:40 UTC+5:30, Samrat Man Singh wrote:
>>
>> I want to use goose(https://github.com/jiminoc/goose) in a Clojure 
>> project and found a StackOverflow answer that pointed me to lein-localrepo. 
>> However, I couldn't figure out how to use it.
>>
>> I did:
>> lein localrepo install ../goose/target/goose-2.1.19.jar goose/goose 2.1.19
>>
>> And lein locallrepo list does show goose, but I don't know how to use it 
>> inside the repository. `lein deps` gives me nothing, and I'm not sure how 
>> to require goose into the REPL or my core.clj.
>>
>
> You should create a project (lein new foo) and include goose as a 
> dependency in project.clj before you can use it. Make sure you are using 
> the correct version of lein-localrepo based on the Leiningen version.
>
> Shantanu
>

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

Re: help with lein-localrepo

2012-07-30 Thread Samrat Man Singh
Thanks, it is working now. 

 Neither seems to work for me. To, my project.clj I tried adding both 
[goose "2.1.19"] and [com.gravity/goose "2.1.19"], but in the 

On Monday, July 30, 2012 4:07:12 AM UTC+5:45, Shantanu Kumar wrote:
>
>
>
> On Sunday, 29 July 2012 17:37:40 UTC+5:30, Samrat Man Singh wrote:
>>
>> I want to use goose(https://github.com/jiminoc/goose) in a Clojure 
>> project and found a StackOverflow answer that pointed me to lein-localrepo. 
>> However, I couldn't figure out how to use it.
>>
>> I did:
>> lein localrepo install ../goose/target/goose-2.1.19.jar goose/goose 2.1.19
>>
>> And lein locallrepo list does show goose, but I don't know how to use it 
>> inside the repository. `lein deps` gives me nothing, and I'm not sure how 
>> to require goose into the REPL or my core.clj.
>>
>
> You should create a project (lein new foo) and include goose as a 
> dependency in project.clj before you can use it. Make sure you are using 
> the correct version of lein-localrepo based on the Leiningen version.
>
> Shantanu
>

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

2012-07-30 Thread Tassilo Horn
Warren Lynn  writes:

>> In general, all different versions of a function should somehow do
>> the same thing, so with separate docstrings you'd need to repeat
>> yourself.  A good guideline is to write the "big picture" first,
>> followed by the meaning of the different parameters.
>>
> I agree the design should keep all implementations to do the same
> thing *conceptually*, as that is what an interface is for. However, I
> can imagine it is very common that a concrete implementation needs
> extra documentation for certain implementation specific things.  [...]
>
> In summary, in my view, this is a very legitimate and basic need.

I won't object, and the alter-meta! approach allows you to do that.  Of
course, it cannot provide documentation for the implementations, but the
interface docs may be extended with impl docs incrementally at the
location where the implementation is defined.  That's at least better
than nothing...

Bye,
Tassilo

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