On Sun, Jan 30, 2011 at 08:07:05PM +0100, Mark Overmeer wrote:
> * Eric Brine (ikegami@adaelis.com) [110130 02:46]:
> > On Sat, Jan 29, 2011 at 5:48 PM, Mark Overmeer <mark@overmeer.net> wrote:
> > There's no way to simply check parameter list length using "function
> > signatures", if by that you mean prototypes,
>
> In the common case you can. Of course, there are situations where it
> does not work. A prototype of ($$) works as well as @_==2
Eh, no.
sub foo ($$) {...}
@arg = (1, 2);
foo (@arg);
isn't the same as
foo (1, 2);
> > 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.
>
> Of course.
> Let's be realistic, the exit(@args) in the original code is a bug.
> No-one is his right mind will call exit with multiple values. But you
> will certainly be able to produce examples which may exist in reality.
But who says @args contains more then one element? In fact, in Nicks
example @arg only contains 1. Do you know there isn't any code out there
that uses 'POSIX::exit (@_)'?
> Do you really wish to keep back the evolvement of the language because
> you want to stay compatible with (all imaginable) sleeping bugs?
Slapping prototypes on existing functions has nothing at all to do with
language evolvement.
If I were to write POSIX now, I may considered using prototypes. But it's
there, it has been there for a long time, and I don't think the advantage
of a prototypes outweights the risk of breaking code.
Abigail
Thread Previous
|
Thread Next