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:
Salvador Fandiño
Date:
June 29, 2020 17:13
Subject:
Re: Dual-life perl 5-or-7 code and prototypes - impossible?
Message ID:
968a6516-8662-d18a-cad7-0c45f391b064@gmail.com
On 29/6/20 18:53, Paul "LeoNerd" Evans wrote:
> 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.

If I had understood correctly the aim behind p7, it is to get people to 
use the new features. Just the opposite of encouraging people to write 
code compatible with p5, right?

If you want to remain compatible with both perl5 and perl7, you are 
going to have the worst of both worlds. You would not be able to use 
"features" removed from perl7 neither would you be able to use the new 
features added.

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