Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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.


Comment on Re: perldelta unclear on 'given's fate
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2015-07-06 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (81 votes), past polls