On 10/07/2015 10:24 AM, Dave Mitchell wrote: > > I think 95% of what people actually *want* a smartmatch system for is so > that they can write code of one of these three forms: > > given ($index) { > when (undef) {...} > when (0) {...} > when (1) {...} > when (INDEX_MAX) {...} > } > > given ($string) { > when (undef) {...} > when ("foo") {...} > when ("bar") {...} > when (BAZ) {...} > } Lets for a moment forget about the smart match operator and focus on when. My understanding is that the issue there is really reduced to the incapability to determine if the user wants number or string equality so well, let him tell perl what he wants in a concise way, using '+' (or '-'): given ($index) { when (undef) # !defined when (+1) # == when (+INDEX_MAX) # == when (+"foo") # == when (-1) # == when (3) # eq? I am undecided about literal numbers when ("foo") # eq when (BAZ) # eq when (/$re/) # /$re/ }Thread Previous | Thread Next