Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created October 20, 2014 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizmat/16382a07084c5bb33d19 to your computer and use it in GitHub Desktop.
Save lizmat/16382a07084c5bb33d19 to your computer and use it in GitHub Desktop.
using private method instead of sub confuses the VM
$ git diff
diff --git a/src/core/Baggy.pm b/src/core/Baggy.pm
index 060b74f..56110d5 100644
--- a/src/core/Baggy.pm
+++ b/src/core/Baggy.pm
@@ -99,7 +99,7 @@ my role Baggy does QuantHash {
proto method grab(|) { * }
multi method grab(Baggy:D:) {
- my \grabbed := ROLLPICKGRAB1(self,%!elems.values);
+ my \grabbed := self!ROLLPICKGRAB1(%!elems.values);
%!elems.delete_key(grabbed.WHICH)
if %!elems.at_key(grabbed.WHICH).value-- == 1;
grabbed;
@@ -123,7 +123,7 @@ my role Baggy does QuantHash {
proto method pick(|) { * }
multi method pick(Baggy:D:) {
- ROLLPICKGRAB1(self,%!elems.values);
+ self!ROLLPICKGRAB1(%!elems.values);
}
multi method pick(Baggy:D: $count) {
ROLLPICKGRABN(self,
@@ -134,7 +134,7 @@ my role Baggy does QuantHash {
proto method roll(|) { * }
multi method roll(Baggy:D:) {
- ROLLPICKGRAB1(self,%!elems.values);
+ self!ROLLPICKGRAB1(%!elems.values);
}
multi method roll(Baggy:D: $count) {
$count ~~ Whatever || $count == Inf
@@ -142,8 +142,8 @@ my role Baggy does QuantHash {
!! ROLLPICKGRABN(self,$count, %!elems.values, :keep);
}
- sub ROLLPICKGRAB1($self,@pairs) is hidden_from_backtrace { # one time
- my Int $rand = $self.total.rand.Int;
+ method !ROLLPICKGRAB1(@pairs) is hidden_from_backtrace { # one time
+ my Int $rand = self.total.rand.Int;
my Int $seen = 0;
for @pairs -> $pair {
return $pair.key if ( $seen += $pair.value ) > $rand;
$ 6 '<a b b>.BagHash.pick.say'
Cannot invoke this object (REPR: Null, cs = 0)
in method ROLLPICKGRAB1 at src/gen/m-CORE.setting:17865
in method pick at src/gen/m-CORE.setting:17841
in block <unit> at -e:1
$ 6 '<a b b>.BagHash.roll.say'
Cannot invoke this object (REPR: Null, cs = 0)
in method ROLLPICKGRAB1 at src/gen/m-CORE.setting:17865
in method roll at src/gen/m-CORE.setting:17852
in block <unit> at -e:1
$ 6 '<a b b>.BagHash.grab.say'
Cannot invoke this object (REPR: Null, cs = 0)
in method ROLLPICKGRAB1 at src/gen/m-CORE.setting:17865
in method grab at src/gen/m-CORE.setting:17818
in block <unit> at -e:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment