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

Re: What happened to the whole "small core" idea?

Thread Previous | Thread Next
From:
Lukas Mai
Date:
October 28, 2012 09:41
Subject:
Re: What happened to the whole "small core" idea?
Message ID:
508D5FED.7070309@web.de
On 27.10.2012 21:58, Peter Rabbitson wrote:
> On Sat, Oct 27, 2012 at 09:32:40AM -0400, Peter Martini wrote:
>> Just a couple of thoughts from my phone, which is why I cut out the message:
>>
>> 1. Sub signatures have been prototyped, and quite successfully, on CPAN.
>> The internal interface could be improved, but the core support is there.
>
> This is simply untrue. There has never yet been an implementation on CPAN
> which concerned itself with the amount of arguments.

This is simply untrue. :-)
Function::Parameters basically provides two modes of operation: "lax" 
mode (the default), which works like 'my ($foo, $bar, $baz) = @_;' (i.e. 
excess arguments are ignored, missing arguments are set to undef), and 
"strict" mode, which croaks if the number of arguments is wrong.

The choice between the two modes lies with the subroutine author because 
the checks are part of the generated code and controlled via use/import 
arguments to Function::Parameters.

> Nor has there been
> an implementation which in any way altered the behavior/contents of @_.

Not 100% true. Function::Parameters can't make @_ disappear completely, 
but it can alter the contents by automatically shifting the first 
element into $self for methods. I suspect most modules of this kind will 
do the "shift $self" thing, because it's really extremely convenient for 
methods. (OK, that doesn't affect normal 'sub' declarations - you have a 
point there.)

> I never said keywords - I said syntax. Not only is your proposal adding
> new syntax *to the language core*, it does so by hijacking unused parts
> of a preexisting syntax (prototypes). No implementation on CPAN has
> attempted this so far.

Isn't that exactly what signatures.pm does? It hijacks prototypes.

Lukas

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