Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: perldelta unclear on 'given's fate

by ikegami (Pope)
on Jan 06, 2014 at 11:45 UTC ( #1069488=note: print w/replies, xml ) Need Help??

in reply to perldelta unclear on 'given's fate

There are problems with the design of smart-matching. The decision of what any given TYPE ~~ TYPE should do is most often unobvious, inconsistent and/or disputed. The idea isn't to remove smart matching; it's to fix it.

Specifically, ~~ will likely be greatly simplified, as you can see in a proposal by the 5.18 pumpking. Decisions as to how two things should match will be done with helpers such as those that already exist in Smart::Match.

... ~~ any(...)

Much more readable, much more flexible (fully extensible), and solves a number of problems (such as "When should X be considered a number, and when should it be considered a string?").

Along the same lines, the rules for when when uses smart-matching and when it doesn't are complicated. I suspect that will change.

Lexical $_ (currently used by given) apparently causes too much problems. For example, the following code doesn't work because first sets package variable $_, but the callback captured the lexical $_ declared by given.

given (...) { ... first { /.../ } ... ... }

Rather than continuing to require callbacks to use our $_;, given will be changed to use package variable $_ instead of lexical $_ in 5.20.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1069488]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2020-12-04 15:06 GMT
Find Nodes?
    Voting Booth?
    How often do you use taint mode?

    Results (60 votes). Check out past polls.