Re: Drawbridge: a (Ring) HTTP transport for nREPL

2012-03-29 Thread Christophe Grand
It's just a web app, I guess you have to roll out your auth method of
choice.

On Fri, Mar 30, 2012 at 8:32 AM, Laurent PETIT wrote:

> Awesome!
>
> One question : how to pass security credentials ?
>
>
>
> Le 29 mars 2012 à 23:43, Chas Emerick  a écrit :
>
> > Drawbridge is an HTTP/HTTPS nREPL transport, implemented as a Ring
> handler:
> >
> >https://github.com/cemerick/drawbridge
> >
> > It also provides a client-side nREPL transport using clj-http that
> extends nREPL's url-connect; the intention is that any tool that uses
> url-connect will be able to transparently connect to and use an HTTP nREPL
> endpoint simply by specifying an http:// URL instead of e.g. an nrepl://
> one.
> >
> > I hope this will prove to be a reasonable "reference implementation" of
> both an alternative nREPL transport as well as of an effective HTTP/HTTPS
> transport to enable many applications that couldn't reasonably be built
> using other protocols.
> >
> > I welcome your questions, bugs, usage reports, etc.
> >
> > Thanks,
> >
> > - Chas
> >
> > --
> > [Clojure Programming from O'Reilly](http://www.clojurebook.com)
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (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: Drawbridge: a (Ring) HTTP transport for nREPL

2012-03-29 Thread Laurent PETIT
Awesome!

One question : how to pass security credentials ?



Le 29 mars 2012 à 23:43, Chas Emerick  a écrit :

> Drawbridge is an HTTP/HTTPS nREPL transport, implemented as a Ring handler:
>
>https://github.com/cemerick/drawbridge
>
> It also provides a client-side nREPL transport using clj-http that extends 
> nREPL's url-connect; the intention is that any tool that uses url-connect 
> will be able to transparently connect to and use an HTTP nREPL endpoint 
> simply by specifying an http:// URL instead of e.g. an nrepl:// one.
>
> I hope this will prove to be a reasonable "reference implementation" of both 
> an alternative nREPL transport as well as of an effective HTTP/HTTPS 
> transport to enable many applications that couldn't reasonably be built using 
> other protocols.
>
> I welcome your questions, bugs, usage reports, etc.
>
> Thanks,
>
> - Chas
>
> --
> [Clojure Programming from O'Reilly](http://www.clojurebook.com)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

2012-03-29 Thread Shantanu Kumar


On Mar 29, 11:46 pm, Cedric Greevey  wrote:
> On Thu, Mar 29, 2012 at 2:36 PM, Shantanu Kumar
>
>
>
>
>
>
>
>
>
>  wrote:
> >> 81  (defn foo [...]
> >> 82    (let [x (compute-something ...)]
> >> 83      (do-something x ...)
> >> 84      (calculate-whatever ...)))
>
> >> and you're able to edit lines 82, 83, and 84 but not line 81 (or
> >> whatever). But I can't see any plausible circumstance where that would
> >> be the case.
>
> > That's exactly the case. Somebody else owns/maintains `foo` and other
> > functions/macros that `foo` corresponds with. I am only going to put
> > in a macro in the body of `foo` in order to provide some value that is
> > orthogonal to foo's main intent. There are several such functions
> > (like `foo`) where I have to put in the macro. As I am not the owner
> > of that code it does not make sense (from maintenance standpoint,
> > currently) to control the way they are defined. Hope that clarifies.
>
> It still doesn't make sense. If you have permission to edit the
> function, you have permission to edit the first line of the function.
> And regardless you could substitute a different version of defn
> throughout that namespace.

The change needs to be least intrusive and doesn't justify exposing
more surface area than it should. It's a trade off.

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: The rationale behind mutable namespaces?

2012-03-29 Thread Alf Kristian Støyle
Thanks Herwig, makes sense.

Cheers,
Alf
On Mar 29, 2012 1:37 PM, "Herwig Hochleitner" 
wrote:

> 2012/3/29 Alf Kristian Støyle :
> > So, long story short, why are namespaces in Clojure mutable? What is
> > the rationale behind this?
>
> It's for REPL development. Everytime you redefine a function, its Var
> needs to be updated.
>
> OTOH, redefining a var during the normal course of operation is frowned
> upon.
> For this reason, defs should always be top level (modulo an enclosing
> let, or something).
>
> The only official way to change a Var value during normal operation is
> binding, which is thread local and dynamically scoped (bound Vars can
> also be set! while bound, still thread locally), so its semantics are
> well defined, if a bit more obscure than normal lexical/immutable let.
>
> kind regards
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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: Using the Clojure Logo

2012-03-29 Thread Chip Collier

On 3/29/12 12:33 AM, Marco Dalla Stella wrote:
> Il 26 marzo 2012 16:33, Marco Dalla Stella  ha 
> scritto:
>> Hi,
>>
>> We would like to use the Clojure logo for our new Italian Clojure User Group.
> Thank you all for your kind answer.
> We are not going to use any logo until Rich will give us his permission.
> It will be great if something like the "powered by Clojure" logos were
> to be available to the public without requiring permission, as other
> languages do.
>
> HAND,

Seconded. :)



signature.asc
Description: OpenPGP digital signature


Re: ClojureScript gets PersistentVectors

2012-03-29 Thread László Török
It has been a great learning experience on both Clojure internals and the
Clojurescript side.
One thing to note, that the handwritten JS (which also a straight port of
the java version and not optimized by the closure compiler) still
outperforms the Clojurescript version consistently by at least a factor of
3-3.5x on V8 and slightly on other engines.

It would be interesting to see why. I suspect that the code generated by
cljsc can be improved a lot and currently it does not always lend itself to
agressive inlining. (pure speculation, yet to be confirmed)
On the other hand, I understand that there are certain conventions that
have to be observed for CLJS abstractions like protocols etc. to work.

I'm interested to hear opinions and directions on where to go from hear:
chunked sequences and transient will certainly deliver a performance boost.
How about pods? Is there a design written up out there?

Is there a clojure experimental implementation on separate branch?

Las

2012/3/29 Evan Mezeske 

> This is excellent.  Big thanks to Laszlo!  I've been working on
> a Raphaël-based interactive GUI app in ClojureScript that maintains a big
> vector of elements, and had just recently started to run into what seemed
> to be the performance limits of the copy-on-write approach.  I'm very
> optimistic that this feature will allow me to keep using vectors instead of
> dropping down to mutable host arrays, which is a big win.  I can't wait to
> try this.
>
> -Evan
>
>
> On Thursday, March 29, 2012 2:31:10 PM UTC-7, David Nolen wrote:
>>
>> Thanks to Laszlo Török, ClojureScript now has PersistentVectors,
>> https://github.com/clojure/**clojurescript/commit/**
>> e615f4cd326e7c608050272c64c4df**aff9a34689
>> .
>>
>> They are based on the Java implementations found in Clojure. I'm happy to
>> say they thoroughly trounce the old copy-on-write Vectors:
>>
>> http://jsperf.com/**persistentvector-norecur-js/11
>>
>> Note how much room for improvement we have on JS engines like V8 :)
>>
>> David
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
>
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en




