Re^2: Smart match in p5
by Juerd (Abbot) on Mar 14, 2005 at 12:51 UTC
|
Wouldnt it be better if your patch was against blead and not maint and that you submit it to p5p for review?
Perhaps. However, I'd like to have a more complete implementation (i.e. one with SmartMatch.pm itself) before sending things over to p5p. I want to avoid discussion of practical problems that simply aren't there, and the only way to do that is to prove it can work before suggesting its inclusion. The advance work usually consumes less time than the discussion avoided by it. Also, I don't care much for the final implementation, and see what we're doing now as a proof of concept (that can very well be implemented without much change, if people like it).
I haven't needed switch/case or given/when myself. But many, many people would prefer it over if/elsif/else structures.
| [reply] |
|
| [reply] [d/l] |
|
| [reply] |
|
|
| [reply] |
|
print $fh ~~EXPR;
| [reply] [d/l] |
|
|
|
|
|
|
IMO a crucial issue to get this into play is to find out how many scripts it breaks. You should have a good estimate of that before proposing it.
Do I have statistics? Do you? Does anyone?
All we can reasonably test with is CPAN modules, our own scripts and perl's test suite. I know nothing in my repository would break except one throwaway script that uses Switch.pm for given/when.
| [reply] |
|
|
|
| [reply] |
|
Since it does break backwards compatability
Please provide example code, as the only place I know where it'd be ambiguous, it's resolved in favour of the existing behaviour, sacrificing no real functionality in the new feature.
A smart match operator doesn't seem to fill a great demand (and no, "smart match operator" is not the same as "switch", for which there are alternatives - a "smart match operator" is yet another alternative to "switch").
Smart match is what gives a switch statement for free. Of course, those can be implemented without having the smart match at all, but it'd be nice to be able to use the logic used for switch statements outside givens too.
They will demand showing you it fills a demand. So they'll suggest you first implement it in a module (a source filter probably).
The smart match operator is not in great demand. The only reason for concentrating on that is its relation with given/when. And re doing it as a source filter: no, I won't. That's very nice for a proof that the syntax works, or if you want very badly to use this feature yourself. The only thing I'm interested in is getting given/when implemented in Perl 5 itself, not a source filter, because that source filter already exists and we all know why we're avoiding its use in production. This feature requires modifications to the core (which a minor release can do -- for conservatives, there are maintenance releases), and if we're at it, I think it makes sense to do it right the first time. If p5p doesn't like it, then the work we've done has still not been done for nothing. The code that implements SmartMatch::sm can be reused without modification, and some people (like me) learn a bit about how Perl's internals work by looking at xmath's work.
But for someone who said he was doing this to avoid discussion, I have been wasting too much time on unnecessary typing already. For now, I don't care about p5p's opinion on this at all, but there will be a time that I should care, and I trust that p5p will make a wise decision.
| [reply] |
A reply falls below the community's threshold of quality. You may see it by logging in.
|