One of the things that got a little less clear with A12 was the idea of
multiple C<is> clauses.

Once upon a time, we talked about:

  my $spot is Dog is const is persistent is ...;

Obviously some of those are traits, now. However, I'm wondering how to
handle things like my recent suggestion of a class (metaclass instance) that
generated different accessor behavior.

The obvious way was:

  use GrammarMod;
  # use AccessorClass;

  NewKeyword thing {...}
  # accessor_class thing {...}

but isn't there a better way? In particular, is there some way for the trait
to declare that it modifies the metaclass, not the class, so that:

  use GrammarMod;
  # use AccessorClass;

  class thing is NewKeyword  {...}
  # class Obj is accessor_class { has $.foo is rw; }


would be able to change the metaclass behavior, not the class behavior?

At first blush, this is a macro:

  class OtherBehavior is MetaClass {...}
  # class AccessorClass is MetaClass {...}

  macro NewKeyword is parsed(<Perl6::ClassDecl>)
  {
    $0.meta_class = new OtherBehavior;
  }

but then there's the issue of composition.

Perhaps the accessor function behavior is a role, but it seems more like a
MetaRole:

  macro NewKeyword is ...
  {
    $0.meta_class will do OtherRole;
  }

Comment?

=Austin

Reply via email to