LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm pondering about making Perl memorize parsing information (like from B::Xref , ctags, prototypes) in an extra location, like a static file ( something like "~.meta" or "~.ptags" )

Mechanism would be to compare last-edit time in the UNITCHECK phase.

If the Perl file is newer, parsing information would be stored.

I'm aware of edge cases like AUTOLOAD, but for far more than 90% of modules this should be a reliable approach. This would allow improving our toolchain, like IDEs.

Was this tried before?

Ideas?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Storing dynamic parse results for static introspection?

Replies are listed 'Best First'.
Re: Storing dynamic parse results for static introspection?
by perlfan (Parson) on Jul 21, 2020 at 17:30 UTC
    Usually I just take these cool questions as a chance to learn more. I scanned your link to perlmod (UNITCHECK), something about the fact that it's processed LIFO (outside of execution) and other things (INIT, e.g.) are processed FIFO (during execution) makes me think that AUTOLOAD might not be your only potential gap.

    What problem are you trying to solve? Implementing things like variable scope awareness and caller information in the IDE by dumping some semi-static (I pause at calling it fully dynamic, perhaps out of ignorance) info produced by pre-execution phases of perl itself?

      > Implementing things like ...

      Yes, things like that ...

      The most common complaint about inability to parse Perl statically is that prototypes of imported subs are unknown and that they change the way the source is parsed.

      (Most) imports happen at compile time and are known in the CHECK phase after the code was parsed and compiled.

      > these cool questions

      FWIW: I originally posted this as meditation, it was moved afterwards.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery