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


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