in reply to Perl 6 Shocking Revelations II - classes are built, not declared

I don't see how this is "shocking" in some sense, because you could do the exact same thing in perl 5 as well:
if (some_condition){ *custom_method = sub { do whatever you want }; }

(And arbitrary attributes an be added in p5 objects as well - but I don't have to show an example for that ;-)

This may be shocking if your background is primarily a C++ or Java one, but for perl hackers that's old news ;-)

Update for the monks who are not so familiar with Perl 6 object orientation:

In Perl 6 a class { stuff } directive runs stuff at compile time, "as the body of a method of the metaclass, which is responsible for interpreting the keywords of the class definition." (S12)

Why do we need meta classes? Well, perl 5 showed us that it's not very good to stick one object model - many programmer think it's not the best solution, and invent clever stuff like Moose to get around these limitations.

In Perl 6 you can just define your own meta classes if you don't like the default object model. That's why a class "declaration" is in fact just code that runs at compile time, and builds a class out of it.

Replies are listed 'Best First'.
Re^2: Perl 6 Shocking Revelations II - classes are built, not declared
by John M. Dlugosz (Monsignor) on May 08, 2008 at 23:32 UTC
    You are right, it's shocking to C++/Java people who have no concept of executing code at different "times" like in Lisp or Perl 5.