Hello,

I've been reading this list for a while. Suppose it's time to delurk. :-)

On Thu, Jul 23, 2009 at 10:58 AM, pcda...@gmail.com <pcda...@gmail.com>wrote:
> The kind of scenario I'm worrying about is this:
> - Alice writes library foo and use a particular way to encode values
> (say simple vectors).
>  She publishes foo v1.0.
> - Bob starts using foo, and because it is so simple and convenient,
> uses desctucturing
>  everywhere.
> - Alice adds new features to version 1.1 her library, realizes the
> simple vectors are not
>  enough and decides to use hashmaps instead.
> - Bob updates to version 1.1 of foo, and some of his code starts to
> break, because all the
>  patterns he's used are now obsolete. He has no other solution than
> to audit all his code
>  to locate (not necessarily a trivial task) and update the
> destructuring patterns which
>  concern foo data.

Why didn't Alice provide a good ol' abstract data type with a few
well-behaved selectors? One example could be for pairs. Sorry for
Scheming. Say you have a cons function, which takes two arguments
and returns a pair, and you have two functions fst and snd which
are related as follows:

> (fst (cons x y)) = x
> (snd (cons x y)) = y

Now that you have this contract, you can change the underlying
implementation at will. As long as the contract holds you're okay.
The problem is actually to prove that.

> I understand that the problem would exist even without destructuring
> bindings, but from
> reading Stuart's book, it seems their use is encouraged and considered
> good style. Coming
> from an OO background which puts a strong focus on data encapsulation,
> this makes me a
> little nervous.

Relax. :-) Mainstream OOP practices clearly have their applicability limits.

> Languages like Haskell also have pattern matching, but from what I
> understand, because
> they are strongly and statically typed, incompatible changes are
> detected at compile time
> so they can easily be found and fixed.

Haskell also has existential types and abstract data types. Clojure
OTOH is deliberately dynamic, which naturally gives it more expressiveness
but also allows for some contradictions to arise.

Cheers,
Artyom Shalkhakov.

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