Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readline(FH) throws a warning, <FH> does not #15850

Closed
p5pRT opened this issue Jan 30, 2017 · 5 comments
Closed

readline(FH) throws a warning, <FH> does not #15850

p5pRT opened this issue Jan 30, 2017 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 30, 2017

Migrated from rt.perl.org#130673 (status was 'rejected')

Searchable as RT130673$

@p5pRT
Copy link
Author

p5pRT commented Jan 30, 2017

From ryan.royal@airbus.com

A bare word file handle causes the readline(FH) function to emit a warning​: Name "main​::FH" used only once​: possible typo at readline_test.pl line 4.

-The equivalent diamond operator <FH> used on the same bare word handle does not evoke the warning.

-Using a lexically scoped file handle with readline( $fh ) also does not evoke the warning.

See attached, thanks

========================== version ===========================
Strawberry Perl

C​:\Home\RRoyal02\MyPrograms\perl\bin> perl5.24.0 -v

This is perl 5, version 24, subversion 0 (v5.24.0) built for MSWin32-x64-multi-thread

Copyright 1987-2016, Larry Wall

=========================== OS ============================
Windows 7 Enterprise
Intel Xeon CPU
32 GB Ram

The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.

@p5pRT
Copy link
Author

p5pRT commented Jan 30, 2017

From ryan.royal@airbus.com

ScanMail detected and removed a file named "readline_bug.zip" that violated attachment blocking policy from the original mail entity. You can safely save or delete this replacement attachment.

@p5pRT
Copy link
Author

p5pRT commented Feb 1, 2017

From @iabyn

On Mon, Jan 30, 2017 at 08​:44​:36AM -0800, ROYAL@​rt.perl.org wrote​:

# New Ticket Created by ROYAL, Ryan
# Please include the string​: [perl #130673]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=130673 >

A bare word file handle causes the readline(FH) function to emit a warning​: Name "main​::FH" used only once​: possible typo at readline_test.pl line 4.

-The equivalent diamond operator <FH> used on the same bare word handle does not evoke the warning.

readline takes a typeglob as an argument, while the <> operator takes the
*name* of a typeglob, So, as the docs for readline say,

  $line = <STDIN>;
  $line = readline(*STDIN); # same thing

Note that one has a '*', the other doesn't. However, readline will accept
a bareword string, and at runtime use it as the name of a typeglob to look
up.

So at *compile* time (at which time 'only used once' warnings are checked
for and issued),

  <FH>

is compiled as

  readline *FH

and a typeglob check is done; while

  readline FH

is compiled as

  readline 'FH'

and no typeglob is involved or checked for,

Note that 'readline *FH' *will* give a warning.

It might be possible to change it so that in 'readline FH', the "FH"
string is converted to a typeglob at compile time, but personally I'm in
favour of leaving anything filehanldle/typeglob related well alone. It has
a ton of edge-case weird semantics inherited from perl4 days.

-Using a lexically scoped file handle with readline( $fh ) also does not evoke the warning.

Lexicals don't give 'only used once' warnings in any situation, not just
readline.

--
I before E. Except when it isn't.

@p5pRT
Copy link
Author

p5pRT commented Feb 1, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT p5pRT closed this as completed Mar 28, 2017
@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2017

@iabyn - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant