Moritz Lenz wrote:
chromatic wrote:
On Monday 06 July 2009 23:55:28 Moritz Lenz wrote:
I think abusing a class as a role is forbidden
I hope it's not!
Well, it surely depends on context. You can "pun" a role into a class by
instantiating it, but the correct way to apply it to another class seems
to be with 'does', not 'is'.
As it stands right now...
class C does R { } # composes the role
class C is R { } # inherits from the pun
class C1 is C2 { } # plain old class inheritance
class C1 does C2 { } # fails
I haven't found a concrete reference in the specs if it's actually
forbidden, a comment from jnthn or TimToady would be appreciated.
I've heard the whole "every class implies a role" and "you can take a
role as an immutable snapshot of a class" stuff touted now and then, but
as moritz points out, there's nothing concrete in the spec about that.
Unless that changes (which I'm open to it doing), don't expect Rakudo's
current semantics to change on this (aside from awesomizing the error
message).
Thanks,
Jonathan