Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Start to put back of and returns traits a bit more. We don't enforce …
…return type constraints yet, however.
  • Loading branch information
jnthn committed Mar 2, 2010
1 parent 9921175 commit 32a9461
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/traits.pm
Expand Up @@ -9,8 +9,8 @@ our multi trait_mod:<is>(Mu $child, Role $r) {

our multi trait_mod:<of>(ContainerDeclarand $cont, Mu \$type) {
given substr($cont.name, 0, 1) {
when '@' { }
when '%' { }
when '@' { $cont.container does Positional[$type] }
when '%' { $cont.container does Associative[$type] }
when '&' { }
default { pir::setprop__vPSP($cont.container, 'type', $type) }
}
Expand All @@ -23,3 +23,11 @@ our multi trait_mod:<does>(Mu $target, Mu $r) {
our multi trait_mod:<does>(ContainerDeclarand $c, Role $r) {
$c.container does $r;
}

our multi trait_mod:<of>(Routine $r, Mu \$type) {
$r does Callable[$type];
}

our multi trait_mod:<returns>(Routine $r, Mu \$type) {
$r does Callable[$type];
}

0 comments on commit 32a9461

Please sign in to comment.