develooper Front page | perl.perl5.porters | Postings from December 2017

Re: Revisiting smart match

Thread Previous | Thread Next
December 29, 2017 22:01
Re: Revisiting smart match
Message ID:
Something to keep in mind in developing the smartmatch replacement is the
basic "switch-like" use of testing against literals.

As an example, excerpting code from lines

given($r1) {

    when [ "T", "X" ] { $expansion = "%H:%M:%S"; }
    when "c" { $expansion = "%a %b %e %H:%M:%S %z %Y"; }
    when [ "C", "u" ] { $expansion = "%a %b %e %H:%M:%S %z %Y"; }
    when "g" { $expansion = "%a, %d %b %Y %H:%M:%S %z"; }

It's easy for humans to read and parse (and harkens back to the C-ish
origins of the switch statement which only allows constants)- keep "easy
things easy" going forward- thanks

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About