On Wed, 2002-05-15 at 21:38, root wrote: > > I've always liked how VB allowed you to define "instance methods." > Basically a more elegant way of doing callbacks, plus allows some > structure within your callbacks. Will Perl6 allow this (Perl5 sortof did, > but since the "bless" way of doing things is going away...) > > Perhaps... > > class foo {...} > > $x = new foo; #BTW, is there some standard way of creating instances > #now?
my $x is foo; # I think that's correct > method $x.frob() {...} > Since these are more for run-time sorts of things than compile-time sorts of things, perhaps you want that to be a closure. You could have a autoload check in UNIVERSAL (even in Perl5, not sure how in Perl6) that would work like so (Perl5 syntax): $x = foo->new(); $x->insmeth 'frob', sub {...}; # name wins 'cause it sounds Lovecraftian $x->frob(); So, you can already do this, though I would sit down and think long and hard about adding an autoload to UNIVERSAL in Perl5. Hopefully autoloading will be able to chain correctly in Perl6.