Skip to content

Instantly share code, notes, and snippets.

@vrurg
vrurg / MOP-generic-subset.raku
Created July 4, 2023 00:21
This is an example of creating a generic subset.
# This is an example of how a generic can be used by a nominalizable type from the MOP point of view.
# There is a catch in this example: there is no way to create similar subset via Raku syntax using the legacy grammar.
use nqp;
my \generic = Metamodel::GenericHOW.new_type(:name<T>);
say "Generic's name: ", generic.^name;
sub make-ctx(::T --> Mu) is raw {
# Instantiation of a generic requires a lexical context to work. This is how we can get it dynamically – and we
# do it by using another generic.
use Test;
my $v = 0;
my $st = now;
for ^100000 {
$v++;
}
my $et = now;
diag "Test time: " ~ ($et - $st);
unit class Bar;
use Foo;
also does Foo;
@vrurg
vrurg / rakudo-segv
Created February 1, 2022 16:18
Rakudo SEGV
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f9a85de6249 in exists_key () from //home/vrurg/src/Raku/rakudo-master/install/lib/libmoar.so
[Current thread is 1 (Thread 0x7f9a857db440 (LWP 3931316))]
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7f9a857db440 (LWP 3931316) 0x00007f9a85de6249 in exists_key ()
from //home/vrurg/src/Raku/rakudo-master/install/lib/libmoar.so
2 Thread 0x7f9a857d9700 (LWP 3931317) 0x00007f9a85e3a0a5 in add_usage_for_bb ()
from //home/vrurg/src/Raku/rakudo-master/install/lib/libmoar.so
role R[::T] {
my subset RS of T where { note "VALIDATING ", $_, ", T:", T.^name; True };
method the-subset { RS }
method foo(RS $vrs) {
pass "got value " ~ $vrs.raku
}
}

My comments are in quotes like this one.

I think title must reflect the subject somehow. Perhaps, include the "architechture" word.

Red is a ORM for Raku that tries to mimic Raku's Seq's API but to query databases.

Since the document is aiming at potential contributors, this sentense is redundant. They already know its ORM, its about DBs. The only useful part of it is about Seq mimicing.

Prerequsites

  • Project: https://github.com/vrurg/raku-Vikna/tree/for-comma-debug
  • Rakudo stack is built with ./Configure.pl --gen-moar --gen-nqp --backends=moar – nothing specific
  • Just in case, as the project needs chained dispatchers, there is a branch v-dispatcher for it in either the main rakudo repo or in my fork at https://github.com/vrurg/rakudo/tree/v-dispatchers
  • A breakpoint is set in lib/Vikna/EventHandling.rakumod. Basically any line within !run-ev-loop method is ok. Last time it was line 58.
  • The script I'm using for testing is t/desktop/010-screen-resize.t
  • The debugging can be configured with option start suspended set to any on or off, makes no difference. I usually start suspended, so my scenario is based on this.

What happens:

use Bench;
my $rcnt = 0;
my $wcnt = 0;
class C {
has $.a is rw;
has $.b is rw;
submethod TWEAK {
my $a;
README.md
atom-desert-syntax/
atom-keyboard-macros-vim/
atom-macros/
atom-perl6-editor-tools/
build/
busy-signal/
character-table/
desert-ex-syntax/
desert256-syntax/
use v6.d;
unit module Baz;
sub test is export {
"The Ultimate Question"
}
our &test-test is export := &test;