in reply to Re: caller() returns wrong line on multi-line function call
in thread caller() returns wrong line on multi-line function call

I would say the "true line" is either the line with the function name or the line with the closing ) (or the last argument, in the case of a function call without parenthesis).

The reason I say this is because the arguments to a function call may be any expression that can be used on the right-hand side of an assignment, including another function call.

Replies are listed 'Best First'.
Re^3: caller() returns wrong line on multi-line function call (debugger confused)
by LanX (Saint) on Sep 15, 2017 at 19:07 UTC
    The information in nextstate is used by the debugger to display the current line while stepping thru

    • hence it has to be the start of the statement,
    • hence the line with the sub statement in our case
    • not the "function name", since it could be in another line

    Sorry, I don't think there is any room left to argue.

    edit
    The debugger can't work properly with this bug, and actually fails.

    If you type v you'll see something like

    DB<1> n main::tst(caller_subline.pl:24): do { A +=> 1, B => main::tst(caller_subline.pl:25): ); DB<1> v 21 22 23 print_calling_line( __LINE__, 24==> do { A => 1, B => 2, C => 3 } 25 ); 26 27 print_calling_line( __LINE__, 28: do { A => 1, B => 2, C => 3 }, 29: do { A => 1, B => 2, C => 3 , 30: do { A => 1, B => 2, C => 3 } DB<1> n Called from line 23; caller() reports line 24 main::tst(caller_subline.pl:29): do { A +=> 1, B =>

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      hence the line with the sub statement in our case

      In the OP's case, yes.

      I was talking about function calls in general. And for the case of displaying line numbers to a sentient being (which the OP did mention).

      For a debugger, yes, the line of number of start of the function call is needed to be able to display the function call correctly.

      Update: Though, for a GUI debugger, highlighting the line with the closing ) as long as there wasn't another function call on the same line.

      Certainly, the least ambiguous is to have the line number with the start of the call (either the function name or the sub).

      My main point of my previous post still remains: Anything line "in the middle" of the call is too ambiguous, therefore not acceptable.