Skip to content

Instantly share code, notes, and snippets.

@skids
skids / dsmileynil.patch
Created July 22, 2016 21:16
Fix for :D = Nil (untested)
diff --git a/src/vm/moar/ops/container.c b/src/vm/moar/ops/container.c
index aaa7e63..b925ad6 100644
--- a/src/vm/moar/ops/container.c
+++ b/src/vm/moar/ops/container.c
@@ -85,13 +85,15 @@ static void rakudo_scalar_store(MVMThreadContext *tc, MVMObject *cont, MVMObject
if (!obj) {
MVM_exception_throw_adhoc(tc, "Cannot assign a null value to a Perl 6 scalar");
}
- else if (STABLE(obj)->WHAT == get_nil()) {
- obj = rcd->the_default;
diff --git a/src/core/Signature.pm b/src/core/Signature.pm
index 129b4e9..0cbe262 100644
--- a/src/core/Signature.pm
+++ b/src/core/Signature.pm
@@ -138,16 +138,26 @@ my class Signature { # declared in BOOTSTRAP
multi sub infix:<eqv>(Signature $a, Signature $b) { $a.perl eq $b.perl }
Perl6::Metamodel::Configuration.set_multi_sig_comparator(
- -> \a, \b { my $sa = a.signature.^find_private_method('gistperl')(
- a.signature, True, :where(-> $ { Nil }));
@skids
skids / rdp0222_performant.pm
Created February 23, 2016 15:06
reddit daily programmer perl 6 solution within striking distance of bonus.
$ time perl6 -e 'my %sw := SetHash.new; my $size = 5000000; for (0..^$size).pick xx 200000 -> $s is copy, $e is copy { ($s,$e) = $e, $s if $e < $s; %sw{+$s} +^= 1; %sw{+$e + 1} +^= 1 if $e < $size - 1; }; my $accum; my $o = 0; for %sw.keys.sort.rotor(2 => -1) -> ($s, $e) { $o +^= 1; $accum += $e - $s if $o; LAST { $accum += $size - $e unless $o }}; $accum.say'
2495015
real 1m25.943s
user 1m25.832s
sys 0m0.076s
# Just need two orders of magnitude improvement :-)
# Algorithm note: decompose each run of switch throws into throwing all the switches right (inclusive) of the leftmost switch,
@skids
skids / Never.pm6
Created February 20, 2016 22:38
inverted "when" statement
use nqp;
use QAST:from<NQP>;
sub EXPORT(|) {
role Control::Never {
rule statement_control:sym<never> {
<sym><.kok> <xblock>
}
}
role Control::Never::Actions {
method statement_control:sym<never>(|c) {
@skids
skids / rabbithole.txt
Created February 18, 2016 04:24
I knew I should have taken that left turn at Albequirky
So this is why I get lost in NQP/MoarVM.
Objective: figure out how to create a non-resumable subclass of Exception
Step 1: Look at Exception, notice "method resumable" checks $!ex at key 'resume' and "method resume" just calls nqp::resume
Step 2: Well, I could just override those, but what if the nqp op is called directly somewhere. Better investigate
Step 3: OK $!ex is made by calling "nqp::newexception". rgrep nqp tree for it
step 4: OK that's mapped to MoarVM "newexeception" op. Resist the urge to say "this goes to VM level too?!?"
since exceptions are pretty low level VM things. and I knew that would happen in this case.
There's a similar problem when using inline doc style: declarative POD cannot be easily nested inside a section, if that is what you want. For example if you are following manpage conventions, you'd want to start a DESCRIPTION block, then drop out of POD and put declaratives around your module, then end the DESCRIPTION block (explicitly, or implicitly by starting, say, a SEE ALSO block.
There's actually a way to get part of the way (=alias directives) but it is NYI. Having the ability to =alias before a declarative pod directive and populate the alias with the rendered pod would be nice. e.g.
=alias DOCSFORFOO
#| does foo things
sub foo {
}
=begin DECRIPTION
@skids
skids / packish
Last active May 2, 2020 20:56
packish things
So, after saying yesterday on IRC that a bottom-up design shoud come first for packish things
I somehow came over with a case of hypocrisy and thought a bit about top-downish stuff.
Suppose we had a role-like MOP construct (bikeshedding welcome on names):
packing foo {
template bar {
# pack template bottom level constructs
# templates can nest, and can come from mixing other packings
@skids
skids / loop_ecosystem
Created December 23, 2015 05:28
possily impacted modules
Definitely not a complete list of modules with while/loop in last statement of sub or whatnot.
Many are likely harmless but might bear correcting just for sake of sane return value.
Mostly I just did directories of authors whos names I remembered seeing a lot.
awwaiid/p6-lrep
azawawi/perl6-electron
colomon/mandelbrot
colomon/io-prompter
colomon/Test-Junkie
hoelzro/p6-priorityqueue
regex ℙ_production {
( <ℙ_new-lexical-item-name> ) <ℙ_lexical_separator>
'::=' <ℙ_lexical_separator>
# This next bit should be producing a prestructured lol-ish thing.
# Two things NYI|buggy prevent that:
# 1) @<alternatives>=(...)*
# 2) /(...) :my $f = $0; ($f)/
# So though it may appear the below several lines would be simpler
# put as [ $<a>=a | $<b>=b | $<c>=c ]* % <sep>
# they are kept in a future-looking form.
@skids
skids / altquasitexas.txt
Last active December 9, 2015 04:48
investigation of a possible quasi injection character/texas combo
A consideration of ‹ and › as quasi injection delimiters, or part thereof.
The compose-key (and thus texas mappings) are .< and .>
Advantage #0: easy to type
Disadvantage #1: texas not really symmetrical
Advantage #2: .> is not syntax for anything, I think (?)
Disadvantage #3: .< is syntax for $_<
Disadvantage #4: visual confusion with < and >