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

[perl #24765] #line number problem

Thread Previous | Thread Next
Glenn Linderman
December 27, 2003 22:26
[perl #24765] #line number problem
Message ID:
# New Ticket Created by  Glenn Linderman 
# Please include the string:  [perl #24765]
# in the subject line of all future correspondence about this issue. 
# <URL: >

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 below demonstrates, there is no error when 
a number too big is provided, and as the code 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.

#line 1234567 ""
die "horribly";

horribly at line 54919.

#line 65535 ""
warn "nicely";
warn "harshly";
die "horribly";

nicely at line 65535.
horribly at 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.
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, the Perl Home Page.

Glenn --
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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About