The functions which generate the code don't know what file they are writing to, and keeping track of the current output line seems like a big hassle, so generating #line directives for my own code isn't really possible.

The Perl compiler only keeps track of one file name and one "current line number" for each stream of code that it is compiling. So supporting a "pop" (or "reset") feature for #line isn't really possible.

Well, for your definition of the word "possible", which seems a rather non-standard one.

That said, I think having a "reset" feature for "#line" is a fine idea. In a quick test, '#line 0' had the strange impact of making the next line of input "not from any line" but the line after it being "line 1". '#line 5 ""' is identical to '#line 5' (the empty string is ignored).

So we could patch Perl so that '#line 0' resets the current line number to be real line number and so that '#line 9 ""' resets the current file name to be the original file name. Of course, '#line 0 ""' would reset both.

However, keeping track of two different file names and two different "current line number"s for each stream of source code seems like a big hassle. So if you want it done, you'll probably have to write the patch for Perl yourself. See S_incline() in p5git://toke.c..

- tye        


In reply to Re: Reset the effect of #line (patch) by tye
in thread Reset the effect of #line by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.