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:
Zefram
Date:
October 19, 2015 03:11
Subject:
Re: YA smartmatch proposal [ was: Re: smartmatch needs your eyes]
Message ID:
20151019031101.GS9229@fysh.org
Ricardo Signes wrote:
>On the other hand, a future &num could provide a faster magic value that ~~'s
>implementation can know to directly resolve to a numeric comparison.  I'd doubt
>it would ever match custom when:num syntax in speed,

It totally could, without any real difficulty.  XS code that knows
specifically about the objects returned by num() could hook checking of
the smartmatch op, recognise a num()-generated const value on the rhs,
and replace the smartmatch with a numeric comparison op.  Also, num()
call expressions with const parameter expression can be constant-folded.
Putting them together, "when(num(3))" would compile to the same ops as
"when { $_ == 3 }".

-zefram

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