introspection (and Perl 6)

Aaron Trevena aaron.trevena at gmail.com
Mon Jan 21 21:04:45 GMT 2008


On 21/01/2008, Ovid <publiustemp-londonpm at yahoo.com> wrote:
> --- 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?
>
> 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');

Kinda neat. :)

I don't mind the hat as long as it's shorthand for golfers that I'll
never need to use or read in production code.

> 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.

It's an improvement on what we have currently and well beyond the 80/20 :)

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

True. Especially considering how the after-market mod's from CPAN you
can apply to Perl 5 now - you should be able to do even more with perl
6 :)

I still think there are a bunch of WTF syntax changes in Perl 6, but
I'll reserve judgement until I've ported my code.

A.

-- 
http://www.aarontrevena.co.uk
LAMP System Integration, Development and Hosting


More information about the london.pm mailing list