Dorkish indeed. I don't see how that makes any sense.
First, it gives tons of warnings. Second, it doesn't make sense to treat an error signal as a valid value.
$ perl -wE' sub expensive_call { $_[0] == -1 ? undef : $_[0] } say $_ // "[undef]" for sort { ( $c{$a} //= expensive_call($a) ) <=> ( $c{$b} //= expensive_call($b) ) } 0,1,-1,-1,0,2; ' Use of uninitialized value $c{"-1"} in numeric comparison (<=>) at -e +line 3. Use of uninitialized value $c{"-1"} in numeric comparison (<=>) at -e +line 3. Use of uninitialized value $c{"-1"} in numeric comparison (<=>) at -e +line 3. Use of uninitialized value $c{"-1"} in numeric comparison (<=>) at -e +line 3. Use of uninitialized value $c{"-1"} in numeric comparison (<=>) at -e +line 3. Use of uninitialized value $c{"-1"} in numeric comparison (<=>) at -e +line 3. Use of uninitialized value $c{"-1"} in numeric comparison (<=>) at -e +line 3. 0 -1 -1 0 1 2
It would make more sense to handle the error, perhaps by dying or by using a sensible default.
$ perl -wE' sub expensive_call { $_[0] == -1 ? undef : $_[0] } say $_ // "[undef]" for sort { ( $c{$a} ||= expensive_call($a) // -1 ) <=> ( $c{$b} ||= expensive_call($b) // -1 ) } 0,1,-1,-1,0,2; ' -1 -1 0 0 1 2
In reply to Re: D'Orcish Maneuver
by ikegami
in thread D'Orcish Maneuver
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |