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:
Paul "LeoNerd" Evans
Date:
June 29, 2020 16:53
Subject:
Re: Dual-life perl 5-or-7 code and prototypes - impossible?
Message ID:
20200629175312.551c57ec@shy.leonerd.org.uk
On Mon, 29 Jun 2020 18:40:18 +0200
Salvador Fandiño <sfandino@gmail.com> wrote:

> Aren't you too focused in supporting the new subroutine attribute in 
> older perls instead of just providing its functionality in some way?
> 
> For instance, it shouldn't be to difficult to write a package, say
> for instance, "sub::prototype", that sets the function prototype and
> works both under p5 and p7.
> 
>    sub foo {
>       ...
>    }
>    use sub::prototype foo => "$";
> 
>    sub bar {
>       ...
>    }
>    use sub::prototype bar => "\@"

Ohsure, that could work. But for that matter the following already
works right now on all versions of perl

  sub foo { ... }
  BEGIN { Sub::Util::set_prototype( "$", \&foo ); }

But is that really what we want to encourage new authors of perl code
to be writing?

If we preferred that form, why would we have designed the `:prototype`
attribute in the first place? My aim was to allow people to continue
writing what is valid and encouraged in both *current* perl 5.32 and
proposed perl 7.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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