🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
ugexe yes 00:01
presumably you are reaching the end of your script before all the threads have finished 00:02
you should await all of your promises first
SrainUser Should I use map for await then? 00:03
I'm not sure how else to assign to promises in a loop. 00:08
00:14 jpn joined 00:18 jpn left
.landyacht. you can do a gather, e.g. my @promises = gather for 1..5 { take start { say 'hi'; } }; 00:21
I believe await can take an array, so you don't even need to await each individually 00:22
01:14 jpn joined 01:20 jpn left 01:26 ryoskzyp1 joined 01:30 ryoskzyp1 left
ugexe or push them into an array you await outside the loop 01:41
my @promises; for 1..5 { push @promises, start { say "hi" }; }; await @promises; 01:42
evalable6 hi
hi
hi
hi
hi
ugexe await eager gather for 1..5 { take start { say "hi" } } 01:43
evalable6 hi
hi
hi
hi
hi
ugexe await (1..5).map({ say "hi" });
await (1..5).map({ start { say "hi" } });
evalable6 hi
hi
hi
hi
hi
02:01 skyesoss joined, skyesoss left
timo m: await do for 1..5 { start { say "hi $_" } }; say "done" 02:07
camelia hi 1
hi 2
hi 3
hi 4
hi 5
done
02:16 jpn joined 02:21 jpn left, SrainUser left 02:29 SrainUser joined 02:40 esh left 02:52 nil78 left 02:54 esh joined 02:57 hulk joined 02:58 kylese left 03:02 nil78 joined 03:12 nil78 left 03:14 guifa joined, nil78 joined 03:15 hulk left, kylese joined 03:17 jpn joined 03:21 jpn left 03:37 wbooze joined 03:46 sorenson left 03:48 sorenson joined 04:10 jpn joined 04:15 jpn left 04:33 wbooze left 04:50 jpn joined 04:52 simcop2387_ joined 04:53 simcop2387 left 04:54 simcop2387_ is now known as simcop2387 04:55 jpn left 04:58 wbooze joined 05:08 Aedil joined 05:15 Aedil left 05:19 Aedil joined 05:36 guifa left 05:47 jpn joined 05:53 jpn left 06:07 wbooze left 06:18 wbooze joined 06:23 wbooze left 06:26 wbooze joined 06:41 nil78 left 06:44 wayland joined 06:45 nil78 joined 07:14 jpn joined 07:19 jpn left 07:21 jpn joined 07:26 jpn left 08:00 Sgeo left 08:18 jpn joined 08:25 jpn left 08:27 jpn joined 08:35 jpn left 08:37 jpn joined 08:45 jpn left 09:31 jpn joined 10:00 comborico1611 joined, oodani left 10:16 sftp left 10:17 melezhik joined, sftp joined
melezhik do we have Rakudo binaries for ARM/Linux? don't see any on rakudo.org/downloads/rakudo 10:18
10:19 comborico1611 left
wayland Hi! A question (probably for librasteve): Do we have anything that makes a Raku library that's basically just stubs around a Rust library? I'm looking at github.com/ballsteve/xrust (since I've had plenty of problems with libxml, and am looking for an alternative). I noticed github.com/librasteve/raku-Inline-Rust from librasteve++ and am wondering how far we've moved in that direction, and how much work it'd be to wrap a library like the 10:24
one I linked. I'm guessing from the doco that it's pretty bare-bones and we don't currently do any auto-generation?
10:34 melezhik left 10:42 euandreh left, euandreh joined, euandreh left 10:45 bdju left 10:55 bdju joined 11:05 nil78 left 11:11 nil78 joined
librasteve wayland: yup ... my puny attempt was really a set of notes to self on how to combing FFI and Rust ... as noted I never felt it was worthy of module status 11:33
generally I would recommend wrapping a native C library rather than a Rust one since Rust has no ABI ... the implication is that generally you cannot map a random struct and then pass back and forth (I think that's the case, but I am definitely not an expert in FFI) ... so the way I ended up working with Rust was to stick to vanilla native Array and Pointers and then translate data up and down to objects ... kind 11:39
of like every Rust object can be represented by a Raku proxy - but very action at a distance-y
11:39 SrainUser left
wayland: i read www.ottorask.com/blog/creating-an-...ry-in-rust that there is a way to C bindgen from rust 11:41
wayland: chatgpt.com/share/67b86704-e768-80...df8b64404b may also be a clue as to consuming c bindings into raku -- iirc someone here was working on automating this ... so maybe others can help? 11:45
11:58 topnep left 11:59 topnep joined 12:01 vrurg left 12:06 apac joined
antononcube @wayland Using Rust is not a good idea. It is too much of a "moving target." 12:52
There are plenty of good, exemplary packages for binding Raku with C. Say, by titsuki or bduggan. 12:54
12:54 guifa joined 12:57 wbooze left 13:08 wbooze joined 13:12 Aedil left 13:15 oodani joined 13:42 nil78 left 13:46 nil78 joined 14:01 Aedil joined 14:03 topnep left 14:05 topnep joined 14:21 vrurg joined 14:22 vrurg left 14:24 vrurg joined 14:37 lichtkind joined
tbrowder .tell timo i updated doc PR 14:46
tellable6 tbrowder, I'll pass your message to timo
14:47 abraxxa-home joined 14:49 abraxxa-home left 14:58 apac left 15:22 yewscion joined 15:25 MyNetAz left 15:27 wayland left, wayland76 joined 15:33 Sgeo joined 15:40 MyNetAz joined 16:09 topnep left 16:11 topnep joined
tbrowder hi, i've asked @ugexe about this before, but is there any practical way to disambiguate two zef/installed binaries with the same name? from my user view the internam 16:58
*internal used modules do that, but afaik currently a new module with a binary of the same name will just over-write the duplicate. 16:59
i guess it would take an overhaul or extension of the existing system. 17:00
ugexe not really no. fwiw the binary does not get overridden though. when you install raku code with a bin file it also gets a wrapper. the wrapper could theoretically provide options to disambiguate and choose a different one 17:01
you can sort of do it if you put all your bin/ code in a module, but then you have to invoke it like `raku -e 'use Zef::CLI:ver<0.1.2>' install Foo::bar` 17:02
tbrowder hm, too bad. i've been naming my bin files with a short prefix based roughly on the parent module name... 17:04
oh, well, "c'est la vie!" 17:05
ugexe the problem is there just isnt a good way to allow disambiguating that is also easy for the user. adding flags like --use-version --use-auth etc to the wrapper (i.e. `myscript --use-version=0.1.2` means users MAINs cannot use options with the same name when installed (while working fine when not installed). having environment variable that could be used like `RAKU_BIN_USE_VERSION=0.1.2 myscript`
doesn't work because that env var would affect any other script invocations that myscript may itself spawn
tbrowder yepper, thnx for reminder 17:06
hm, on linux one can easily provide aliases for command, so maybe that could be lee 17:07
*leveraged with yr zef bin location somehow 17:08
ugexe raku -e 'require ($*REPO.repo-chain.grep(CompUnit::Repository::Installation).map({ .files("bin/zef", :ver<0.22.7>).Slip }).grep(*.defined).map(*.<source>).head)' 17:14
you can replace bin/zef and :ver<...> with whatever binary and version you want
which should suffice for writing your own wrapper for an alias or whatever 17:15
17:24 Manifest0 left 17:39 xinming left, Manifest0 joined
tbrowder thanks! 17:43
sounds like it should be mentioned in the raku weekly (as well as someone's blog) 17:45
18:05 wbooze left, yewscion left 18:08 yewscion joined 18:14 topnep left 18:15 topnep joined 18:41 yewscion left 18:45 jpn left, apac joined 18:55 librasteve_ left, ryoskzypu left 18:56 ryoskzypu joined 19:00 yewscion joined 19:41 ryoskzypu left 19:47 ryoskzypu joined 20:09 ryoskzypu left 20:25 ryoskzypu joined 20:46 melezhik joined
melezhik I don't know why but zef install is extremely slow on my qemu instance 20:47
it literally hangs on installing even a simple module without even dependencies  , like Kind
real0m14.640s for command `zef --version` 20:48
which is weird 20:49
20:50 melezhik left
timo melezhik, can you check what you get when you set RAKUDO_MODULE_DEBUG=1 to see if it's doing any precompilation? if it is doing precompilation, it might be using more ram than your qemu instance has configured maybe? are you on an architecture without moarvm JIT (anything except x86_64), etc? can you share more details? 20:55
21:19 lizmat left 21:21 lizmat joined 21:37 apac left
wayland76 antononcube: OK, good to know. Is it a moving target at the language level, or just the ABI level? As to using C, I don't really like any of the C XML libraries -- libxml crashes (segfaults) too much, and think the others are proprietary. 21:41
librasteve: Thanks! Good info. 21:42
librasteve wayland76: fwiw I have had some success with the raku.land/zef:raku-community-modules/XML and raku.land/zef:tony-o/HTML::Parser::XML modules, not sure what they use under the hood 21:45
guess you want speed 21:46
wayland76 At this point, speed is optional, but I'm struggling with XML; will probably post a gist soon. I've already done a couple of PRs to address the problems I see. 21:48
I hadn't seen HTML::Parser::XML; I might need to check that one out.
librasteve since I am lazy, I would use Inline::Perl5 and metacpan.org/pod/XML::Parser - using libexpat.github.io on the basis that it may well be stable and quite fast - and likely to be quick to assemble the parts ;-) 21:49
21:50 librasteve_ joined
librasteve_ ? 21:50
wayland76 Oh, nice idea! I've also just spotted DOM::Tiny, so looks like I've got some good options :) 21:51
librasteve_ some notes to self on how to do stuff with raku XML module www.irccloud.com/pastebin/6meVfH3B
wayland76 antononcube, I've just seen the answer to my own question: blog.rust-lang.org/2025/02/20/Rust-1.85.0.html indicates language changes.
librasteve_: I'm trying to make something that will walk any kind of tree, and I'd like that to include XML trees. I'm not much fussed what backend I use, as long as the Element object "does Positional" for child nodes, and "does Associative" for attributes. 21:53
21:53 sena_kun joined
librasteve here's the full source of what I did on XML to migrate some pesky files 21:53
github.com/librasteve/ACPI-Migration
oh, ok - i think i see 21:54
wayland76 librasteve_: Not sure I understand why you sent the "?" -- I'm assuming you didn't follow something I said, but I don't know which part.
librasteve well HTML is XML right
wayland76 Subset of XML with more leeway, but yes :). 21:55
librasteve that's just me going from discord to ircloud and chaking i am on the same channel (easier to post text snippets), sorry 21:56
22:01 kst left
wayland76 Oh, OK :) 22:02
22:10 Aedil left 22:13 yewscion left 22:21 kst joined 22:25 topnep left 22:26 jpn joined, lichtkind left 22:28 topnep joined
wayland76 DOM::Tiny has the same bug I just fixed in the XML class -- the HasChildren role doesn't "does Positional" 22:52
Hi all! I'm struggling with a bug, probably in XML, but could be my code. I've made a gist at gist.github.com/wayland/c414a6b563...2a7bebf62f with code, output, and a comment that explains it. If anyone can help, that'd be much appreciated. Thanks! 23:10
23:28 yewscion joined 23:31 yewscion left 23:32 sena_kun left
lizmat there's a lot of superstituous parens here: gist.github.com/wayland/c414a6b563...p-raku-L33 23:41
my @inputs = ('A',), ('B','C', ('E','F','G', %( A => 'E', E => 'A')));
wayland76 I probably could've reduced that a bit, but I wanted it to walk some of the nodes and not others. Specifically, it's walking the nodes that do Positional. 23:43
lizmat for @inputs.grep(Positional) -> $input
maybe better readable, then lose the next line
for @inputs.grep(Positional) -> @inner { 23:44
wayland76 But will that grep descend into all descendents? I'm trying to make a generic treewalk that works on both regular arrays and XML documents.
lizmat grep will not descend
23:44 zetaaaa joined
wayland76 That's what I expected. 23:45
lizmat it'll smartmatch with the topic
wayland76 To clarify, it's really line 19 that I'm trying to debug.
lizmat if you're sure the elements are Positional, you can have them bound to an "array" -> @inner 23:46
wayland76 ...and line 5.
Why is it descending properly on the regular arrays, and not on the XML ones?
lizmat line 19 should probably be: 23:47
@retvals.append(WalkTreeMatch($child)); ?
wayland76 OK, just tried that, and it's still an infinite loop. 23:49
lizmat are you sure there are no recursive structures ? 23:50
23:50 yewscion joined
lizmat wayland76: anyways, it's way past my bedtime... I'll look at it tomorrow and leave anything I find (unless someone else beats me to it) 23:51
23:55 yewscion left
wayland76 Pretty sure -- it's a straight XML document, so shouldn't be recursive. Line 15 even prints out the first child according to [], and that's correct, but then when I loop over $input, 23:55
... 23:56
I think I've figured out that I'm debugging the wrong line. Line 17 is not actually going to the child, it's sitting on the same node it already was. If I can't sort it, I'll update the gist with one more line of debugging, and then wait for your response tomorrow. 23:57