Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^3: Wrong behavior of the implicit smart operator in the given/when blocks

by tobyink (Abbot)
on Apr 30, 2012 at 16:40 UTC ( #968108=note: print w/replies, xml ) Need Help??

in reply to Re^2: Wrong behavior of the implicit smart operator in the given/when blocks
in thread Wrong behavior of the implicit smart operator in the given/when blocks

As I understand it, it's DOY's smartmatch which is the possible candidate for future Perls. This pushes the behaviour of smart match out to modules (on a lexically scoped basis). So you can:

use smartmatch 'acme';

And then the ~~ operator will start acting along the lines of whatever's defined in the smartmatch::engine::acme module. Perl will then come bundled with a backwards compatible behaviour (modelled on 5.14 most probably) and a simplified one.

Personally, I tend to follow the rule of keeping the left hand side of the smart match as either a non-reference scalar or a blessed object. If you stick to that, then whatever you put on the right hand side, smart match generally behaves pretty sanely and intuitively. (With the possible exception of when you've got hashref on the right hand side - I'm not sure there's any completely intuitive behaviour in that case, but the current behaviour certainly seems no worse than anything else.)

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://968108]
[Corion]: marto: Yep, but I didn't make it up north, sorry ;)
[Corion]: But LPW was enjoyable, even though it's always a bit hectic due to cramming everything into one day
[Corion]: I have no feeling about how my talk was received, but I'm happy with it, which counts the most to me ;-D
[Corion]: Also, London is always a nice visit, as I got to meet a friend there, and spent some time offline, working on "minor" features of the shadertoy thing ;)
[marto]: maybe next year when the kids are a little older I'll have time to attend perl events in Europe

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2016-12-07 09:25 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (125 votes). Check out past polls.