Hi Ru,
Think of it this way...In Java you can't declare something as public
from within a method. Ok, in Java this would break the object's contract
but even if you look at languages like python, you still don't define
global variables from within functions. I have seen python code where
functions mutate some global but never defining a global. THe reasons
are manyfold...For starters, any function that defines global vars
should not be called a function. Upon invocation it has an immediate
impact on the outside world and therefore you lose all the nice
properties of pure functions. Secondly, if you define global vars from
functions, presumably other functions will depend on these globals and
so you can immediately see you've introduced time in you program, and
the world is generally much simpler and testable without time. So
basically, if you absolutely need mutable globals then the way to do it
is to have a top-level 'def' that points to one of Clojure's reference
types (atom, ref, agent etc). Alternatively, you could have a dynamic
var that can be rebound under the 'binding' scope. That said, I am not a
big fan of dynamic-bindings and rarely (to never) use them...
hope that helps a bit,
Jim
On 08/11/13 14:43, Dimitrios Jim Piliouras wrote:
You don't generally do global variable assignment in Clojure...it is
seriously frowned upon and goes against the functional paradigm... I
need to run now and I will be busy for the next 2 hours... perhaps
someone else can explain if you are in a hurry?
On Nov 8, 2013 2:34 PM, "ru" <soro...@oogis.ru
<mailto:soro...@oogis.ru>> wrote:
Jim, please, recommend a correct solution for global variable
assignment.
John, Indeed I would prefere technique with better performance.
But, as I understand from scarce documentation, disj works with
sets. And doesn't it recursive?
пятница, 8 ноября 2013 г., 13:17:28 UTC+4 пользователь ru написал:
Dear clojure-users,
StackOverflowError clojure.lang.RT.nthFrom (RT.java:789)
I got this error message during evaluation of "count" function
call on a quite short list (about 200 elements). What can be
reasons of the error. Any hints would be greatly appreciated.
Sincerely,
Ru
--
--
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
<mailto: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
<mailto: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 unsubscribe from this group and stop receiving emails from it,
send an email to clojure+unsubscr...@googlegroups.com
<mailto:clojure%2bunsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/groups/opt_out.
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.