develooper Front page | perl.perl5.porters | Postings from May 2008

method call overloading: more better tests

Thread Next
Ricardo SIGNES
May 16, 2008 08:31
method call overloading: more better tests
Message ID:

I've written one more set of overloaded-method-invocation tests, attached with
a slightly improved version of the classless-root test.

The new tests is a class-based scheme.  In my vision of using overloaded
->method, the package-based old-style classes become places to put behavior
about how the "real" class works.  They are, in effect, simple metaclasses.
The new test has two of these: Class and Instance.  They differ primarily in
their universal methods and in how they dispatch.

I think that these two tests are really exciting!  They show that over the
course of a short bus ride, a middling Perl programmer like me can implement
two useful (if woefully trivial) new object systems.  Unfortunately, the needed
syntax currently is dreadful.  With -> overloading, custom, purpose-optimized
object systems can be made easily, with client code that looks just like good
ol' fashioned Perl.

  my $x = $instance->new;
  # Fatal: no instance method 'new' on Instance(ParentClass)

  my $x = $instance->class->new;
  # okay!

It cannot be resisted!


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About