On May 26, 5:13 pm, Michael Jaaka <michael.ja...@googlemail.com>
wrote:
> Hi!
>
> I have some suggestions about transients (btw. 
> thehttp://clojure.org/transients
> is not linked fromhttp://clojure.org).
>
> Maybe before you give up reading the whole post I will post as first
> the digression:
> vars binding and transient are similar, however in the first case we
> have thread isolation on reading and writing with reference covering/
> hiding ability. Currently operations on transients structures seems to
> be badly interfaced in Clojure and below is a deal:
>
> Why do we have to deal with conj! and rest of foo! operations, when
> there are much more functions like update-in, assoc-in etc. what about
> them? In most my code I fail to use transient because of xyz-in
> operations. More over I know that the code is whole executed by one
> thread, since I know where the transient structure starts to exist and
> when it ends. Tracking such code is easy task to do since most fast
> compuations are free of side effects and thread intercommunication.
>
> If the whole talk is about thread isolation (which is great feature),
> then the interface should be simplified, in the way like - (transient
> x) - attaches thread (which calls transient) reference to my structure
> (object), when any other thread tries to modify x then the exception
> is thrown. When I do (persistent x), the thread reference is detached
> from the structure, so it becomes persistent and others threads can
> concurrently modify it.
>
> This would eleminate duplication of functions and allow for single
> threaded computations. This would satisfy most computations related
> with reduce operation and recurention. So easy to do, so easy to
> track, yet not in Clojure ;-(. The (transient x) and (persistent x)
> are required since the are explicit declaration of single thread
> mutation.
>
> Also it would be nice if such transient structures could be used in
> binding clasues, since I have found other adoption - for example
> thread is doing computations in a functional way - and with binded
> transients I'm gathering statistics (time measurement, bytes counting
> etc. in an imperative, side effecting, more like aspect way.)
>
> What are your thoughts?
>

The problem is that the semantics of conj and conj! are quite
different. The first promises to return a persistent immutable value
and the second promises the opposite.

> BTW. What does it mean "don't bash in place" - since for not all
> people English is not a native language I suggest to use simpler words
> in such formulations.

It means, modify in place by repeated interaction with the same
object, as in OO:

x.changeThis()
x.changeThat()
x.changeTheOther()

or, in Clojure with a transient:

;;this is bad, don't do this
(let [x (transient y)]
  (conj! x this)
  (conj! x that)
  (conj! x theOther))

the above Clojure structure would never arise by following the
guidelines of writing it functionally first.

Rich

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

Reply via email to