Thursday, July 6, 2023

Re: vim9 Equivalence of __FILE__, __LINE__, and __FUNCTION__ usage in C++

Yegappan wrote:

> On Tue, Jul 4, 2023 at 1:11 PM Lifepillar <lifepillar@lifepillar.me> wrote:
> >
> > On 2023-07-04, Nicolas <nivaemail@gmail.com> wrote:
> > > Hi,
> > >
> > > Is there an equivalence in vim9 of __FILE__, __LINE__, and __FUNCTION__
> > > usage in C++
> > ><https://stackoverflow.com/questions/597078/file-line-and-function-usage-in-c>
> >
> >
> > For __LINE__ and __FUNCTION__, I don't know what "equivalent"
> > alternative to suggest, but if you elaborate on what your goal is, it
> > will be easier to help.
> >
>
> You can try using <script>, <sflnum> or <stack>:
>
> https://vimhelp.org/cmdline.txt.html#%3Cscript%3E
> https://vimhelp.org/cmdline.txt.html#%3Csflnum%3E
> https://vimhelp.org/cmdline.txt.html#%3Cstack%3E

Expanding "<stack>" gives you the most information. But the form is a
bit hard to parse, because it was kept compact. With some effort you
can parse it back into a list of function calls and script commands.
You can use "getscriptinfo()" to get the script file name from the
script ID, which is inside the function name after <SNR>:
<SNR>74_OuterFunc[7]

Here "74" is the script ID. Inside the script you may find
s:OuterFunc() or just OuterFunc() (esp. in Vim 9 script).

"[7]" indicates line 7 of the function. To see what script line that is
you can go to the line where the function is defined with ":func" or
":def" and then go that many lines down: "7j". When line continuation
is used it may be off by a few lines. And line insert/delete need to be
taken into account.

For interactive debugging the "where" command can be used. You need to
set a breakpoint or use ":debug command args". See ":help debug-mode".

--
Why is it that pizza is made round, packed in a square box,
and eaten as a triangle?

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20230707021852.1BCCC1C09A9%40moolenaar.net.

No comments: