I am new to clojure, but it seems very interesting.

Has anyone thought about allowing "update in place"
for situations where it is safe?

Suppose you have

  (def y (tripleit x))

and you know that there is only a single reference to x
at this point, then it would be safe to implement it as

  "y takes on the storage of x and this is multiplied
   by 3 in-place".

Well, I should say it's safe as long as "x" loses scope
at this point.  The fact that y has gained its storage and
done an update in place shouldn't bother anyone or
cause any loss in purity.

This is what "uniqueness types" are used for in the
"Clean" functional lanugage.  (And logic language
Mercury uses "unique modes".)

Now I realize there is the question in Clojure of
"how do we know whether it's unique".  Clean does it
via the type system.  But one could have other
mechanisms for ensuring uniqueness.  One would be
to keep a runtime track of references and only allow an
update-in-place primitive in the case of a single reference.
If this were attempted when multiple references existed,
a runtime error would occur.

Has anyone thought about this kind of update-in-place
methodology?  It seems to be one of the reasons why
both Clean and Mercury achieve good performance.

Perhaps there are good reasons why this approach is
not workable in clojure (or not useful), but I'd be
interested to hear why.

Thanks,

Mark.

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