Skip to content

Instantly share code, notes, and snippets.

View usev6's full-sized avatar

Christian Bartolomäus usev6

  • Berlin, Germany
View GitHub Profile
@usev6
usev6 / seq_cmp.p6
Last active August 29, 2015 14:17
sequence for custom class
class A {
has $.val;
method Numeric { $.val };
method succ { say "DEBUG: method succ was called"; A.new( val => $.val+1) };
method pred { say "DEBUG: method pred was called"; A.new( val => $.val-1) };
}
multi sub infix:<cmp> (A $x, Int $n) { $x.val cmp $n };
multi sub infix:<cmp> (A $x, A $y) { $x.val cmp $y.val };
@usev6
usev6 / gist:bcdf2ada8cd523d37810
Last active August 29, 2015 14:21
something wrong with "a" ~~ /"$0"/ on rakudo.jvm
$ perl6-j --ll-exception -e '"a" ~~ /"$0"/'
Cannot unbox a type object
in warn (gen/jvm/CORE.setting:811)
in warn (gen/jvm/CORE.setting:807)
in Str (gen/jvm/CORE.setting:1212)
in Str (gen/jvm/CORE.setting:1208)
in Stringy (gen/jvm/CORE.setting:1222)
in Stringy (gen/jvm/CORE.setting:1219)
in infix:<~> (gen/jvm/CORE.setting:1649)
in infix:<~> (gen/jvm/CORE.setting:1647)
@usev6
usev6 / gist:602ad169eb6e3bcdf27e
Created May 14, 2015 12:49
weird content of %anno in "sub warn" in src/core/control.pm
$ perl6-j -e 'say "a" ~~ /"$0"/'
{:file("gen/jvm/CORE.setting"), :line(9411)}<>
{:file("gen/jvm/CORE.setting")}<>
{:file("gen/jvm/CORE.setting")}<>
{:file("gen/jvm/CORE.setting")}<>
{:file("gen/jvm/CORE.setting")}<>
{:file("gen/jvm/CORE.setting")}<>
{:file("gen/jvm/CORE.setting")}<>
{:file("gen/jvm/CORE.setting")}<>
{:file("gen/jvm/CORE.setting")}<>
@usev6
usev6 / gist:d29f551093a704624663
Last active August 29, 2015 14:21
Changes to src/core/Block.pm to make 'say { $^a }.assuming(123)()' work on JVM
diff --git a/src/core/Block.pm b/src/core/Block.pm
index 8e78e82..dbf937e 100644
--- a/src/core/Block.pm
+++ b/src/core/Block.pm
@@ -36,6 +36,7 @@ my class Block { # declared in BOOTSTRAP
}
method assuming(Block:D $b: |curried) {
+ 1;
anon sub CURRIED (|direct) {
@usev6
usev6 / gist:3697d60ce7fe77f0d680
Created June 19, 2015 21:12
STD output for 'my @foo; my $exists = @foo[0]:exists;'
$ viv -e 'my @foo; my $exists = @foo[0]:exists;'
VAST::comp_unit, BEG: 0, END: 38
│ └─LEX: !!perl/hash:Stash
│ '!file': &1
│ name: (eval)
│ '!id': &2
│ - MY:file<(eval)>
│ '!line': 0
│ $!: !!perl/hash:NAME
│ dynamic: 1
@usev6
usev6 / gist:8bd78b697a2e1367e381
Last active October 29, 2015 19:41
unbreak jvm build
diff --git a/src/core/Str.pm b/src/core/Str.pm
index 4b9fdb0..5cf4dcd 100644
--- a/src/core/Str.pm
+++ b/src/core/Str.pm
@@ -907,7 +907,7 @@ my class Str does Stringy { # declared in BOOTSTRAP
$!todo = $!todo - 1;
my int $found = nqp::index($!string,$!match,$!pos);
$found < 0
- ?? $!todo = 0
+ ?? ($!todo = 0)
@usev6
usev6 / gist:9be71bd04ea7d34c9595
Created October 29, 2015 21:22
build error for rakudo-jvm
Stage parse : Error while constructing error object:Could not locate compile-time value for symbol X::Syntax::ConditionalOperator::PrecedenceTooLoose
Error while compiling, type X::Syntax::ConditionalOperator::PrecedenceTooLoose
operator: =
at line 9861, near "?? $!todo "
in panic (gen/jvm/stage2/NQPHLL.nqp:399)
in typed_exception (src/Perl6/World.nqp:3812)
in throw (src/Perl6/World.nqp:3623)
in typed_panic (src/Perl6/Grammar.nqp:240)
in infix:sym<?? !!> (src/Perl6/Grammar.nqp:4194)
in !protoregex (gen/jvm/stage2/QRegex.nqp:1350)
@usev6
usev6 / gist:bac193a8b7219490993c
Last active November 2, 2015 23:05
Prevent "Method 'Int' not found for invocant of class 'Any'"
diff --git a/src/core/Failure.pm b/src/core/Failure.pm
index 70aa7be..4a7baff 100644
--- a/src/core/Failure.pm
+++ b/src/core/Failure.pm
@@ -56,7 +56,7 @@ my class Failure {
multi method Str(Failure:D:) { $!handled ?? $.mess !! self!throw(); }
multi method gist(Failure:D:) { $!handled ?? $.mess !! self!throw(); }
method mess (Failure:D:) {
- "(HANDLED) " x $!handled ~ self.exception.message ~ "\n" ~ self.backtrace;
+ "(HANDLED) " x ($!handled ?? $!handled !! 0) ~ self.exception.message ~ "\n" ~ self.backtrace;
@usev6
usev6 / gist:f7eaf093a38fb893e76b
Created November 6, 2015 07:17
baindaid rakudo.jvm
With the following changes I'm able to build rakudo.jvm on commit a2a34c26
The code I had to work around was modified by these three commits
* 5349d05c
* ad08a1d7
* cc4d72c4
$ git diff
diff --git a/src/core/Failure.pm b/src/core/Failure.pm
index 76ad01f..6d45344 100644
@usev6
usev6 / gist:132c79cefca8ce12607d
Created November 17, 2015 22:37
first element of $indices is (Any) here
use nqp;
my \iter = (3,2,1,4).iterator;
my \sort-buffer = IterationBuffer.new;
unless iter.push-until-lazy(sort-buffer) =:= IterationEnd {
fail X::Cannot::Lazy.new(:action<sort>);
}
my int $i = 0;
my int $n = sort-buffer.elems;