Re: [Catalyst] what is the type of $context?

2006-06-09 Thread Carl Franks
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?

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.
Okay, we've now got cool modules such as Class::Accessor::Fast which
are easer to use than autoload, and which do insert the subs into the
symbol table, but there must be a lot of modules out there that still
do it the old way.

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?

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.

Cheers,
Carl

___
Catalyst mailing list
[EMAIL PROTECTED]
http://lists.rawmode.org/mailman/listinfo/catalyst


Re: [Catalyst] what is the type of $context?

2006-06-09 Thread Yuval Kogman
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



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/


Re: [Catalyst] what is the type of $context?

2006-06-09 Thread A. Pagaltzis
* Nilson Santos Figueiredo Junior [EMAIL PROTECTED] [2006-06-10 06:30]:
 Well, there's nothing stopping you from implementing this in
 Perl 5.

Sure, and then it will be used by you and two others and 98% of
the Perl code out there will remain unintrospectible by your pet
interface.

 What Perl 6 provides is just a default way of doing it. But
 Perl 5 is perfectly capable of doing it.

Exactly, and that makes All. The. Difference.

 If you adhere to a convention of specifying introspection
 meta-data you won't have to rely on guesses and heuristics (in
 whatever form that meta-data is available), this is true for
 any programming language.

Sure, and it also doesn’t buy you anything, because your solution
won’t be able to cope with most code.

 Perl 6 has a lot of nice features. But, IMO, a default
 instrospection API is not a significant one.

I think it’s quite significant. It’s not as important as other
things, but it opens the door to a class of things that are not
generically doable in Perl 5, so I’d say it’s pretty big in its
own right, even if it’s not the foremost reason to adopt Perl 6.

 explicit call semantics are […] nice not because they provide
 better introspection for the user, but because they might
 increase perl's ability to do compile-time validation, for
 example.

They are a nice feature for both reasons. This isn’t an either-or
matter. That they have additional (and arguably more important)
effects than introspection annotation ensures that people will
use them even without having introspection in mind, which makes
them yet more valuable for introspection. A nice synergy.



In any case, I stand by my assertion that introspection in Perl 5
is possible, but fraught with problems.

That Perl 6 will fix most of that is just a side note I threw in,
and I stand by that too. That this is the biggest reason to adopt
Perl 6 is something I never said, and if you had the impression
that I did, then it’s because you read into my arguments
something that wasn’t there.

Regards,
-- 
Aristotle Pagaltzis // http://plasmasturm.org/

___
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/