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

[perl #24765] #line number problem

Thread Previous | Thread Next
From:
Glenn Linderman
Date:
December 27, 2003 22:26
Subject:
[perl #24765] #line number problem
Message ID:
rt-3.0.7_01-24765-68946.12.0676157041051@perl.org
# New Ticket Created by  Glenn Linderman 
# Please include the string:  [perl #24765]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=24765 >


This seems like a trivial problem, perhaps, but it tripped me up.

The line number parameter to #line seems to be limited to modulus 65536 
(a.k.a. a 16-bit number).  It is not clear why that should be the case. 
  I suppose it might be possible that the reason is that many different 
line numbers must be saved, so they are saved small, but most machines 
have adequate memory these days.

I have a source file with over 34000 lines in it, and it does numerous 
evals.  I thought it would be clever, to avoid overlap with "real" 
source lines, to simply add one million to the source line of the eval. 
  That would be easy to mentally chop back off when the error would be 
reported, I thought.

However, as the code test2.pl below demonstrates, there is no error when 
a number too big is provided, and as the code test3.pl below 
demonstrates, there is no error when it rolls over, either.  And if 
#line is zero during the transition, it is not reported at all.

I couldn't find the limit documented, after a grep for #line in the 
documentation.  I'd rather have it fixed than documented, of course.


D:\MY\PERL\src>type test2.pl
#line 1234567 "from_other_file.pl"
die "horribly";
__END__

D:\MY\PERL\src>perl test2.pl
horribly at from_other_file.pl line 54919.

D:\MY\PERL\src>type test3.pl
#line 65535 "from_other_file.pl"
warn "nicely";
warn "harshly";
die "horribly";
__END__

D:\MY\PERL\src>perl test3.pl
nicely at from_other_file.pl line 65535.
harshly.
horribly at from_other_file.pl line 1.

D:\MY\PERL\src>perl -v

This is perl, v5.8.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2002, Larry Wall

Binary build 805 provided by ActiveState Corp. http://www.ActiveState.com
Built 18:08:02 Feb  4 2003


Perl may be copied only under the terms of either the Artistic License 
or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

-- 
Glenn -- http://nevcal.com/
===========================
The best part about procrastination is that you are never bored,
because you have all kinds of things that you should be doing.


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