in reply to Reflecting on Object

Since Perl can adjust its symbol tables on the fly, even WHILE making a call to a routine, this is akin to the unsolvable "halting problem."

You can scan the source code for the package file. You can scan the current state of the symbol table. You can even look at the source code to any AUTOLOAD and DYNALOAD libraries to see what they might hint at adding on the fly. [Update I forgot to mention that you'll then have to walk the @ISA tree for all inherited packages, each such package with the same problems.] And you'd still have a potentially incomplete list.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^2: Reflecting on Object
by tomazos (Deacon) on Jul 21, 2005 at 00:20 UTC
    OK, ignoring that, how do I scan the current symbol table for functions that will work with $obj?

    -Andrew.


    Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com
Re^2: Reflecting on Object
by Anonymous Monk on Jul 21, 2005 at 01:34 UTC
    Actually, this isn't equivalent to the halting problem. If you can guarentee that there are no other threads executing, it's possible to guarentee that the code you write to discover the available methods doesn't modify $obj in any way, and so you can know what methods are available right now. The problem is that that information is only good until you execute some code that might change $obj. It's also impossible to compensate for AUTOLOAD.
      You break your own argument here. From the caller's point of view, a call appears atomic, but thanks to AUTOLOAD, the call itself is able to modify the world, even before the eventually-installed method is entered. You can stop time just before the call, and still not prove what methods are available. QED.

      And words are important: I said 'akin,' not 'equivalent.' There are differences. However, they're both in a group of unprovable-because-the-domain-can-change problems.

      --
      [ e d @ h a l l e y . c c ]

        What the other AM means is that it is possible to determine which subroutines are available to classes (including the AUTOLOAD routine) *without* the class getting a chance to modify itself (or some code to modify the class). There's no need to call a method to find out whether it is defined. However, you cannot find out what is dealt with by AUTOLOAD (well, technically, if there's an AUTOLOAD, *anything* is dealt with, even if dealing with means not doing anything - if there's an AUTOLOAD, you won't get a perl generated "Can't locate object method" error for that class.
        "the call itself"? What call? I see no call here. We're not calling anything, we're just walking through the symbol table.