* Peter Scott <Peter@PSDT.com> [2012-08-30T01:40:35] > On Sun, 26 Aug 2012 12:52:14 -0700, Father Chrysostomos wrote: > > Do we really need smart match at all? > > Please, please, what he said. All of the below is FWIW, and in case a > new voice is of any help. I have been unable to find a way to be > comfortable putting ~~ in any of my teaching materials or use it in my > own programs. > [...] I feel the same way, which is why I originally and again proposed the much simpler behavior discussed in this thread. > If I wanted to construct a subroutine that smartmatched arguments that > could really be of any type, I'd be so paranoid every time I looked at > the code that I'd be forever reconsidering what all possible argument > types could do. Is the type dispatch table for ~~ obvious enough that > people can internalize it rapidly without having to refer to it > constantly? So far, I haven't. ...because this paragraph made it sound like you were only considering the old one. The new one is tiny and (I thought) both easy to remember and to intuit. Could you let me know whether you've written ths message with it in mind? > I'm afraid even that looks like madness, as useful as it appears. > Because if I have 'when( 3.14159 ) ... when ( 2.71828 )' then why should > it behave differently when I refactor to turn magic numbers into symbols: > 'when ( $PI ) ... when ( $E )'? How can I explain that? Or am I missing > something that would enable that to work? Even then, if someone's read > from input "003" into $num and then does a ~~ on $x = 3, how to explain > that it's not coercing to a number? It's too much to think about, when > using an operator that looks deceptively simple. Again, the current discussion does not allow $x ~~ $simple_value. > It's fundamental to Perl that you have to know whether to use == or eq. I agree. > If there were a natural intuitive interpretation of ~~ I think it would > have emerged from all this brainstorming by now. I think one has. Are you specifically saying that the "short table smart match" is not good? Because it's too complex, or too simple? It was: $x ~~ undef $x ~~ $overloaded_object $x ~~ sub {} $x ~~ regex ...or fail -- rjbsThread Previous | Thread Next