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

Re: The future of POSIX in core

Thread Previous | Thread Next
Mark Overmeer
September 2, 2011 07:37
Re: The future of POSIX in core
Message ID:
* Abigail ( [110902 14:08]:
> I don't think "needs a scalar" actually means "will not accept an
>   array as argument".
> In fact, I consider the bug here to be:
>     $ perl -wE '@a = 2; exit @a; echo $?'
>     1

But an array is not a scalar!  An array is NOT the same thing as a
list of scalars.

> I actually expect this to print 2, and checking the manual page for exit,
> there's actually nothing in it that suggests it's evaluating its argument
> list in scalar context. Not only doesn't it say "needs a scalar", it doesn't
> even mention the word "scalar":
>   =item exit
>   Evaluates EXPR and exits immediately with that value.

IMO, a "value" is not the same as "the first value of a list/array"
So documented is that EXPR is expected to produce a single thing,
which @x in POSIX::exit(@x) can only be if there is a prototype.

OK, but that point has been raised a few times before.  Can you also
give your response to my counter argument that it is very unpleasant

   use POSIX 'exit';
   ... zillion lines of code ...

differs from

   ... zillion lines of code ...

Or even worse, with functions with a single scalar which change from
being prefix operator priority into functions by a seemingly unrelated
"use" statement... Of course, this is only a problem when you do not
use parens for function calls (I like to have few parens, and Perl
allows me to)

(a similar horrific change when you add "use filetest" to the top
of your program, which changes the behavior of every -r/-w/-x)


       Mark Overmeer MSc                                MARKOV Solutions                         

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About