Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement default trait on variables.
Again, a first pass, but seems to basically work.
  • Loading branch information
jnthn committed Jul 25, 2013
1 parent 4766065 commit cd4831d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/Variable.pm
Expand Up @@ -4,3 +4,10 @@ my class Variable {
has $.var is rw;
has $.block;
}

# Variable traits come here, not in traits.pm, since we declare Variable
# in the setting rather than BOOTSTRAP.
multi trait_mod:<is>(Variable:D $v, :$default!) {
$v.var = $default;
nqp::getattr($v.var, $v.VAR.WHAT, '$!descriptor').set_default($default);
}

0 comments on commit cd4831d

Please sign in to comment.