develooper Front page | perl.perl5.porters | Postings from June 2020

Re: Dual-life perl 5-or-7 code and prototypes - impossible?

Thread Previous | Thread Next
From:
Kent Fredric
Date:
June 30, 2020 19:56
Subject:
Re: Dual-life perl 5-or-7 code and prototypes - impossible?
Message ID:
CAATnKFChSi4uQe7dbPABOJHq9p9UmcTQhGQzbwQnO8=mnXSyag@mail.gmail.com
On Sat, 27 Jun 2020 at 23:45, Paul "LeoNerd" Evans
<leonerd@leonerd.org.uk> wrote:
>
> TL;DR: I believe it impossible to write a dual-life module using
>   function prototypes that works on both perl 5 and perl 7.

There may be an easier, and inherently more portable and compatible
option, assuming of course, perl7 never deprecates the ability to `no
feature qw(signatures)`

( in say, List::Utils )

BEGIN {
    if ( $] >= 7) {
        require feature;
        feature->unimport('signatures');
    }
}

I've synthetically demonstrated this currently works on perl5.

https://gist.github.com/kentfredric/875a5d2f9d56a7438669cbabfdc3b885

Surely I must have missed something obvious.

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