-- 
László Török

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

Re: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-29 Thread David Cabana
> "Very likely" strikes me as a huge overstatement here. Most sequences
> that you want to average won't be source-code literals, they'll be
> lazy sequences, and those aren't counted

Point taken about lazy sequences. But the above was not intended to
suggest the sequence needs to be source code literal to satisfy
'counted?', rather that vectors, lists, maps, and sets do so.  That
covers a fair bit of ground.

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


Re: ClojureScript gets PersistentVectors

2012-03-29 Thread Evan Mezeske
This is excellent.  Big thanks to Laszlo!  I've been working on 
a Raphaël-based interactive GUI app in ClojureScript that maintains a big 
vector of elements, and had just recently started to run into what seemed 
to be the performance limits of the copy-on-write approach.  I'm very 
optimistic that this feature will allow me to keep using vectors instead of 
dropping down to mutable host arrays, which is a big win.  I can't wait to 
try this.

-Evan

On Thursday, March 29, 2012 2:31:10 PM UTC-7, David Nolen wrote:
>
> Thanks to Laszlo Török, ClojureScript now has PersistentVectors, 
> https://github.com/clojure/clojurescript/commit/e615f4cd326e7c608050272c64c4dfaff9a34689
> . 
>
> They are based on the Java implementations found in Clojure. I'm happy to 
> say they thoroughly trounce the old copy-on-write Vectors:
>
> http://jsperf.com/persistentvector-norecur-js/11
>
> Note how much room for improvement we have on JS engines like V8 :)
>
> David 
>

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

Drawbridge: a (Ring) HTTP transport for nREPL

2012-03-29 Thread Chas Emerick
Drawbridge is an HTTP/HTTPS nREPL transport, implemented as a Ring handler:

https://github.com/cemerick/drawbridge

It also provides a client-side nREPL transport using clj-http that extends 
nREPL's url-connect; the intention is that any tool that uses url-connect will 
be able to transparently connect to and use an HTTP nREPL endpoint simply by 
specifying an http:// URL instead of e.g. an nrepl:// one.

I hope this will prove to be a reasonable "reference implementation" of both an 
alternative nREPL transport as well as of an effective HTTP/HTTPS transport to 
enable many applications that couldn't reasonably be built using other 
protocols.

I welcome your questions, bugs, usage reports, etc.

Thanks,

- Chas

--
[Clojure Programming from O'Reilly](http://www.clojurebook.com)

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


ClojureScript gets PersistentVectors

2012-03-29 Thread David Nolen
Thanks to Laszlo Török, ClojureScript now has PersistentVectors,
https://github.com/clojure/clojurescript/commit/e615f4cd326e7c608050272c64c4dfaff9a34689
.

They are based on the Java implementations found in Clojure. I'm happy to
say they thoroughly trounce the old copy-on-write Vectors:

http://jsperf.com/persistentvector-norecur-js/11

Note how much room for improvement we have on JS engines like V8 :)

David

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

Re: partition-distinct

2012-03-29 Thread Weber, Martin S
Meh. Half-assed (mis)reading. Sorry. -Martin

On 2012-03-29 16:23 , "Weber, Martin S"  wrote:

>Yeah I don't like that either. Consider (comp vals (partial group-by
>identity)).
>
>On 2012-03-29 16:18 , "David Jagoe"  wrote:
>
>>Hi all,
>>I'm sure I'm missing a really simple way of doing this!
>>
>>Given a sequence like this: [1 2 1 2 1 1 2 1 2 2 2]
>>
>>partition it to get this: [(1 2) (1 2) (1) (1 2) (1 2) (2) (2)]
>>
>>I've been trying to write something generic like partition-by because the
>>values are maps. Also I want to be able to deal with more than 2 distinct
>>values.
>>
>>Thanks!
>>
>>-- 
>>David Jagoe
>>
>>davidja...@gmail.com
>>+447535268218
>>
>>
>>
>>
>>-- 
>>You received this message because you are subscribed to the Google
>>Groups "Clojure" group.
>>To post to this group, send email to clojure@googlegroups.com
>>Note that posts from new members are moderated - please be patient with
>>your first post.
>>To unsubscribe from this group, send email to
>>clojure+unsubscr...@googlegroups.com
>>For more options, visit this group at
>>http://groups.google.com/group/clojure?hl=en
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Clojure" group.
>To post to this group, send email to clojure@googlegroups.com
>Note that posts from new members are moderated - please be patient with
>your first post.
>To unsubscribe from this group, send email to
>clojure+unsubscr...@googlegroups.com
>For more options, visit this group at
>http://groups.google.com/group/clojure?hl=en

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


Re: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-29 Thread Alan Malloy
On Mar 29, 10:18 am, David Cabana  wrote:
> On Thu, Mar 29, 2012 at 12:18 AM, simon.T  wrote:
> > The obvious way is like the following, which traverse the sequence 2 times.
> > ...
>
> The obvious way does not necessarily traverse the sequence twice.  If
> a sequence S satisfies the 'counted?' predicate, (count S) takes
> constant time. In particular
> user=> (counted? [:a :b :c])
> true
>
> user=> (counted? '(:a :b :c))
> true
>
> user=> (counted? {:a 1 :b 2 :c 3})
> true
>
> user=> (counted? #{:a :b :c})
> true
>
> The examples are stolen 
> from:http://clojuredocs.org/clojure_core/clojure.core/counted_q
>
> So it is very likely that (/ (reduce + coll) (count coll)) will not
> traverse 'coll' twice, and the natural way is the preferred way.
> 

"Very likely" strikes me as a huge overstatement here. Most sequences
that you want to average won't be source-code literals, they'll be
lazy sequences, and those aren't counted.

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

2012-03-29 Thread Weber, Martin S
Yeah I don't like that either. Consider (comp vals (partial group-by
identity)).

