Welcome to the main channel on the development of MoarVM, a virtual machine for NQP and Rakudo (moarvm.org). This channel is being logged for historical purposes.
Set by lizmat on 24 May 2021.
timo1 if we give substr a :copy, maybe Match.Str also wants a :copy 01:59
MasterDuke you get a :copy! everybody gets a :copy! 02:03
kueppo Hello there! 10:41
I'm a learner and I'm reading moarvm source code as a reference so please excuse me if I mixing stuff and at the end they donot make sense at all, so here is my question.
What are the raku op extensions archive and where are they located in the generated bytecode after linking differents objects generated from the compilation of the different compilation units or it is that bytecode for every extension(say pick for arrays) fitted into different object before linking or it is loaded dynamically at runtime?
tellable6 2023-06-20T01:29:24Z #raku <guifa_> Kueppo63: you can check with .WHICH to see if you're getting the same actual array
lizmat kueppo: not sure what you mean by "extension" 10:43
but if you're talking about the .pick method on Array objects
that.s something MoarVM doesn't really know about afaik 10:44
kueppo yes, I donot see the opcode for that in moarvm code
but how come does it compile that if i may ask?
*interpret
lizmat because MoarVM is a VM for NQP, really 10:45
and Rakudo is built on NQP
kueppo From what I've read rakudo compile code to bytecode and Moarvm executes it right? also donot understand very well the relationship between NQP, Rakudo and MoarVM can you please explain? 10:47
lizmat NQP is the language in which Raku is implemented in the Raku compiler
NQP can have multiple backend, of which MoarVM is but one, and JVM is another 10:48
when you compile Raku code with Rakudo, it internally builds an AST in NQP, which is then converted to bytecode and then run 10:49
kueppo Okay, got it 10:50
lizmat the "core" of Raku, is mostly Raku code itself, with some NQP mixed in for bootstrapping and/or performance 10:51
but e.g. the .pick method on Array objects, is implemented in Raku
and is no different from any logic that you might implement yourself in Raku 10:52
(except maybe for performance tweaks)
kueppo (write code in raku + NQP) -> (build AST in) -> (compile AST to bytecode) -> (pass to MoarVM) -> (more MoarVM executes) 11:29
The above is what I understood based on your explanation, hope it is correct
Now since MoarVM has nothing to do with pick, grep, map etc, I'm don't understand how it is able to handle their instruction sets given that it is written in another language, `split` for example is an opcode but how `grep` works?
in what language is NQP written in?
Voldenet in nqp
kueppo: to grasp more, you might want to see `nqp` binary
kueppo ok, mind blown 11:30
Voldenet nqp is sort of like raku, but really limited
m: sub foo($x) { $x ~ "bar" }; my $x = ""; $x = foo($x); say $x 11:32
camelia bar
Voldenet valid perl code
nqp: sub foo($x) { $x ~ "bar" }; my $x = ""; $x = foo($x); say $x
camelia ===SORRY!=== Error while compiling <tmp>
Assignment ("=") not supported in NQP, use ":=" instead at line 1, near " \"\"; $x = "
at NQP::src/HLL/Grammar.nqp:234 (/home/camelia/rakudo-m-inst-1/share/nqp/lib/NQPHLL.moarvm:panic)
from <unknown>:1 (/home/…
Voldenet s/perl/raku/
but not valid nqp code
nqp: sub foo($x) { $x ~ "bar" }; my $x := ""; $x := foo($x); nqp::say($x)
camelia bar
Voldenet to understand what's going on you want to start with github.com/Raku/nqp/blob/main/src/...nsMAST.nqp 11:34
iirc that connects to this file github.com/MoarVM/MoarVM/blob/main...core/ops.h 11:35
jnthn Things like `pick` and `grep` do get compiled into bytecode, if you have a Rakudo build tree look at blib/CORE.c.setting.moarvm (well, it's binary so `moar --dump blib/CORE.c.setting.moarvm` to get it disassembled) 13:09
Grep for `name : pick` in it or some such 13:10