develooper Front page | perl.perl5.porters | Postings from January 2011

Re: Time to update POSIX.pm?

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
January 30, 2011 01:03
Subject:
Re: Time to update POSIX.pm?
Message ID:
20110130090345.GU24189@plum.flirble.org
On Sat, Jan 29, 2011 at 09:46:32PM -0500, Eric Brine wrote:
> On Sat, Jan 29, 2011 at 5:48 PM, Mark Overmeer <mark@overmeer.net> wrote:
> 
> > The unsplit POSIX.pm file is 1024 lines (21kb).  It does not use function
> > signatures, but checks parameter list length manually...
> >
> 
> There's no way to simply check parameter list length using "function
> signatures", if by that you mean prototypes,

Indeed, given that prototype checking can be disabled by calling using a &
If it *matters* that the parameter list length is correct, then it still
needs to be checked, even with prototypes.

> Attached is my compact rework of the POSIX module (434 lines, 15kb), as
> >
> example how small the module actually is. No regression tests run yet.
> > All fancy tricks removed. But it may trigger some debate first ;-)
> >
> 
> What about the fancy tricks you added? Prototypes change parsing rules, so
> by definition, it is a backwards incompatible change. For example, your
> changes causes
> 
> perl -e"use POSIX qw( ); @args=2; POSIX::exit(@args);"
> 
> to exit with code 1 instead of 2.

And also breaks any existing code which has marshaled the arguments for a
2 or 3 argument function into an array before calling it. At least it breaks
*that* at compile time.


I'm really not convinced that prototypes (as is) add any value in the general
case. To my mind, they complicate reading the code, because they provide
action-at-a-distance on how the parser is going to treat function calls.

There seemed to be a fashion for using them extensively around 5.003-5.004
time (for example, a lot of the regen code in the core), and looking at that
code now, it feels dated to me, and lacking some KISS.

Nicholas Clark

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