Sorry if this has already been asked and answered, but in doing a little research 
about Perl 6
mixins (http://www.perlmonks.org/index.pl?node_id=384858), I ran into some questions 
that I
couldn't figure from either A12 or "Perl 6 and Parrot Essentials."

First, how does one access the instance in a constructor?  Let's say I need to create 
a child node
of a parent node:

  method new(Class $class: Node $parent) {
    $:parent = $parent;
    my $self = $class.bless(0, $parent); # is this correct?
    $parent.add_child($self);
    return $self;
  }

I'm also trying to figure out method disambiguation with mixins.  A12 states that 
mixins are to be
implemented via anonymous inner classes and related via inheritence.  Thus, a later 
mixin will
override a previous mixin, but this seems to cause the problems we already have with 
mixins:

  $driver does SanitationEngineer does RaceCarDriver;

So my $driver who does some racing as a hobby now has no choice but to drive his dump 
truck like
mad through the streets.  That dump truck had better have darn good brakes.  Is there 
some other
method (pun not intended, but I'll take it) of disambiguating these?  The delegation 
syntax looked
promising, but it seemed to be a compile-time tool.

Cheers,
Ovid

=====
Silence is Evil            http://users.easystreet.com/ovid/philosophy/indexdecency.htm
Ovid                       http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

Reply via email to