Daniel Ruoso wrote:
Em Qui, 2009-03-12 às 10:28 -0700, Larry Wall escreveu:
On Thu, Mar 12, 2009 at 08:51:45AM -0700, Ovid wrote:
: > From: David Green <david.gr...@telus.net>
: > I suppose, but is there a reason why you want to apply roles instead of coercing : > the results? : Because I am coming from Moose instead of Perl 6 and didn't know about this :) Note however that coercions require parens these days, since types parse
as values, not as routine names.
    $x = Role::Serializable::XML($resultset);
    $y = Role::Serializable::YAML($resultset);

Er... wouldn't that create a proto-object sending $resultset as the
attribute for the only attribute that the Role can have? being the
equivalent to:

  $x = Role::Serializable::XML{ :attr($resultset) }

It is even supposed to fail if that Role declares more than one
attribute...

Or am I missing something?

IIRC, that's a special syntactic form that only counts when it is on the RHS of but or does. (And yes, in this case it fails if the role has more than one attr...) I think in all other cases, it's a coercion.

Jonathan

Reply via email to