Yes, it is. I reworked my code and removed where it is possible global 
assignments through *def*, particulary, from the function *retract-fact*. 
But, I can not do without global mutations altogether, so I have to use 
atom, ref, agent etc., as you suggested. But, do mutation of these 
structures have better performance than simple reassignment of def? I 
understand that from theoretical point of view assignments, states, 
mutation ,.. etc. break functional cleanliness, but to solve specific 
partial tasks can we mix differnt even conflicting paradigms to gain 
maximum performance. Or not?

суббота, 9 ноября 2013 г., 13:47:54 UTC+3 пользователь Jim foo.bar написал:
>
>  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" <sor...@oogis.ru <javascript:>> 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 clo...@googlegroups.com<javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> 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.

Reply via email to