[Israel.pm] What's new in Perl 5.10

Oded Arbel oded-linux at typo.co.il
Tue Dec 25 06:23:28 PST 2007

On Tue, 2007-12-25 at 15:14 +0200, Jason Elbaum wrote:
> > Smart Matching in Perl 5.10
> > http://www.szabgab.com/blog/2007/12/1198487688.html
> I actually think this new feature is representative of one of Perl's
> design flaws.

> 1. "Different things should look different. Similar things should look similar."
> -> http://www.perl.org.il/presentations/larry-wall-present-continuous-future-perfect/transcript.html
> 2. "Do What I Mean" or "Do the Right Thing."
> The problem is that doing "the right thing" requires the compiler to
> do *different* things with the same (or very similar) code, depending
> on its understanding of the "right" thing.
> In this case, we have a single operator ~~ which can either mean:
> - Do these numbers have the same value?
> - Do these strings have the same characters?
> - Do this number and this string represent more or less the same thing?
> - Does this string match this regular expression?
> - Is this element found in this array?
> - Is this element one of the keys of this hash?
> - Do these arrays have the same elements?
> - Do these hashes have the same keys?
> - etc., etc., etc.
> Keeping track of all these cases and how they interact is not
> necessarily intuitive, and will likely call for frequent reference to
> the documentation. That's because they're fundamentally doing
> *different* things, even though they all look the same.

While far from being perl guru, I would hazard a guess that these are
all similar things - they are not identical, but they are all operations
of matching data hence they are all similar hence they should look

As a counterpoint it would be stupid if "string" . "string" would
perform string concatenation while (list) . (list) would perform list
intersection - as these are very different operations, but if the .
(dot) operator on lists would perform list concatenation then it would
make sense as string concatenation and list concatenation are similar



More information about the Perl mailing list