Skip to content

Instantly share code, notes, and snippets.


Jonathan Worthington jnthn

View GitHub Profile
View eval.p6
use Test;
lives-ok {
await Promise.allof((^3).map: {
start {
for ^200 {
EVAL "True";
jnthn / ffs.c
Created Mar 8, 2017 — forked from bdw/ffs.c
cross-platform first set bit
View ffs.c
#include <stdio.h>
#include <stdlib.h>
#define MVMint32 int
#ifdef __GNUC__
#define FFS(x) __builtin_ffs(x)
#elif defined(_MSC_VER)
static __inline MVMint32 FFS(MVMint32 x) {
MVMint32 i = 0;
View gist:7843dadbe45e3f56f02f6a679c21f407
Slide 3: Cross Compiler
- The NQP and Rakudo compilers are also cross-compilers by this definition,
since their output works on any platform
Slide 9: sysroot
- So if I follow, this is only relevant to compiling native code, and it says
where the headers etc. for that target platform live?
Slide 14:
- The MoarVM build process builds itself a minilua as a build tool. If I
jnthn /
Last active Feb 25, 2016
Answers to some concurrency questions
  1. Should two different taps of a a serial supply be run simultaneuosly?

$ perl6 -e 'my $p =; my $s = $p.Supply; $s.serial.say; $s.tap({ sleep 1; "42 {now}".say; }); $s.tap({ sleep 1; "43 {now}".say }); $p.emit(42); sleep 3;' True 42 Instant:1449454902.847377 43 Instant:1449454903.854135

No. Supplies do not introduce concurrency, at least not unless you explicitly ask for it with something like the start method. So the emit here is doing no more than a loop through the taps, calling the closures passed to tap one

View bounded-channel.p6
class BoundedChannel is Channel {
has $!lock =;
has $!send-cond = $!lock.condition;
has $.limit is required;
method send(|c) {
LEAVE $!lock.unlock();
while $!limit == 0 {
View gist:b291be5a7a18398849d4
multi trait_mod:<is>(Attribute:D $attr, :$chainymutable!) {
$attr does role {
method compose(Mu \package) {
my constant NO_ARG =;
my $this_attr = self;
$, # strip sigil
method (Mu \value = NO_ARG) {
if value =:= NO_ARG {
View gist:283979d6120c2278ee0e
C:\consulting\rakudo>perl6-m -Ilib t\04-nativecall\11-cpp.t
# Error while compiling C++ script:
# Running 'g++ --shared -fPIC -o 11-cpp.dll t/04-nativecall/11-cpp.cpp':
# 'g++' is not recognized as an internal or external command,
# operable program or batch file.
1..0 # Skip: Cannot compile C++ script
View gist:03e2082ca5ed20ff8d44
Given this example code, where we uncomment one of the commented lines (and yeah, this is a
very slow way to do a Range, but I didn't actually implement ranges yet):
my $i = 0;
my $nums := GLRSeq.from-loop({ ++$i }, { $i < 100000 });
my @b := GLRArrayCircumfix();
# @b = $nums.GLRmap({ next unless .is-prime; $_ });
# @b = $nums.race(:degree(1)).GLRmap({ next unless .is-prime; $_ });
# @b = $nums.race(:degree(2)).GLRmap({ next unless .is-prime; $_ });
# @b = $nums.race(:degree(3)).GLRmap({ next unless .is-prime; $_ });
jnthn / glr.p6
Last active Aug 29, 2015
Great List Re-implementation: initial draft/exploration
View glr.p6
# This file contains some work-in-progress bottom-up design work for the GLR.
# All types and operators introduced are prefixed with GLR, so there are no
# conflicts with those in core (the GLR prefix has even been used where there
# isn't anything in core to conflict with, to make clear what's being added).
# There's no syntax sugar, but rather explanations of what some syntax will
# desugar to are included. The various MAIN subs do tests to check correctness
# and various benchmarks to compare with what we have in Rakudo today.
# Up-front summary:
# * (1, 2, 3) makes a List; there is no Parcel. List supports laziness and