develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #117969] use POSIX emits multiple warnings if used after "Cwd"

Thread Previous | Thread Next
From:
Linda Walsh via RT
Date:
May 14, 2013 01:40
Subject:
[perl #117969] use POSIX emits multiple warnings if used after "Cwd"
Message ID:
rt-3.6.HEAD-2650-1368495619-1303.117969-14-0@perl.org

First, I must note, this is hardly the most important issue on 
my plate.  I'm responding to these as mostly academic discussion, 
as my program has already dealt with the issue -- and as mentioned
earlier, I'd previously only used "use POSIX" with a parameter.

On Sun May 12 18:01:14 2013, ikegami@adaelis.com wrote:
> On Sun, May 12, 2013 at 2:52 PM, Linda Walsh via RT <
> perlbug-followup@perl.org> wrote:
> 
> > How would improving it to
> > not give warnings if something has already defined those modules NOT be
> > an improvement?
> 
> Easy. Importing foo() from one module yet have foo() silently calling
> another module's foo() is NOT an improvement. This is exactly what
warnings
> are for.
----
If you import POSIX() you will get no imports.
I don't know if you mean to be this was specifically about the POSIX
module, not modules in general.

The POSIX module exports over 550 symbols, *by default*.

If something is going to export that many symbols by default,
it would seem care should be taken not to overwrite the names if
they are already in use.  If warnings are issued, it would be
more appropriate (in the *default* case on this module), to
put the errors in $@ and developers who were concerned that
they got the right module from POSIX, could check $@.

It wouldn't break existing code that runs now without warnings,
so wouldn't that be enough so satisfy a reasonable person's 
definition of "compatibility"?

---------------
On Sun May 12 18:32:44 2013, xdg@xdg.me wrote: 
> I would have no problem at all with having POSIX deprecate it's
> @EXPORT and use @EXPORT_OK instead and warn if import is called
> without arguments, (e.g. deprecate and warn in 5.20, and actually
> remove @EXPORT in 5.22) but I think the odds of that being welcome by
> p5p are slim at best.
---
But that still doesn't make it useful in the default case.

I also wish some other modules (ex. Errno) had a (:all) option, so I
wrote for myself "Errno_h" that does.  People are used to the errno.h
include file including all the definitions of E_NOBLAH and 
ENOTHIS or ENOTHAT, but to expect all possible POSIX calls to be
defined -- Does anyone have such a list in there head, and know what
they would be getting in advance? 

It's unweildy and seems to be a not-very-useful implementation the
way it is as it already, **without warnings about specifics**, 
any POSIX call that had a name collision with perl's key words.
I.e. -- it is already the case that for many posix keywords, 
it doesn't warn you that they conflict with perl keywords -- you
just silently get the perl version -- right?

So, why not make that they default with all it's symbols, but
only in the default case.  That way, it's behavior could
be made more consistent.  Functions specified to be included would
still give warnings as they do now.  But someone includes
POSIX with no specifications/parameters, then it could lower its 
demands on how it communicates warnings.  

Just seems like that would make it more useful in the default case,
rather than eliminating the default case altogether.

It also would make the default case easier to use:

1) If someone wants to see warnings, they can make sure POSIX is
included 1st, and any following modules will issues warnings.

   However,

2) In cases where POSIX is included down in some sub-block of code,
it would be unlikely to come first in defining functions, and
it would  be "upgraded in intelligence",  to auto-configure what
modules it exports based on what isn't defined.  Thus it not only
doesn't conflict with perl's "system namespace" but also not with
perl's general namespace for things that are already defined.


> That's the Perl philosophy of bending over backwards to avoid breaking
> old code.
---
I think the above accomplishes that.



> I happen to disagree with that philosophy in many cases, but I seem to
> regularly be in the minority.
---
	Ditto.


-----
On Sun May 12 22:54:38 2013, vadim.konovalov@alcatel-lucent.com wrote:
> > From: Aristotle Pagaltzis
> > Skipping already-defined functions silently would be just as bad; 
> 
> my intuition tells me this would be not "...as bad", rather this will
> be much worse
---

Do you think that would be the case with old code?  I.e. If it is
in production and runs now without warnings, would a new version
that silenced such warnings (for $warn () {...}).


Mon May 13 00:49:23 2013, rvtol+usenet@isolution.nl wrote:
> On 12/05/2013 03:02, Linda Walsh wrote:
> > I was trying to "use POSIX" and got multiple warnings in my
> > program:
> 
> Start with replacing your "use POSIX;" by "use POSIX ();".
---

Actually I started with a "require" and changed it back after
seeing the mess "use" caused.  "oops" ;-)










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