On Sat, Aug 22, 2009 at 11:24 PM, Michel Salim
<[email protected]>wrote:
>
> On Sat, 2009-08-22 at 23:00 -0700, bradford cross wrote:
>
> >
> > Destructuring is useful all over the place, not just for pattern
> > matching. For example, it is really useful in function parameter
> > vectors.
>
> I consider that to be an example of pattern matching, though.
As far as I understand it. Pattern matching is built from destructuring
bind, but destructuring bind is not pattern matching. Pattern matching
follows a match-when-return, or match-with-return logical flow written as:
[match_val] -> return_val
using Maikel's esample:
type foo = [ Foo of int ];
value frobnicate x =
match x with
[ Foo 5 -> do_something ()
| Foo 7 -> do_something_else ()
| Foo x -> do_more x ];
Pattern matching is a composition of destructuring bind, predicates, and
guard clauses. Destructuring bind can be used elsewhere, without predicates
or guards, in which case I don't call it pattern matching. Although maybe
I am wrong on some technical terminology, this is how I think of it.
>
> --
> Michel
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---