Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
get "is default" working in the setting
and use it to get rid of some postcircumfix:<[ ]> candidates.
Adventurous minds can get rid of many more
  • Loading branch information
moritz committed Oct 9, 2013
1 parent d7e5e1d commit 06556e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
21 changes: 3 additions & 18 deletions src/core/array_slice.pm
Expand Up @@ -17,31 +17,16 @@ sub POSITIONS (\SELF, \pos) { # handle possible infinite slices
proto sub postcircumfix:<[ ]>(|) { * }

# @a[1]
multi sub postcircumfix:<[ ]>( \SELF, int $pos ) is rw {
multi sub postcircumfix:<[ ]>( \SELF, int $pos ) is rw is default {
fail "Cannot use negative index $pos on {SELF.WHAT.perl}" if $pos < 0;
SELF.at_pos($pos);
}
multi sub postcircumfix:<[ ]>(\SELF, int $pos, Mu :$BIND! is parcel) is rw {
fail "Cannot use negative index $pos on {SELF.WHAT.perl}" if $pos < 0;
SELF.bind_pos($pos, $BIND);
}
multi sub postcircumfix:<[ ]>( \SELF, int $pos, :$delete!, *%other ) is rw {
SLICE_ONE( SELF, $pos, True, :$delete, |%other );
}
multi sub postcircumfix:<[ ]>( \SELF, int $pos, :$exists!, *%other ) is rw {
SLICE_ONE( SELF, $pos, True, :$exists, |%other );
}
multi sub postcircumfix:<[ ]>( \SELF, int $pos, :$kv!, *%other ) is rw {
SLICE_ONE( SELF, $pos, True, :$kv, |%other );
}
multi sub postcircumfix:<[ ]>( \SELF, int $pos, :$p!, *%other ) is rw {
SLICE_ONE( SELF, $pos, True, :$p, |%other );
}
multi sub postcircumfix:<[ ]>( \SELF, int $pos, :$k!, *%other ) is rw {
SLICE_ONE( SELF, $pos, True, :$k, |%other );
}
multi sub postcircumfix:<[ ]>( \SELF, int $pos, :$v!, *%other ) is rw {
SLICE_ONE( SELF, $pos, True, :$v, |%other );
multi sub postcircumfix:<[ ]>( \SELF, int $pos, *%adv ) is rw {
SLICE_ONE( SELF, $pos, True, |%adv );
}

# @a[$x]
Expand Down
4 changes: 3 additions & 1 deletion src/core/traits.pm
Expand Up @@ -91,7 +91,9 @@ multi trait_mod:<is>(Routine:D $r, :$parcel!) {
$r.set_rw(); # for now, until we have real parcel handling
}
multi trait_mod:<is>(Routine:D $r, :$default!) {
$r does role { method default() { True } }
# needed in bootstrap of postcircumfix:<[ ]> where infix:<does> isn't
# defined yet, so cheat.
$r.HOW.mixin($r, role { method default() { True } });
}
multi trait_mod:<is>(Routine:D $r, :$DEPRECATED!) {
my $new := $DEPRECATED ~~ Bool
Expand Down

0 comments on commit 06556e9

Please sign in to comment.