On 2012-03-29 16:18 , "David Jagoe"  wrote:

>Hi all,
>I'm sure I'm missing a really simple way of doing this!
>
>Given a sequence like this: [1 2 1 2 1 1 2 1 2 2 2]
>
>partition it to get this: [(1 2) (1 2) (1) (1 2) (1 2) (2) (2)]
>
>I've been trying to write something generic like partition-by because the
>values are maps. Also I want to be able to deal with more than 2 distinct
>values.
>
>Thanks!
>
>-- 
>David Jagoe
>
>davidja...@gmail.com
>+447535268218
>
>
>
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Clojure" group.
>To post to this group, send email to clojure@googlegroups.com
>Note that posts from new members are moderated - please be patient with
>your first post.
>To unsubscribe from 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: Using the Clojure Logo

2012-03-29 Thread Donald Lindsay
Considering what I've seen of other lisp logos, I'd 'polly want to see a
preview.

It's Lisp, the 3 -rlt &entiti cassius  ~/dev/null

On Wednesday, March 28, 2012, Dimitrios wrote:

> On 28/03/12 13:12, Stuart Sierra wrote:
>
>> Rich Hickey holds the copyright on the Clojure logo design, and it's not
>> under an open-source license.
>>
>> He has asked that the logo not be used to refer to anything except the
>> language itself.
>>
>
> Does that mean it can be used freely by anyone (presentations/web-sites
> etc) as long as it refers to Clojure itself?
>
> 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: partition-distinct

2012-03-29 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 4:18 PM, David Jagoe  wrote:
> Hi all,
>
> I'm sure I'm missing a really simple way of doing this!
>
> Given a sequence like this: [1 2 1 2 1 1 2 1 2 2 2]
>
> partition it to get this: [(1 2) (1 2) (1) (1 2) (1 2) (2) (2)]
>
> I've been trying to write something generic like partition-by because the
> values are maps. Also I want to be able to deal with more than 2 distinct
> values.
>
> Thanks!

(defn partition-distinct [s]
  (lazy-seq
(loop [seen #{} s (seq s) part []]
  (if s
(let [[f & r] s]
  (if (seen f)
(cons (seq part) (partition-distinct s))
(recur (conj seen f) r (conj part f
(if-let [part (seq part)]
  (list part))

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


partition-distinct

2012-03-29 Thread David Jagoe
Hi all,

I'm sure I'm missing a really simple way of doing this!

Given a sequence like this: [1 2 1 2 1 1 2 1 2 2 2]

partition it to get this: [(1 2) (1 2) (1) (1 2) (1 2) (2) (2)]

I've been trying to write something generic like partition-by because the
values are maps. Also I want to be able to deal with more than 2 distinct
values.

Thanks!

-- 
David Jagoe

davidja...@gmail.com
+447535268218

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

2012-03-29 Thread Herwig Hochleitner
2012/3/29 Alf Kristian Støyle :
> So, long story short, why are namespaces in Clojure mutable? What is
> the rationale behind this?

It's for REPL development. Everytime you redefine a function, its Var
needs to be updated.

OTOH, redefining a var during the normal course of operation is frowned upon.
For this reason, defs should always be top level (modulo an enclosing
let, or something).

The only official way to change a Var value during normal operation is
binding, which is thread local and dynamically scoped (bound Vars can
also be set! while bound, still thread locally), so its semantics are
well defined, if a bit more obscure than normal lexical/immutable let.

kind regards

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

2012-03-29 Thread Sean Corfield
On Thu, Mar 29, 2012 at 6:41 AM, Chris Webster  wrote:
> Is there an alternative/mirror site for downloading Clojure, or do I just
> have to wait until the main site is working again?

You might want to start with Leiningen since that will hide all of the
classpath / dependency issues for you. If you're on Mac/Linux, it's a
single shell script download. If you're on Windows, it's a .bat file
and a .jar file. You get a nice REPL and full project / build support.
It's the way most people develop with Clojure.

https://github.com/technomancy/leiningen
-- 
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: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 2:36 PM, Shantanu Kumar
 wrote:
>> 81  (defn foo [...]
>> 82    (let [x (compute-something ...)]
>> 83      (do-something x ...)
>> 84      (calculate-whatever ...)))
>>
>> and you're able to edit lines 82, 83, and 84 but not line 81 (or
>> whatever). But I can't see any plausible circumstance where that would
>> be the case.
>
> That's exactly the case. Somebody else owns/maintains `foo` and other
> functions/macros that `foo` corresponds with. I am only going to put
> in a macro in the body of `foo` in order to provide some value that is
> orthogonal to foo's main intent. There are several such functions
> (like `foo`) where I have to put in the macro. As I am not the owner
> of that code it does not make sense (from maintenance standpoint,
> currently) to control the way they are defined. Hope that clarifies.

It still doesn't make sense. If you have permission to edit the
function, you have permission to edit the first line of the function.
And regardless you could substitute a different version of defn
throughout that namespace.

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

2012-03-29 Thread Shantanu Kumar
> 81  (defn foo [...]
> 82    (let [x (compute-something ...)]
> 83      (do-something x ...)
> 84      (calculate-whatever ...)))
>
> and you're able to edit lines 82, 83, and 84 but not line 81 (or
> whatever). But I can't see any plausible circumstance where that would
> be the case.

That's exactly the case. Somebody else owns/maintains `foo` and other
functions/macros that `foo` corresponds with. I am only going to put
in a macro in the body of `foo` in order to provide some value that is
orthogonal to foo's main intent. There are several such functions
(like `foo`) where I have to put in the macro. As I am not the owner
of that code it does not make sense (from maintenance standpoint,
currently) to control the way they are defined. Hope that clarifies.

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


The rationale behind mutable namespaces?

2012-03-29 Thread Alf Kristian Støyle
Hi guys. First off, love Clojure and it has been a hobby of mine for
several years. When first learning Clojure, one thing I didn't like,
was the ability to actually change a Var at any point in time. Either
through several def/defn's pointing to the same namespace/symbol or by
something like alter-var-root. I kind of accepted it, it is a nice
dynamic feature of Clojure, but still it feels somewhat weird and in
contrast to (mostly) everything else being immutable.

Yesterday I was doing Clojure Koans with a friend who really wanted to
learn Clojure. When he first understood the mutable nature of Vars, he
was really turned off by it. I could actually see his disappointment.
He asked me what the rationale for this was, and I was not able to
tell him.

So, long story short, why are namespaces in Clojure mutable? What is
the rationale behind this?

The next time someone asks me, I would like to be prepared :)

Cheers,
Alf

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

2012-03-29 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 1:10 PM, Stuart Sierra
 wrote:
> Rich's request is that people not use the logo for purposes other than to
> represent the Clojure language.

How does he define "represent the Clojure language"? Just that its
use, in a particular instance, is to refer to Clojure?

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

2012-03-29 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 1:07 PM, Daniel Gagnon  wrote:
>> First of all, one only has to police unauthorized use of the
>> trademark. One can authorize its use under particular circumstances,
>> and then those uses don't need to be policed to avoid losing the
>> trademark.
>
> That's at the heart of trademark law. A trademark is a form of "Proof of
> origin". If you see Mickey Mouse in a movie, you can assume it's Disney.
> This is why you can lose trademarks. If you let people use it for whatever
> they want then it's not a proof of origin any more.

You seem to be confusing "not policing the mark" with "explicitly
licensing it for some uses". Only the former can result in losing the
mark.

>> Second, trademark law only covers "use in commerce". Use on a personal
>> webpage would not be covered, and would not have to be policed or risk
>> losing the mark. Use on a commercial site (which might be broadly
>> inclusive of, for instance, pages with revenue-generating ads) might
>> be another matter, if it's seen as implying an endorsement or a claim
>> to be the product/service the mark names. But...
>
> No you can't.

No, you can't what? Use it noncommercially? Sure you can.

To prevail on a trademark infringement claim for a registered
trademark, a plaintiff must establish that: "(1) it has a valid mark
that is entitled to protection under the Lanham Act; and that (2)
defendant used the mark; (3) in commerce; (4) 'in connection with the
sale ... or advertising of goods or services' ... (5) without the
plaintiff's consent." 1-800 Contacts, Inc. v. WhenU.com, Inc., 414
F.3d 400, 406 (2d Cir. 2005) (citing 15 U.S.C. §1114(1)(a)).

>> Third, use of the mark in a purely factual manner is not, to my
>> knowledge, governed by law. So, a store needn't negotiate a license
>> with Coca Cola Inc. to say they have Coca Cola for sale, at least as
>> long as they aren't lying. Saying a site is powered by X, when it
>> really is powered by X, may fall under the same rule, given that
>> there's no implication that the site *is* X or is endorsed by X.
>
> It is actually the purpose of the law. If you see the Coca Cola logo in a
> store, you can expect genuine Coca Cola.

Likewise, it is the purpose of the law that if you see the Clojure
logo on a web site you can expect genuine Clojure. Your point being?

>> Identifying a noncommercial user group as a Clojure user group would
>> be analogous to identifying a noncommercial Web site as powered by
>> Clojure, to my mind. Trademark law would not apply, and Rich wouldn't
>> risk losing the trademark by not sending a lawyer after the group.
>
> It absolutely would.

Not to a noncommercial use. See above.

>> However, an earlier post claimed Rich had *copyrighted* the logo,
>> which is another kettle of fish.
>
> Copyright is automatic since 1976. All registration does is having the
> copyright office they did see your work on a given date. It is by no mean a
> requirement.

It's a requirement to go after statutory damages for an alleged
infringement. Without a registered copyright you might go after direct
damages (probably zero in this case) or an injunction to stop the
unwanted use but that's about it.

Also, "copyrighted it" in this sort of context tends to mean "intends
to actually use the copyright to control use". Most things with
automatic copyright also have unenforced copyright because the
copyright holder doesn't care. Mailing list messages like this one,
for example. Generally the copyright gets registered if the holder
intends to enforce it, so they can go after statutory damages if
there's an infringement.

> Using the logo seems fair use to me. However trademark and copyright laws
> are independent. You can infringe one one while respecting the other.

I didn't claim otherwise.

>> Personally, I think it would be silly to block uses of the logo to
>> refer to Clojure in circumstances that don't imply an endorsement that
>> doesn't exist, but obviously Rich is not obligated to share my opinion
>> of what would be silly.
>
> I think we would avoid lots of headaches and legal gray areas by having
> official "powered by" logos.

I agree.

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

2012-03-29 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 11:35 AM, Shantanu Kumar
 wrote:
>
>
> On Mar 29, 5:50 pm, Cedric Greevey  wrote:
>> On Wed, Mar 28, 2012 at 11:48 PM, Shantanu Kumar
>>
>>  wrote:
>> >> If you control the third line of:
>>
>> >> (defn foo [x y]
>> >>   (let [z (bar y (next x))]
>> >>     (println "Done in " (find-name) ".")
>> >>     (* 4 z (count x
>>
>> >> then don't you control the first?
>>
>> > Cedric – Unfortunately, no. The target is pre-written code that may
>> > have been created using (1) clojure.core/defn or (2) several `defxyz`
>> > kind of macros already. Injecting a macro that internally uses `find-
>> > name` is something I can do, hence this need.
>>
>> If you can replace some other macro that code's source uses, surely
>> you can also replace defn? You'd need to inject the clojure.core/defn
>> wrapper into the other function's namespace, but you'd have to do that
>> with the other macro anyway.
>
> Cedric – I meant "inject" as in into the body, not to alter/wrap the
> macro itself that defines the function. So, effectively I alter/wrap
> neither of `defn` and `defxyz` macros.

You're not making sense.

There are two cases.

Either you can directly edit the source code for the function, in
which case you can substitute a modified defn;

Or you cannot, but you can cause it to compile with a substituted
version of one of the functions, macros, etc. that it references, in
which case you can cause it to compile with a substituted version of
the defn macro.

What you're suggesting would only make sense if you have a source file
with a function like this:

81  (defn foo [...]
82(let [x (compute-something ...)]
83  (do-something x ...)
84  (calculate-whatever ...)))

and you're able to edit lines 82, 83, and 84 but not line 81 (or
whatever). But I can't see any plausible circumstance where that would
be the case.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-29 Thread David Cabana
On Thu, Mar 29, 2012 at 12:18 AM, simon.T  wrote:
> The obvious way is like the following, which traverse the sequence 2 times.
> ...

The obvious way does not necessarily traverse the sequence twice.  If
a sequence S satisfies the 'counted?' predicate, (count S) takes
constant time. In particular
user=> (counted? [:a :b :c])
true

user=> (counted? '(:a :b :c))
true

user=> (counted? {:a 1 :b 2 :c 3})
true

user=> (counted? #{:a :b :c})
true

The examples are stolen from:
http://clojuredocs.org/clojure_core/clojure.core/counted_q

So it is very likely that (/ (reduce + coll) (count coll)) will not
traverse 'coll' twice, and the natural way is the preferred way.


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

2012-03-29 Thread Daniel Gagnon
>
> As far as I know the Clojure logo is not currently trademarked.
>

You can have a trademark without registering anything (registration is
somewhere between $200 and $300 in the US, I forgot the exact amount), it's
just harder to demonstrate without a registration than copyright.

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

2012-03-29 Thread Stuart Sierra
There must be something strange going on. The Clojure 1.3 ZIP file is only 
4.5 MB.

The Clojure distribution is published through the public Maven repository 
system, which has many mirrors:
http://docs.codehaus.org/display/MAVENUSER/Mirrors+Repositories

For example, here's one mirror of Clojure 1.3:
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/clojure/clojure/1.3.0/

-S


On Thursday, March 29, 2012 9:41:13 AM UTC-4, Chris Webster wrote:
>
> I'm hoping to start learning Clojure (via The Joy Of Clojure book), but 
> I'm having trouble downloading Clojure 1.3 from the  
> http://clojure.org/downloads site.  It downloads maybe 50 or 100 MB very 
> slowly, then grinds to a halt saying the download was interrupted (on 
> Google Chrome browser). Other download sites are working fine witht eh same 
> browser/network connection etc, but I've been trying Clojure at regular 
> intervals all day and keep getting the same problem.
>
> Is there an alternative/mirror site for downloading Clojure, or do I just 
> have to wait until the main site is working again?
>

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

2012-03-29 Thread Chris Webster
I'm hoping to start learning Clojure (via The Joy Of Clojure book), but I'm 
having trouble downloading Clojure 1.3 from the  
http://clojure.org/downloads site.  It downloads maybe 50 or 100 MB very 
slowly, then grinds to a halt saying the download was interrupted (on 
Google Chrome browser). Other download sites are working fine witht eh same 
browser/network connection etc, but I've been trying Clojure at regular 
intervals all day and keep getting the same problem.

Is there an alternative/mirror site for downloading Clojure, or do I just 
have to wait until the main site is working again?

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

Re: Clojure Toolbox

2012-03-29 Thread Qihui Sun
Thank you all!
谢谢!

2012/3/25 dennis zhuang 

> Another link http://cnlojure.org/open.html
>
>
> 2012/3/24 Rostislav Svoboda 
>
>> A nice list of tools and libraries I stumbled upon. Enjoy!
>>
>> http://www.clojure-toolbox.com/
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
>
>
>
> --
> 庄晓丹
> Email:killme2...@gmail.com xzhu...@avos.com
> Site:   http://fnil.net
> Twitter:  @killme2008
>
>
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
Solomon
HUAWEI 
Google+: Qihui Sun 

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

2012-03-29 Thread Stuart Sierra
Please let's not get into a discussion of Copyright or Trademark law.

As far as I know the Clojure logo is not currently trademarked.

Rich's request is that people not use the logo for purposes other than to 
represent the Clojure language.

-S

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

2012-03-29 Thread Daniel Gagnon
>
> First of all, one only has to police unauthorized use of the
> trademark. One can authorize its use under particular circumstances,
> and then those uses don't need to be policed to avoid losing the
> trademark.
>
>
That's at the heart of trademark law. A trademark is a form of "Proof of
origin". If you see Mickey Mouse in a movie, you can assume it's Disney.
This is why you can lose trademarks. If you let people use it for whatever
they want then it's not a proof of origin any more.


> Second, trademark law only covers "use in commerce". Use on a personal
> webpage would not be covered, and would not have to be policed or risk
> losing the mark. Use on a commercial site (which might be broadly
> inclusive of, for instance, pages with revenue-generating ads) might
> be another matter, if it's seen as implying an endorsement or a claim
> to be the product/service the mark names. But...
>

No you can't. That leads to trademark dilution.


> Third, use of the mark in a purely factual manner is not, to my
> knowledge, governed by law. So, a store needn't negotiate a license
> with Coca Cola Inc. to say they have Coca Cola for sale, at least as
> long as they aren't lying. Saying a site is powered by X, when it
> really is powered by X, may fall under the same rule, given that
> there's no implication that the site *is* X or is endorsed by X.
>

It is actually the purpose of the law. If you see the Coca Cola logo in a
store, you can expect genuine Coca Cola.

"Powered by" may or may not count, I don't think it has been tested in a
court of law.


> Identifying a noncommercial user group as a Clojure user group would
> be analogous to identifying a noncommercial Web site as powered by
> Clojure, to my mind. Trademark law would not apply, and Rich wouldn't
> risk losing the trademark by not sending a lawyer after the group.
>

It absolutely would. Not sure if it would be fine or not as mentioned
above.


> However, an earlier post claimed Rich had *copyrighted* the logo,
> which is another kettle of fish.


Copyright is automatic since 1976. All registration does is having the
copyright office they did see your work on a given date. It is by no mean a
requirement.


> On the one hand there's no need to
> police use or risk losing a copyright; on the other, a copyright
> covers noncommercial use as well as commercial. I'm not sure how
> copyrightable a fairly simple logo design really is, though. There are
> circumstances that exempt one from needing a copyright license, "fair
> use", that tend to include noncommercial activities that don't harm
> the copyright holder's market. If Rich has copyrighted the logo, but
> isn't selling copies or cheap licenses to use it, a noncommercial use
> might well be found to be a fair use.
>

Using the logo seems fair use to me. However trademark and copyright laws
are independent. You can infringe one one while respecting the other.



> Personally, I think it would be silly to block uses of the logo to
> refer to Clojure in circumstances that don't imply an endorsement that
> doesn't exist, but obviously Rich is not obligated to share my opinion
> of what would be silly.


I think we would avoid lots of headaches and legal gray areas by having
official "powered by" logos.

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

Re: Clojure-Specific Emacs Environment

2012-03-29 Thread Phil Hagelberg
On Thu, Mar 29, 2012 at 12:48 AM, ian.tegebo  wrote:
> Is anyone working on a Clojure-Specific Emacs Environment?  If considered
> but dismissed, then why?

The problem is that swank-clojure+slime offers a local maximum. While
there are difficulties working with CL and Clojure at the same time,
it seems that most people lose interest in CL after using Clojure for
a while. Maybe swank-js changes the equation a bit.

While there would be benefits to implementing an elisp frontend to
nrepl, it would be a lot of work before it would catch up with what
we've already got. The swank-clojure codebase is ancient, and since
its original author abandoned it, there's no one who really
understands it and is willing to hack on it apart from simple
maintenance tasks.

Anyway, I'd be happy if someone went ahead with nrepl.el even so;
don't let me discourage you.

Nearly all the code in clojure-mode is orthogonal to swank/slime; it's
focused around static font-lock and indentation rather than
interacting with a live process. There's slime-specific stuff in
clojure-test-mode, but it would be pretty trivial to make it work with
another interface.

-Phil

> 
>
> I've just reviewed a thread about nREPL.  The thread also (somewhat
> indirectly) calls into question the current practice of piggy-backing on
> SLIME:
>
> "About a networked REPL..."
> https://groups.google.com/d/topic/clojure/iyqFHXkO0Mw/discussion
>
> I also see a GSoC project,
> http://dev.clojure.org/display/community/Google+Summer+of+Code+2012#GoogleSummerofCode2012-EmacsIDE
> (I realize that this project's existence is probably my answer, but I
> thought I'd check anyway.)
>
> And lastly, this design page,
> http://dev.clojure.org/display/design/IDE+tooling+backend
>
> There also seems to be no shortage of (revised/deprecated) howto's and
> confusion regarding Emacs and SLIME.  I can't help but think that this is at
> least in part due to SLIME's release process and the various ways that
> Clojure is not Common Lisp.  There also appears to have been some back and
> forth on the slime-devel list that may exemplify this.
>
> In any case, the fact remains that I still can't get the workaround to work
> as smoothly as I'd like (for both an old and new installation of SLIME):
>
> https://github.com/technomancy/swank-clojure/issues/66
> (I can switch once between CL and Clojure, but then I get errors.)
>
> While it may make sense to just fix the issues with maintaining multiple
> versions of SLIME, all the facts seem to point towards a Clojure-Specific
> Emacs Environment.
>
> That said, there's certainly been a lot of work that's gone into
> swank-clojure, clojure-mode, and clojure-test-mode so I can understand the
> queasiness involved with a rewrite.  Also, I imagine that the CL part of the
> community is quite small.  However, I'd also like to use swank-js with a
> newer SLIME than currently works with clojure-mode as it appears to be the
> best REPL integration for Javascript.  I imagine that the Javascript part of
> the Clojure community is quite a bit larger (although the
> Emacs+desire+for+REPL constraint certainly restricts that amount).
>
> Finally, we get to the point.  Tool development is essential. And right now
> my tools are becoming clojure-mode and things like kibit, slamhound,
> swank-js, SLIME, and redshank.  I've tried to understand SLIME's
> implementation a few times already.  At this point, I need to be able to
> improve Clojure related tools a lot more than CL ones.  If I can defer
> understanding SLIME, the more the better.  Lastly, I expect a rewrite could
> stay relatively clean given that quite a bit of work can be pushed into
> nREPL related tooling...where we can write in Clojure!
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from 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: Source code as metadata

2012-03-29 Thread Phil Hagelberg
On Thu, Mar 29, 2012 at 9:29 AM, Petr Gladkikh  wrote:
> I am pondering on the idea of having more (or even a lot) of metadata
> that could be useful for debugging and problem resolution.
> Since we can store anything in metadata, can we store not only  source
> file path and line number but whole source code that is associated
> with piece of code?

See https://github.com/technomancy/serializable-fn/ for a
proof-of-concept of this idea.

It's always bothered be that defn puts metadata on the var and not on
the function itself.

Anyway, supposedly Rich is in favour of having "dynamicity knobs"
according to his Conj 2011 keynote, and this sounds like just the kind
of thing that would fall under that.

-Phil

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


Source code as metadata

2012-03-29 Thread Petr Gladkikh
I am pondering on the idea of having more (or even a lot) of metadata
that could be useful for debugging and problem resolution.
Since we can store anything in metadata, can we store not only  source
file path and line number but whole source code that is associated
with piece of code?
For example, for a function we can store it's complete source code.
This way, when some piece of code throws NPE, tooling can show context
of that piece of code that caused problem (e.g. highlight it in
editor).
So, even if Clojure reader does not know actual file and line of
source code user can infer the location of code by matching structure
of code (and some tooling can do that automatically). Such information
could be especially helpful for anonymous functions.

Example:
; Source
(defn c [d]
  (#(/ % d) 13))

; REPL
(c nil)

; Ouput
NullPointerException
clojure.lang.Numbers.ops (Numbers.java:942)
clojure.lang.Numbers.divide (Numbers.java:154)
petrglad.bugs/c/fn--786 (bugs.clj:17)
petrglad.bugs/c (bugs.clj:17)
petrglad.bugs/eval791 (NO_SOURCE_FILE:1)
clojure.lang.Compiler.eval (Compiler.java:6465)
clojure.lang.Compiler.eval (Compiler.java:6431)
clojure.core/eval (core.clj:2795)
clojure.main/repl/read-eval-print--5967 (main.clj:244)
clojure.main/repl/fn--5972 (main.clj:265)
clojure.main/repl (main.clj:265)
clojure.tools.nrepl.middleware.interruptible-eval/evaluate
(interruptible_eval.clj:41)

In this case code is simple and I can guess what is happening by line
number. But what if there are more than one anonymous functions and
more operations in same line?

If source code is associated with that function it can be attached to
the exception and message could instead look like
NullPointerException in #(/ % d)
in (defn c [d] ( ... 13))
in bugs.clj line 17

I have been using Clojure occasionally for some development automation
so I could be missing something.
What do you think of this idea?

-- 
Petr Gladkikh

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

2012-03-29 Thread Shantanu Kumar


On Mar 29, 5:50 pm, Cedric Greevey  wrote:
> On Wed, Mar 28, 2012 at 11:48 PM, Shantanu Kumar
>
>  wrote:
> >> If you control the third line of:
>
> >> (defn foo [x y]
> >>   (let [z (bar y (next x))]
> >>     (println "Done in " (find-name) ".")
> >>     (* 4 z (count x
>
> >> then don't you control the first?
>
> > Cedric – Unfortunately, no. The target is pre-written code that may
> > have been created using (1) clojure.core/defn or (2) several `defxyz`
> > kind of macros already. Injecting a macro that internally uses `find-
> > name` is something I can do, hence this need.
>
> If you can replace some other macro that code's source uses, surely
> you can also replace defn? You'd need to inject the clojure.core/defn
> wrapper into the other function's namespace, but you'd have to do that
> with the other macro anyway.

Cedric – I meant "inject" as in into the body, not to alter/wrap the
macro itself that defines the function. So, effectively I alter/wrap
neither of `defn` and `defxyz` macros.

Sun – I see your point but the functions are pre-written and quite
interwoven. I cannot change the way functions are invoked.

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: SubVec anomaly

2012-03-29 Thread Andy Fingerhut
Thanks for the catch.  Bug report with patch created:

http://dev.clojure.org/jira/browse/CLJ-962

Andy

On Mar 29, 2012, at 2:15 AM, stirfoo wrote:

> 
> user=> (nth (subvec [:??? 1 2] 1) -1)
> :???
> 
> This could be a bug, not sure.
> 
> Only the upper bound of the internal SubVec is being checked.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from 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: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Cedric Greevey
On Wed, Mar 28, 2012 at 11:48 PM, Shantanu Kumar
 wrote:
>> If you control the third line of:
>>
>> (defn foo [x y]
>>   (let [z (bar y (next x))]
>>     (println "Done in " (find-name) ".")
>>     (* 4 z (count x
>>
>> then don't you control the first?
>
> Cedric – Unfortunately, no. The target is pre-written code that may
> have been created using (1) clojure.core/defn or (2) several `defxyz`
> kind of macros already. Injecting a macro that internally uses `find-
> name` is something I can do, hence this need.

If you can replace some other macro that code's source uses, surely
you can also replace defn? You'd need to inject the clojure.core/defn
wrapper into the other function's namespace, but you'd have to do that
with the other macro anyway.

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

2012-03-29 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 5:15 AM, stirfoo  wrote:
>
> user=> (nth (subvec [:??? 1 2] 1) -1)
> :???
>
> This could be a bug, not sure.
>
> Only the upper bound of the internal SubVec is being checked.

Hmm. This also raises the specter of

(let [a (some-very-large-vector-with-millions-of-elements)
  b (subvec a n (+ n 2))]
  (swap! something assoc :somekey b))

holding onto the entirety of a via the subvec. One would hope that b
would only hold onto the minimal subtree of a needed to span b, i.e.
the tree root for b would be the deepest node of a that has all the
elements of b as children. With b only a couple of elements long that
would usually mean holding onto only 32 elements of a and occasionally
1024 elements (when b was split across two of a's 32-element leaf
nodes).

That hope would be dashed:

user=> (def a (vec (range 64)))
#'user/a

user=> (let [b (subvec a 33 35)] (nth b -17))
16

user=> (let [x (vec (range 64)) b (subvec x 33 35)] (nth b -17))
16

user=> (def b (subvec a 33 35))
#'user/b

user=> (def a nil)
#'user/a

user=> (System/gc)
nil

user=> (nth b -17)
16

The bs in this instance would not have access to the first half of a/x
with that implementation, certainly not after the a vector was
completely purged by setting a to nil and doing a full GC. And yet
they do.

Subvec should be modified to hold onto the deepest node of the parent
that holds all of the subvec's elements.

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


Using JPPF in Clojure - Class Loading Issues

2012-03-29 Thread Gunnar Völkel
JPPF is a Java framework to perform distributed execution of computation 
jobs.
In my experiment to use JPPF (http://www.jppf.org) in Clojure I noticed a 
class loading problem.
A JPPFTask implemenation created via 'proxy could not be loaded by the JPPF 
framework.
As a result I got the following ClassNotFoundException: "Could not load 
class 'clj_jppf_example.core.proxy$org.jppf.server.protocol.JPPFTask$0'".
When AOT-compiling the corresponding namespace there is no problem.
But AOT-compilation seems to be a strong restriction for distributed 
computation in pure Clojure projects.

I have an example project for demonstration purposes on github: 
https://github.com/guv/clj-jppf-example

Laurent from JPPF told me that the problem is a missing cache for the 
byte[] representation of dynamically generated classes.
He suggested a change to Clojure's DynamicClassLoader that is adding an 
in-memory cache.
Most likely, an in-memory cache is not suitable in general and that change 
should be extended to an on-disk file cache in a temporary directory.

I hope we can discuss and realize a solution to use JPPF in Clojure without 
the need for AOT compilation.

Sincerely,
Gunnar

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

2012-03-29 Thread Jay Fields
It wasn't very complicated, I just started from zero experience worrying about 
this stuff.

- switch map to loop+recur
- add primitive type hints to args and return values
- make sure you get the types right (e.g. make sure your longs are longs, not 
ints)

Cheers, Jay

On Mar 28, 2012, at 10:17 PM, endbegin wrote:

> On Tuesday, March 27, 2012 2:51:41 PM UTC-4, Jay Fields wrote:
> I recently ran into some code** that was in Java, and ran in single
> digit microseconds (not millis). I converted it to clojure, and got it
> running at about the same speed... though it did take me a day to
> figure out all the tweaks.
> It can be done, if you're willing to invest the time and learn the tricks.
> 
> Cheers, Jay
> 
> 
> 
> That is good to know. Is there a place where the tricks involved were 
> documented? As in, "here" is what you should think about to get Java-like 
> performance. I've seen fragments in different places, and a lot of them 
> applied to Clojure 1.2 or earlier. Based on what I have seen on Stack 
> Overflow, it seems like if you want Java performance, then you have dig down 
> into direct Java interop, and use things like Java arrays.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from 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: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-29 Thread Rob Nagle
You can reduce in one pass with a function that tracks both the sum
and the count.

(defn avg [coll]
  (apply / (reduce (fn [[sum n] x] [(+ sum x) (inc n)]) [0 0] coll)))

This reduce function is somewhat unusual in that its arguments have
different forms. As a result, this one does require the initial-value
argument be used. It's set to [0 0] indicating the sum and count both
start at 0. The function then "consumes" the numbers in coll one at a
time, producing the running sum and count each time. Then we just
apply / to divide the sum by the count.

On Mar 28, 9:18 pm, "simon.T"  wrote:
> The obvious way is like the following, which traverse the sequence 2 times.
> Wondering what will be the efficient way...
>
> (defn avg [coll]
>   (/ (reduce + coll) (count coll)))

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-29 Thread Rick Beerendonk
> The obvious way is like the following, which traverse the sequence 2 times.
> Wondering what will be the efficient way...

(defn avg [coll]
  (loop [c coll tot 0 cnt 0]
(if (empty? c)
  (/ tot cnt)
  (recur (rest c) (+ tot (first c)) (inc cnt)

This will loop only once.
It happens to be faster, but the difference is not explained by (count
coll) elimination only. Maybe reduce is a factor as well.

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


SubVec anomaly

2012-03-29 Thread stirfoo

user=> (nth (subvec [:??? 1 2] 1) -1)
:???

This could be a bug, not sure.

Only the upper bound of the internal SubVec is being checked.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-29 Thread Linus Ericsson
or to increase a counter while reducing it, a function like inc+ returning
{:sum sum :count count} and then take the sum/counter, which is the mean.

The problem is possible to state as a clean map-reduce problem with only
one traversing of the data. It's also possible to remove items form the
mean operation (ie, the problem is associative).

/Linus

2012/3/29 simon.T 

> The obvious way is like the following, which traverse the sequence 2 times.
> Wondering what will be the efficient way...
>
> (defn avg [coll]
>   (/ (reduce + coll) (count coll)))
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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

Clojure-Specific Emacs Environment

2012-03-29 Thread ian.tegebo
tl;dr 

Is anyone working on a Clojure-Specific Emacs Environment?  If considered 
but dismissed, then why?



I've just reviewed a thread about nREPL.  The thread also (somewhat 
indirectly) calls into question the current practice of piggy-backing on 
SLIME:

"About a networked REPL..."
https://groups.google.com/d/topic/clojure/iyqFHXkO0Mw/discussion

I also see a GSoC project,
http://dev.clojure.org/display/community/Google+Summer+of+Code+2012#GoogleSummerofCode2012-EmacsIDE
(I realize that this project's existence is probably my answer, but I 
thought I'd check anyway.)

And lastly, this design page,
http://dev.clojure.org/display/design/IDE+tooling+backend

There also seems to be no shortage of (revised/deprecated) howto's and 
confusion regarding Emacs and SLIME.  I can't help but think that this is 
at least in part due to SLIME's release process and the various ways that 
Clojure is not Common Lisp.  There also appears to have been some back and 
forth on the slime-devel list that may exemplify this.

In any case, the fact remains that I still can't get the workaround to work 
as smoothly as I'd like (for both an old and new installation of SLIME):

https://github.com/technomancy/swank-clojure/issues/66
(I can switch once between CL and Clojure, but then I get errors.)

While it may make sense to just fix the issues with maintaining multiple 
versions of SLIME, all the facts seem to point towards a Clojure-Specific 
Emacs Environment.  

That said, there's certainly been a lot of work that's gone into 
swank-clojure, clojure-mode, and clojure-test-mode so I can understand the 
queasiness involved with a rewrite.  Also, I imagine that the CL part of 
the community is quite small.  However, I'd also like to use swank-js with 
a newer SLIME than currently works with clojure-mode as it appears to be 
the best REPL integration for Javascript.  I imagine that the Javascript 
part of the Clojure community is quite a bit larger (although the 
Emacs+desire+for+REPL constraint certainly restricts that amount).

Finally, we get to the point.  Tool development is essential. And right now 
my tools are becoming clojure-mode and things like kibit, slamhound, 
swank-js, SLIME, and redshank.  I've tried to understand SLIME's 
implementation a few times already.  At this point, I need to be able to 
improve Clojure related tools a lot more than CL ones.  If I can defer 
understanding SLIME, the more the better.  Lastly, I expect a rewrite could 
stay relatively clean given that quite a bit of work can be pushed into 
nREPL related tooling...where we can write in Clojure!

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

What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-29 Thread simon.T
The obvious way is like the following, which traverse the sequence 2 times.
Wondering what will be the efficient way...

(defn avg [coll]
  (/ (reduce + coll) (count coll)))

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

Re: Newbie's Guide to Learning Clojure

2012-03-29 Thread George Oliver


On Mar 28, 10:16 am, Elango Cheran  wrote:
> Hi everyone,
> On Gregg's suggestion, I want to share a writeup about how total beginners
> can learn Clojure in a minimally painful way.  I'd welcome any comments,
> suggestions, etc.

You could add a link to this guide,

http://www.unexpected-vortices.com/clojure/brief-beginners-guide/

It covers a lot of the development environment setup a beginner should
know.

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


Re: Cheap way to find function (defn) name using a macro?

2012-03-29 Thread Sun Ning
Since you want to use the plain defn, what about thinking in a different 
way ?
Write a macro like `with-function-name`, wraps the function call instead 
of the function definition.


(defmacro with-function-name [fn-name args]
  ...)

In clojure, because you can assign function to a var at any time. So the 
wrapped defn could not always work.

For example:

(defn* plus [a b] ...)
(def plus-alias plus)

Then you will call plus-alias but got the name as plus. I know this is a 
special case, but it's actually there.



On 03/28/2012 11:02 PM, Shantanu Kumar wrote:

Hi,

Is it possible to write a macro that when used in a top-level function
(created using defn) can find out the name of the immediate top-level
function? I know *ns* returns the namespace and it's possible to walk
the current thread's stack trace to find out the function name, but I
am looking for a computationally cheap way to do it.

Thanks,
Shantanu



--
Sun Ning
Software developer
Nanjing, China (N32°3'42'' E118°46'40'')
http://about.me/sunng/bio

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

2012-03-29 Thread Greg Chapman


On Mar 22, 10:18 pm, Andy Fingerhut  wrote:
> If anyone has suggestions for what you would like to see added to the 
> cheatsheet, especially _specific_ suggestions, feel free to send me email.

I was just looking at the clojure.org cheatsheet today and noticed
that it lacks links for both the type and the class functions. Seems
like both of those should be on there some place.

Greg

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

2012-03-29 Thread Marco Dalla Stella
Il 26 marzo 2012 16:33, Marco Dalla Stella  ha scritto:
> Hi,
>
> We would like to use the Clojure logo for our new Italian Clojure User Group.

Thank you all for your kind answer.
We are not going to use any logo until Rich will give us his permission.
It will be great if something like the "powered by Clojure" logos were
to be available to the public without requiring permission, as other
languages do.

HAND,
-- 
Marco Dalla Stella
web: http://thediracsea.org
twitter: http://twitter.com/kra1iz3c

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