On Mon, Mar 19, 2012 at 3:56 AM, Narvius <narv...@gmail.com> wrote:

> I see several ways to achieve what I want, that is to return both the new
> world state and success status.
> 1) Compare the old and new value - doesn't seem very efficient.
>

Probably not as inefficient as you think.  Identical things are recognized
as equal right away, unequal things are almost certain to have different
hash values and be recognized as unequal immediately.  Only slow path are
large equal structures that were created by separate processes and
therefore aren't identical.


> 2) Return [new-state success?] instead of just new-state - requires too
> much acrobatics from the user of the function (which is still me, but
> whatever).
>

Probably it's more Clojuresque to return new-state or nil, and handle both
cases anywhere you call the function.  Whether you choose to return
[new-state success?] or new-state or nil, monads could help you with the
acrobatics.  That's exactly the kind of thing they are good for.

Options 3 and 4 seem like things you should avoid if you can make 1 or 2
work.

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