On Fri, Jun 09, 2006 at 20:57:29 +0100, Carl Franks wrote:
> On 09/06/06, Yuval Kogman <[EMAIL PROTECTED]> wrote:
> > On Fri, Jun 09, 2006 at 11:25:40 +0100, Carl Franks wrote:
> >
> > > I'd be surprised if there *was* a way to do intropection with perl5.
> >
> > WTF? Perl is possibly the most lax and free minded language there is
> > WRT inrospection. You can even hack in meta classes if you try hard
> > enough.
> >
> > What other language lets you poke around the instance's structure,
> > know it's class at runtime, and has a hash as a symbol table?
> 
> Daniel defined introspection as: "dump a list of all the subs it supports".
> As I said, how can there be a *reliable* way of doing that?

Well, like mst said there's Class::Inspector and friends, but they
are just convenience wrappers around Perl itself.

> I know I've used autoload in the past to provide getter/setters
> without having to copy/paste subs - they would never show up in the
> symbol table.

->can etc can help with that. An AUTOLOAD aware ->can is one of the
first steps towards producing an introspectable interface. That
said, you can check for ->can("AUTOLOAD") to see if the module
responds to methods computationally. Sometimes the object cannot
give you a method list because the list of methods you can invoke
changes at runtime, or may be infinite. This does not mean it's not
introspectable.

> Would using Class::C3 effect the possible methods, or just the
> order of method-calls?  Is it not possible that if a class uses
> something other than plain @ISA / SUPER, then simply looking at
> the symbol table for everything in @ISA may not be correct?

Yes and no - if an AUTOLOAD exist that's the AUTOLOAD method whose
behavior is catch-all. It means that methods calls which don't match
an existing method will go to it, not that those methods don't
exist.


> btw, I don't know the proper definition of "introspection" with
> regard to programming - if it's broader than I was using it, then
> sorry for any confusion.

Say you have a variable:

        $x;

in an well introspectable language you can find out what it is
without making assumptions. What type of variable it is, what it's
class is if it's an object, and that kind of meta data. For OOP
systems this extends further - you can also ask questions about a
class. Lastly, it implies that you can programmatically locate
methods and invoke them, in a non static way.

-- 
  Yuval Kogman <[EMAIL PROTECTED]>
http://nothingmuch.woobling.org  0xEBD27418

Attachment: pgpKZDI9nj3JP.pgp
Description: PGP signature

_______________________________________________
List: [EMAIL PROTECTED]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to