Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: caller() returns wrong line on multi-line function call

by RonW (Parson)
on Sep 15, 2017 at 18:38 UTC ( #1199473=note: print w/replies, xml ) Need Help??


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 (Archbishop) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1199473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2019-05-25 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (152 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!