Skip to content

Instantly share code, notes, and snippets.

View lizmat's full-sized avatar
💭
Functioning within parameters

Elizabeth Mattijsen lizmat

💭
Functioning within parameters
View GitHub Profile
@lizmat
lizmat / gist:0d9872224e2ae9832895027d472c0fb3
Created January 1, 2020 21:48
Stacktrace doing reproducible build test
$ raku --ll-exception t/02-rakudo/reproducible-builds.t
not ok 1 - Both precompilation runs resulted in the same checksum
# Failed test 'Both precompilation runs resulted in the same checksum'
# at t/02-rakudo/reproducible-builds.t line 31
# expected: 'A75D9F8DDB2AD75254C8ADD7D64577A172F6BEB1'
# got: '9B01D49145E306D7BE20C754A354CD98CB24C832'
Earlier failure:
(HANDLED) Failed to open file /var/folders/7_/ndrzv7y14fj0zxjx3fy0hfjm0000gn/T/rakudo-precomp65YO6VE9NNX926M41HDF7ZQGK/7A0D3C6CAB1AD38A10E52F00804CE6723378076E/00/000: No such file or directory
in block at t/02-rakudo/reproducible-builds.t line 34
in block <unit> at t/02-rakudo/reproducible-builds.t line 31
@lizmat
lizmat / gist:31a39891dce0d8ed07bd4739846fa047
Created December 22, 2019 21:38
Attempting to make handles trait a method on Attribute
diff --git a/src/core.c/Attribute.pm6 b/src/core.c/Attribute.pm6
index 1de2f2074..c544307e3 100644
--- a/src/core.c/Attribute.pm6
+++ b/src/core.c/Attribute.pm6
@@ -218,6 +218,89 @@ my class Attribute { # declared in BOOTSTRAP
method set_why($why) {
$!why := $why;
}
+
+ role Handles {
@lizmat
lizmat / gist:90974d3d89f7f64d02122362ff39c6cc
Last active September 26, 2019 12:30
alternate Proxy implementation
class Proxy {
has Mu &.FETCH;
has Mu &.STORE;
my constant $FETCH = method FETCH(\SELF:) {
my $self := nqp::create(Scalar);
nqp::bindattr($self, Scalar, '$!value', SELF);
nqp::decont(&!FETCH($self))
}
my constant $STORE = method STORE(\SELF: \value) {
@lizmat
lizmat / gist:71c32456b5de3cab33a5a833f3a8ea6a
Created September 26, 2019 09:04
Why do we need to create a Scalar for the Proxy object for each access / change ???
diff --git a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
index 963db37eb..ffef42e48 100644
--- a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
+++ b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
@@ -1739,14 +1739,10 @@ BEGIN {
Proxy.HOW.add_attribute(Proxy, BOOTSTRAPATTR.new(:name<&!FETCH>, :type(Mu), :package(Proxy)));
Proxy.HOW.add_attribute(Proxy, BOOTSTRAPATTR.new(:name<&!STORE>, :type(Mu), :package(Proxy)));
Proxy.HOW.add_method(Proxy, 'FETCH', ($PROXY_FETCH := nqp::getstaticcode(sub ($cont) {
- my $var := nqp::create(Scalar);
- nqp::bindattr($var, Scalar, '$!value', $cont);
@lizmat
lizmat / gist:8c0476706a473405f5b48793eff69f72
Last active September 25, 2019 16:21
proof of concept for "is tracked" variable trait
class History is Proxy {
has @.history;
method history() { @.history.skip.map: *<> }
method push(\value --> Nil) { @!history.push(value) }
method reset(--> Nil) { @!history = () }
}
sub historized-container() is raw {
my $value;
my $historized-container := History.new(
@lizmat
lizmat / gist:6b1fd58385a522886253ecb095edc323
Created September 23, 2019 08:24
Make Proxy honour subclassing
$ git diff
diff --git a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
index a26697224..17b8dc3e7 100644
--- a/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
+++ b/src/Perl6/bootstrap.c/BOOTSTRAP.nqp
@@ -1749,7 +1749,7 @@ BEGIN {
nqp::getattr($cont, Proxy, '&!STORE')($var, $val)
})));
Proxy.HOW.add_method(Proxy, 'new', nqp::getstaticcode(sub ($type, :$FETCH!, :$STORE!) {
- my $cont := nqp::create(Proxy);
$ git checkout newer-sprintf
Switched to branch 'newer-sprintf'
Your branch and 'origin/newer-sprintf' have diverged,
and have 16 and 6 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
LizyPro:rakudo.moar liz$ git rebase master
Current branch newer-sprintf is up to date.
$ perl6 --ll-exception t/spec/S32-io/socket-recv-vs-read.t
1..13
No such method 'recv' for invocant of type 'Any'
at SETTING::src/core/Exception.pm6:62 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/CORE.setting.moarvm:throw)
from SETTING::src/core/Exception.pm6:2797 (/Users/liz/Github/rakudo.moar/install/share/perl6/runtime/CORE.setting.moarvm:)
from gen/moar/BOOTSTRAP.nqp:3814 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/BOOTSTRAP.moarvm:)
from t/spec/S32-io/socket-recv-vs-read.t:27 (<ephemeral file>:<unit>)
from t/spec/S32-io/socket-recv-vs-read.t:1 (<ephemeral file>:<unit-outer>)
from gen/moar/stage2/NQPHLL.nqp:1835 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/NQPHLL.moarvm:eval)
from gen/moar/stage2/NQPHLL.nqp:2039 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/NQPHLL.moarvm:evalfiles)
@lizmat
lizmat / gist:83476091b86901b90fb0a005bab53986
Created July 5, 2019 07:04
stack trace Inline::Perl5
$ 6l 'use Inline::Perl5'
Cannot unbox a type object (int64) to int.
at gen/moar/stage2/QASTNode.nqp:387 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/QASTNode.moarvm:new)
from src/Perl6/World.nqp:3053 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/World.moarvm:add_constant_folded_result)
from gen/moar/Perl6-Actions.nqp:5163 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/Actions.moarvm:type_declarator:sym<constant>)
from gen/moar/stage2/QRegex.nqp:1545 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/QRegex.moarvm:!cursor_pass)
from gen/moar/Perl6-Grammar.nqp:2937 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/Grammar.moarvm:type_declarator:sym<constant>)
from gen/moar/stage2/QRegex.nqp:1644 (/Users/liz/Github/rakudo.moar/install/share/nqp/lib/QRegex.moarvm:!protoregex)
from <unknown>:1 (/Users/liz/Github/rakudo.moar/install/share/perl6/lib/Perl6/Grammar.moarvm:type_declarator)
from gen/moar/Perl6-Grammar.nqp:2187 (/Users/liz/Github/rakudo.
@lizmat
lizmat / gist:2ed4732f8acff8bba03aa371a130b78c
Created June 9, 2019 21:31
2 profiles of the same code, one before MoarVM bump, one after
<!DOCTYPE html>
<html lang="en" ng-app="moarProfApp" ng-controller="NavigationController">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MoarVM Profiler Results</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
<style>