Author: lwall Date: 2009-05-04 06:29:35 +0200 (Mon, 04 May 2009) New Revision: 26662
Modified: docs/Perl6/Spec/S14-roles-and-parametric-types.pod Log: [S14] syntax category declarations need symbol in brackets Modified: docs/Perl6/Spec/S14-roles-and-parametric-types.pod =================================================================== --- docs/Perl6/Spec/S14-roles-and-parametric-types.pod 2009-05-04 04:21:10 UTC (rev 26661) +++ docs/Perl6/Spec/S14-roles-and-parametric-types.pod 2009-05-04 04:29:35 UTC (rev 26662) @@ -11,8 +11,8 @@ Contributions: Tim Nelson <wayl...@wayland.id.au> Jonathan Worthington <jn...@jnthn.net> Date: 24 Feb 2009, extracted from S12-objects.pod - Last Modified: 30 Apr 2009 - Version: 4 + Last Modified: 3 May 2009 + Version: 5 =head1 Overview @@ -353,8 +353,8 @@ role xxx { has Int $.xxx; - multi trait_auxiliary:is(xxx $trait, Class $container; $arg?) {...} - multi trait_auxiliary:is(xxx $trait, Any $container; $arg?) {...} + multi trait_auxiliary:<is>(xxx $trait, Class $container; $arg?) {...} + multi trait_auxiliary:<is>(xxx $trait, Any $container; $arg?) {...} } Then it can function as a trait. A well-behaved trait handler will say @@ -366,19 +366,19 @@ matching, you can also say: class MyBase { - multi trait_auxiliary:is(MyBase $base, Class $class; $arg?) {...} - multi trait_auxiliary:is(MyBase $tied, Any $container; $arg?) {...} + multi trait_auxiliary:<is>(MyBase $base, Class $class; $arg?) {...} + multi trait_auxiliary:<is>(MyBase $tied, Any $container; $arg?) {...} } These capture control if C<MyBase> wants to capture control of how it gets used by any class or container. But usually you can just let it call the generic defaults: - multi trait_auxiliary:is(Class $base, Class $class; $arg?) {...} + multi trait_auxiliary:<is>(Class $base, Class $class; $arg?) {...} which adds C<$base> to the "isa" list of C<$class>, or - multi trait_auxiliary:is(Class $tied, Any $container; $arg?) {...} + multi trait_auxiliary:<is>(Class $tied, Any $container; $arg?) {...} which sets the "tie" type of the container to the implementation type in C<$tied>. @@ -389,8 +389,8 @@ auxiliaries". Here's "C<will>", which (being syntactic sugar) merely delegates to back to "is": - multi sub trait_auxiliary:will($trait, $container; &arg) { - trait_auxiliary:is($trait, $container, &arg); + multi sub trait_auxiliary:<will>($trait, $container; &arg) { + trait_auxiliary:<is>($trait, $container, &arg); } Other traits are applied with a single word, and we call one of those a @@ -399,7 +399,7 @@ role as { has ReturnType $.as; - multi sub trait_verb:as($container; ReturnType $arg) { + multi sub trait_verb:<as>($container; ReturnType $arg) { $container does as($arg); } ... @@ -409,7 +409,7 @@ compile-time traits are applied one at a time, like mixin roles. You can, in fact, apply a trait to a container at run time, but if you do, it's just an ordinary mixin role. You have to call the -appropriate C<trait_auxiliary:is()> routine yourself if you want it to +appropriate C<trait_auxiliary:<is>()> routine yourself if you want it to do any extra shenanigans. The compiler won't call it for you at run time like it would at compile time.