This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q:PIR{ | |
loadlib $P0, 'rational' | |
}; | |
class Rat { | |
has $.v is rw; # Should be $!v; | |
submethod BUILD () { | |
$!v = Q:PIR{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Notes from my drive-time meditations... | |
Two semantics for Associative with multiple identical keys. | |
( :a<foo>, :a<bar> ) | |
#1 #2 | |
a => bar or a => ( foo, bar ) | |
What Perl5 users expect In regexp/Match for multiple <name> | |
Used to amend defaults In Hash.invert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# So for building ASTs we already have something like: | |
class Actions { | |
method foo { make $0 }; | |
#etc | |
} | |
# The complement would look something like this, using the same convention | |
# of matching names that appear as Grammar rules. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Current working rakudo recipe for making a CStruct member behave like a | |
# given type. (As of rakudo/rakudo 22c12b0cffa05d999fbf84b83eeb551922860ed5) | |
class A is repr('CStruct') { | |
# For a rw attribute, must use a private attribute. Using $.x gives error: | |
# "Cannot create rw-accessors for natively typed attribute '$!x'" | |
# (Also if you use $.x and then try to make a method x to write your | |
# own accessors you get an infinite loop at runtime. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Subject: Curried role compose fails in precompiled modules | |
When a parametric role is curried it works fine straight from source, | |
but when the role has been precompiled into a module, a parrot | |
error is thrown: | |
cat mod2.pm6 | |
role Foo [ ] { }; role Bar does Foo[] { } | |
$ PERL6LIB="." perl6 -e 'use mod2; class C does Bar { };' | |
$ PERL6LIB="." perl6 --target=pir --output=mod2.pir mod2.pm6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This trick can be used to temporarily work around some NYI areas of Perl6 Parametric Roles for a specific use case. | |
A known shortfall in the current Parametric Role implementation is NYI diamond composure: | |
role A { method foo ($x) { "HIYA".say } } | |
role B does A { } | |
role C does A { } | |
role D does B does C { } | |
class E does D { } | |
my E $e .= new(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Cargo-culted fix for right shift issues in nqp_bigint.ops. */ | |
/* This could be done better in a way that doesn't dirty so much write cache | |
for huge shifts/values, since the results are calculatable without actually | |
performing additions across the whole number. */ | |
inline op nqp_bigint_shr(out PMC, invar PMC, in INT, invar PMC) :base_core { | |
mp_int b; | |
mp_int *a = get_bigint(interp, $2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void grow_and_negate(mp_int *a, int size, mp_int *b) { | |
int i; | |
/* Always add an extra digit so we can tell positive values | |
* with a one in the highest bit apart from negative values | |
* with a zero in the highest bit. | |
*/ | |
int actual_size = MAX(size, USED(a)) + 1; | |
SIGN(b) = MP_ZPOS; | |
mp_grow(b, actual_size); | |
USED(b) = actual_size; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You have an unlimited supply of black and red checkers. | |
You stack checkers next to each other into two piles on a level table. | |
In the first pile, you stack N red checkers, then M black checkers, | |
then P red checkers, and then (possibly) repeat M black/P red checkers for | |
a total of X times. | |
In the second pile you do the same, with (possibly) different values |
OlderNewer