develooper Front page | perl.perl5.porters | Postings from October 2015

Re: YA smartmatch proposal [ was: Re: smartmatch needs your eyes]

Thread Previous | Thread Next
From:
Eric Brine
Date:
October 7, 2015 19:57
Subject:
Re: YA smartmatch proposal [ was: Re: smartmatch needs your eyes]
Message ID:
CALJW-qH89NgKyWgyh3gGzUUKGJ-sjLjR8Lk44pmGWojYyJ-r3g@mail.gmail.com
On Wed, Oct 7, 2015 at 4:24 AM, Dave Mitchell <davem@iabyn.com> wrote:

> 2. Make when's behaviour entirely dependent on the *compile-time* class
> of of its arg. In particular, make 'when (FOO)' have exactly the following
> behaviours:
>
>     FOO             condition evaluates to
>     --------------  ----------------------
>     literal undef             !defined($_)
>     numeric const                $_ == FOO
>     literal pattern              $_ ~= FOO
>     all else                     $_ eq FOO
>
> 3. when { FOO } has condition FOO.
>
> For example:
>
>     use constant ME  => "davem";
>     when (ANS)     # equivalent to when { $_ == 42 }
>

According to your table, shouldn't that be "when { $_ eq ANS }"? ANS could
have any value, so when (ANS)" is no different than "when ($x)". There's no
"compile-time class" available to study.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About