introspection (and Perl 6)

Ovid publiustemp-londonpm at yahoo.com
Mon Jan 21 17:43:26 GMT 2008


--- Aaron Trevena <aaron.trevena at gmail.com> wrote:

> On 21/01/2008, Jeff Anderson <captvanhalen at gmail.com> wrote:
> > $class.^can('foo')
> >
> > That syntax is nearly as elegant as mud is not. :P
> 
> Yes - what's wrong with just having a can method, it's say not ^say,
> so why the silly hat?
> 
> And yes, I am bitching about perl 6, mostly because I'm starting to
> write code in it and some of the syntax changes like this are just
> WTF.

I think the problem here is that when you universally shove things into
all objects, you force your changes on everyone.

  $class.^can('foo');

That's actually shorthand for:

  $class.HOW.can('foo');

You can still do this:

  $class.can('foo');

But if another programmer needs to override can() in a subclass, you
can still allow easily reach the original can() method, if needed. 
This method is properly kept in a metaobject (fetched, of course, with
$class.HOW) which is separate from the class itself.  It's a good step
towards metaprogramming, but since 'can' isn't entirely honest, it
seems broken to me.

Since not many people get into metaprogramming, however, it might not
have much effect.

Cheers,
Ovid

--
Buy the book  - http://www.oreilly.com/catalog/perlhks/
Perl and CGI  - http://users.easystreet.com/ovid/cgi_course/
Personal blog - http://publius-ovidius.livejournal.com/
Tech blog     - http://use.perl.org/~Ovid/journal/


More information about the london.pm mailing list