Skip to content

Instantly share code, notes, and snippets.

View LLFourn's full-sized avatar

Lloyd Fournier LLFourn

View GitHub Profile
@LLFourn
LLFourn / bench_samcv_branch.sh
Created April 7, 2017 07:21
The script I used to benchmark samcv++'s branch
for i in $(seq 1 5); do
./install/bin/perl6 -e '"a" x 1000000000 ~ "b" ~~ /b/; say now - INIT now;'
done | awk '{ v += $0; i++; }; END { print v/i }'
@LLFourn
LLFourn / native-int-perf.p6
Created March 12, 2017 05:45
Shows the difference in performance between native ints and vanilla.
#!/usr/bin/env perl6
sub perl6-loop($n)
{
my $sum = 0;
for 1..$n -> $i {
for 1..$i -> $j {
$sum += $i+$j;
}
}
@LLFourn
LLFourn / p6-top-10.md
Last active March 2, 2017 15:08
my Top 10 p6 features

My top 10 p6 features

My brain did work so I wrote it down. This is more for my use cases than why I think the language will succeed in general.

  1. containers
  2. grammars
  3. multi-dispatch (esp on type narrowness)
  4. lexical $_
  5. easy + sane defaults builtin OO
  6. Types as first class citizens + MOP
  7. lazy iterators
I've been getting segfaults in this area recently. The trace is a bit different but I guess it's related. It seems that flag_map in gc_mark is no longer allocated so I get segfault.
(lldb) r
There is a running process, kill it and restart?: [Y/n] y
Process 75673 exited with status = 9 (0x00000009)
Process 75691 launched: '/Users/llfourn/src/rakudo/install/bin/moar' (x86_64)
Process 75691 stopped
* thread #1: tid = 0x23cfc68, 0x0000000100063ca4 libmoar.dylib`gc_mark(tc=0x0000000100500290, st=0x0000000101004f40, data=<unavailable>, worklist=0x000000010d27c1a0) + 84 at MVMCallCapture.c:55, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10a72533)
frame #0: 0x0000000100063ca4 libmoar.dylib`gc_mark(tc=0x0000000100500290, st=0x0000000101004f40, data=<unavailable>, worklist=0x000000010d27c1a0) + 84 at MVMCallCapture.c:55
52 MVMuint16 count = ctx->arg_count;
@LLFourn
LLFourn / backtrace.txt
Last active June 26, 2016 16:54
rakudo segfault 27/6/16
#== WITH LLDB \o/
(lldb) run
Process 41869 launched: '/Users/llfourn/src/rakudo/install/bin/moar' (x86_64)
Process 41869 stopped
* thread #1: tid = 0x1a7644d, 0x0000000100063cf4 libmoar.dylib`gc_mark(tc=0x0000000100402a80, st=0x0000000100804b40, data=<unavailable>, worklist=0x000000010a0e61f0) + 84 at MVMCallCapture.c:55, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x0000000100063cf4 libmoar.dylib`gc_mark(tc=0x0000000100402a80, st=0x0000000100804b40, data=<unavailable>, worklist=0x000000010a0e61f0) + 84 at MVMCallCapture.c:55
52 MVMuint16 count = ctx->arg_count;
53 MVMuint16 i, flag;
54 for (i = 0, flag = 0; i < count; i++, flag++) {
-> 55 if (flag_map[flag] & MVM_CALLSITE_ARG_NAMED) {
use nqp;
my package EXPORTHOW {
package SUPERSEDE {
class subset is Metamodel::SubsetHOW {
has @!ss-params;
method parameterize($obj,*@params) {
@!ss-params = @params;
$obj;
}
@LLFourn
LLFourn / visitor-circular-dependencies.pm6
Last active May 29, 2016 17:07
Visitor Pattern package relationships in Perl 6
# this is a .gist to explain my solution wrt https://rt.perl.org/Public/Bug/Display.html?id=128275
# VisitorRoles.pm6
role Visitor {
method visit {...}
}
role Node {
method accept {...}
}
@LLFourn
LLFourn / backtrace.txt
Last active March 3, 2016 15:12
moarvm: pointer being realloc'd was not allocated
=====WHEN IT FAILS IN CLEANUP======
moar(74468,0x7fff7b6d9000) malloc: *** error for object 0x1098dd400: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Breakpoint 1, 0x00007fff96c6bf42 in malloc_error_break () from /usr/lib/system/libsystem_malloc.dylib
(gdb) bt
#0 0x00007fff96c6bf42 in malloc_error_break () from /usr/lib/system/libsystem_malloc.dylib
#1 0x00007fff96c5d001 in free () from /usr/lib/system/libsystem_malloc.dylib
#2 0x0000000100051f6d in gc_free () from /Users/llfourn/tmp/p6/rakudo/install/lib/libmoar.dylib
#3 0x000000010003c8c5 in MVM_gc_collect_free_gen2_unmarked ()
@LLFourn
LLFourn / provides.p6
Created February 23, 2016 03:26
create META6.json provides
use File::Find;
.say for find(dir => "lib", name => /\.pm6$/)».Str.map({"\"{.subst("lib/","").subst("\.pm6","").subst("/","::",:g)}\" : \"$_\","}
@LLFourn
LLFourn / negate-type.p6
Last active February 19, 2016 01:25
Why I want to negate Types
# introspecting the return vale of a sub
my $return-descr = do given &foo.returns {
when $_ !=== Any { "the programmer has not specified the return value" }
when Any:D { "returns a definite" }
when $_ !~~ Any:D { "returns a type object" }
when Any { "may return either a type object or a definite"}
}
# I would prefer to use something like ¬ (returns a subset type matching anything that doesn't match it)