Francois> Pythoneers do not know, or at least, do not use).
Francois> Another problem with structure matching in Python is
Francois> that a failed matching raises an exception, something
Francois> slow for applications heavy on pattern matching. For
Francois> very simple applications however, Python easily does as
Francois> it stands.
And that's where I proposed a library, taking a "structure" (tuple,
typically), a'la (int, int,(float,str),[int]) that verifies that the
tuple matches before unpacking.
Jacek> ... yup, you prove my point exactly.
Francois> And Jacek is right, once again. One should avoid being
Francois> too judgemental, especially when not much familiar with
Francois> problems at stake. (Yet, I did
I have to admit I'm not aware of my unfamiliarity with the topic. I
was thinking of pattern matching as it is used in ocaml, assuming
scheme does the same. As you can see from a previous post, I was
asking for an example on how it would *not* work, possibly as a way to
learn something new about pattern matching. It's also an idea for a
python library. So I don't think this is entirely unproductive.
Francois> presumptuous I might have been at times
.) I know
Francois> that some people trigger their own education by
Francois> challenging others, which is not that humble to start
Francois> with, likely irritating to the challenged people, and
Francois> not looking very polite to the casual observers.
Well, I'm still waiting for the education, so far I've only got "you
don't understand" (w/ which I disagree, for now). For a non-casual
observer, "you don't understand" is much closer to a cheap ad-hominem
shot than "can you explain this, because I disagree with this
interpretation".
Francois> Hopefully, life will give you the opportunity for many
Francois> more checks!
Pattern matching is by far not limited
Francois> to strings, and whole areas of technology are either
Francois> dedicated or based on pattern matching.
Yes, this is something I actually do understand. I wasn't thinking of
regexp pattern matching at all. I was thinking of
let rec len l =
match l with
[] -> 0
| [_] -> 1
| [_;_] -> 2
| _::xs -> 1 + len xs;;
But in theory, I agree with you about the approach of "younger"
programmers [I'm an old fart, BTW; 27 years and counting]. It's just
part of the thrills of being a programmer. I just don't have enough
real work to do ATM, I'm on summer vacation ;-).
Understanding that, and the fact that I'm back to work on monday
(ouch), probably the wise thing to do is to terminate this discussion
now. I hereby declare that Jacek won, Scheme kicks Pythons rear parts
(esp. the Bigloo implementation) and I prefer Python because I Just
Don't Get It (TM).
[and lest someone misunderstand that as bitter sarcasm, it's not -
it's more the reason of getting 0.5 hours of sleep within the last 36
hours, and I terminate this in quite a cheerful mood]