develooper Front page | perl.perl5.porters | Postings from December 2000

Re: [PATCH] Fcntl constants speedup

Thread Previous | Thread Next
Nicholas Clark
December 18, 2000 06:56
Re: [PATCH] Fcntl constants speedup
Message ID:
On Mon, Dec 18, 2000 at 02:33:57PM +0000, Ton Hospel wrote:
> In article <>,
> 	Nicholas Clark <> writes:
> > static IV
> > constant(char *name)
> > {
> >     errno = 0;
> >     switch (*name) {
> >     case '_':
> > 	if (strEQ(name, "_S_IFMT")) /* Yes, on name _S_IFMT return S_IFMT. */
> > 
> Hey ! what is that evil setting of errno ?

I didn't change that.
> perl -wle 'use Fcntl; $!=1; print O_NDELAY; print $!'
> perl -wle 'use Fcntl; $!=1; print $!' 
> That is just sooo wrong ! 

5.004 is the earliest perl I have to hand

$ /usr/bin/perl-5.004 -wle 'use Fcntl; $!=1; print O_NDELAY; print $!'

$ /usr/bin/perl-5.004  -wle 'use Fcntl; $!=1; print $!'
Operation not permitted

I think that it has been this way since 5.000, but I can't easily verify.

Note, the above doesn't express an opinion about wrongness or rightness.
My opinion is to agree that it's wrong. But I am cautious about making
changes that would be visible to the program (however trivial) that it
may have relied upon.
[says he who would like to change the internals of all the maths ops and
numeric conversions to like integers]

Previous threads about errno setting include one where I said:

    However, it is irritating when things succeed but set errno. I'm
    thinking of op/die_exit.t failing under sfio as an example.

and the conclusion of Hugo was

It would not be in such a minority: it is quite common for applications
to set errno to zero for similar purposes. As has been mentioned, system
library calls do not guarantee to preserve errno just because they are
successful; I see no benefit to perl offering such a guarantee itself -
anyone who needs it can save it easily enough themselves.

Hugo's position is consistent and well stated. I can't find arguments that
would convincingly undermine it.

Nicholas Clark

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