Skip to content

Instantly share code, notes, and snippets.

use v6;
sub pretty($perl, :$indent = ' ') is export {
my ($pc, $depth, $string, $esc) = '', 0, False, False;
join '', gather for $perl.comb -> $cc {
NEXT $pc = $cc;
unless $string {
given \($pc, $cc) {

I'd like to change the NQP op set to provide two distinct sleep ops taking integer arguments in micro-second (or milli-second?) precision:

trysleep    r(int64)
sleep       w(int64) r(int64)

User-facing would be the following subs defined in the setting:

sub microsleep($micros) {

nqp::trysleep($micros);

@gerdr
gerdr / memmap.h
Created August 17, 2013 10:23
mmap wrappers for moarvm (totally untested)
#ifndef MEMMAP_H_
#define MEMMAP_H_
#include <stdef.h>
#ifdef _WIN32
#include <windows.h>
#ifdef _MSC_VER
#define inline __inline
@gerdr
gerdr / gist:6228451
Last active December 21, 2015 01:29
moarvm gerdr/libuv-build fail
prove -e D:\dev\p6\win32\bin\nqp.exe t\moar t\qast
t\moar\6model.t ................. ok
t\moar\annotated.t .............. ok
t\moar\associative.t ............ ok
t\moar\attribute.t .............. ok
t\moar\boxing.t ................. ok
t\moar\branching.t .............. ok
t\moar\calling.t ................ ok
t\moar\clargs.t ................. ok
t\moar\close_filehandle.t ....... ok
@gerdr
gerdr / gist:6204335
Last active December 20, 2015 22:19
moarvm naming ambiguities
should all of these be MVM*?
no prefix:
HashAttrStoreBody, Uninstantiable
P6 prefix:
P6int, P6num, P6str
mixed prefix:
MVMP6opaque
@gerdr
gerdr / foo.c
Last active December 20, 2015 21:59
how we structure C type definitions
// enumerations cannot be forward-declared
// the compiler needs to see its definition
// if it wants to choose an underlying type other than int
// therefore, we start with enum definitions
enum foo
{
FOO,
BAR
};
@gerdr
gerdr / Configure.pl
Last active December 20, 2015 20:39
MoarVM Configure.pl
#!perl
use 5.010;
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
my %SHELLS = (
@gerdr
gerdr / gist:6184541
Last active December 20, 2015 19:38
MoarVM configuration refactor

The current build system is too restrictive. I did an ad-hoc fix to get my setup to work, but a proper solution should respect the following configuration options:

host os --os

win32 vs posix

determines things like binary suffix or which libraries need to be linked (-lm -lpthread vs -lws2_32 -lmswsock ...)

build shell --shell

@gerdr
gerdr / gist:5922055
Last active December 19, 2015 07:58
shift semantics
Rakudo/Parrot, int and (soon) Int:
17 +> 3 = 2 # 17 div 2**3
-17 +> 3 = -3 # floor(-17 / 2**3)
17 +> -3 = 136 # 17 <+ 3 = 17 * 2**3
-17 +> -3 = -136 # -17 <+ 3 = -17 * 2**3
17 +< 3 = 136 # 17 * 2**3
-17 +< 3 = -136 # -17 * 2**3
17 +< -3 = 2 # 17 +> 3 = 17 div 2**3
-17 +< -3 = -3 # -17 +> 3 = floor(-17 / 2**3)
@gerdr
gerdr / shift.t
Created July 3, 2013 17:21
shift tests
use v6;
use Test;
plan 60;
sub check ($a, $b, $ls, $rs) {
is $a * 2**$b, $ls, "expected value $ls for shl $a by $b is sane";
is floor($a / 2**$b), $rs, "expected value $rs for shr $a by $b is sane";
is $a +< $b, $ls, "got expected value $ls for shl $a by $b";