🦋 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.
japhb timo: Cool asciinema! 00:05
FYI for anyone that doesn't know: I am in the process of selling/buying/moving my home, so if you want me to take a look at something, please do use my nick like timo did! :-) 00:07
(Otherwise I'll miss it, since I can't keep up with IRC at the moment.)
timo wait, i am supposed to use your nick? but you're already using your nick?? 01:18
xinming releasable6: status 07:53
releasable6 xinming, Next release will happen when it's ready. There are no known blockers. Changelog for this release was not started yet
xinming, Details: gist.github.com/b6382276b0757e6d77...cfd530558f
librasteve hi! I am using submethod TWEAK in a role - my guess is that this is then called on punning or on class new where the class does the role ...? is that roughly right? 10:48
the problem I have is that I want my role to have defaults but I want my doing class to have it's own defaults ... seems like one solution is to rename submethod TWEAK {...} in the role to method defaults {...} and then to go submethod TWEAK { self.defaults; ... } but that seems a bit manual. Perhaps a better way to ask is "How can I have a role do automatic self initialization?" 10:52
lizmat there is currently no way to do that automatic 10:58
you will need to do it manually, e.g.:
m: role A { method TWEAK(|c) { say "A"; dd c } }; class B does A { method TWEAK(|c) { say "B"; self.A::TWEAK(|c) } }; B.new(:a(42))
camelia B
\(:a(42))
A
librasteve yeah - I see ... thought that would be the case
tx! 10:59
guess it's probably best to keep the word TWEAK away from roles to help maintainability - I will stick with method defaults 11:00
lizmat fwiw, the object initialization machinery would support multiple TWEAK calls 11:04
we only need to decide how to indicate that, and possibly in which order they should be called
librasteve I imagine that "formally" the TWEAK/BUILD mechanisms could/should be confined to classes and that any parallel autoinit for roles be given a new name and potentially a different calling pattern --- why do I say that, well there's a bunch of things that work at compile time and a bunch of things that don't --- for example I tried to use BEGIN {...} to init my role (durrr). So to a beginner/intermediate coder then a 11:38
different name would make this a lot clearer ... maybe submethod TUNE {...}
I have discovered that I can either put my TWEAK in my class, or it can be provided in a role ... that's cool - but it still only gets called when the role is instantiated by a class ... so no need to change that if we have a new name 11:40
lizmat m: role A { method TWEAK { dd } }; A.new 11:48
camelia method TWEAK(A $:: *%_)
lizmat if you instantiate a role, the TWEAK will get called ?
in any case, a TUNE method would just be another way to apply syntactic sugar 11:49
in the object build mechanism it would just be another Callable to be called
patrickb Also, role init is a solved problem in 6.e. Vrurg put a lot of work into improving the situation. 11:55
blogs.perl.org/users/vadim_belman/.../post.html 11:57
librasteve, lizmat: ^ 11:58
lizmat patrickb: good point ! 12:04
guifa ah, I just needed to use 6.e.PREVIEW haha I was literally dealing with the overridden TWEAK the other day 12:59
lizmat yeah, TIL again
guifa I think the only major thing I've come across (and now forgotten the context) is to get the COMPOSE method, but I guess TWEAK is a decent enough substitute 13:03
lizmat there is no COMPOSE method afaik
it was sorta speculated
but never considered to be needed, as the mainline of a role serves that purpose 13:04
guifa hmm, mainline almost works 13:14
guifa problem is referencing $?CLASS almost always gets a "could not instantiate" error (makes sense) 13:15
actually wait, it's more than that. it gets called both at composition (foo does bar) but also on each instantiation. TWEAK sounds right for the latter 13:18
nope I'm an idiot and shouldn't think outloud. I was doing bar.new instead of foo.new in my example LOL 13:19
xinming Today when I organize chat log snippets I asked, I saw Zoffix answered a lot of my questions, How is he now? 13:25
patrickb I think little is known. From the little I've heard it seems he's fine and found other fun endeavors to pursue. 13:28
guifa he has popped back to the Raku world *very* occasionally
lizmat he is still missed 13:41
guifa indeed 13:50
[Coke] sends zoffix some good vibes. 14:20
antononcube @guifa What is the status of your LLM endeavors? 14:21
guifa antononcube: about to get back to it today
antononcube More importantly (for me) are you using chatbooks?
guifa had to finish up a project for my networking class
antononcube I have to update "WWW::Gemini" with Google's new models. (This should be automated soon.) 14:22
I hope to go to the Perl/Raku conference in June 2025. Is there any restriction for the number of talks a person can present? 14:31
librasteve patrickb, lizmat: I simultaneously hopeful and confused - not got time to try 6.e.PREVIEW (on something else) but will definitely let you'all know how it pans out ... no doubt I will have some troubles! 15:11
(getting mhy head around it)
tbrowder antononcube: i suspect not based on recent raku/perl conf in us 15:13
guifa antononcube: negative. What may happen is if there are a fair number of others we might balance things out 15:38
Geth advent: massa++ created pull request #119:
Update authors.md
16:29
Geth advent/main: 8405953843 | (Humberto Massa)++ (committed using GitHub Web editor) | raku-advent-2024/authors.md
Update authors.md (#119)

I have idea for two articles, and maybe a third... but I will only commit the two first for now
17:26
xinming Is it possible to get the memory usage of a var? 17:47
let's say 'my Num $v = 100', <-- In this case, Is it possible to know how much memory is used for the $var? 17:48
Geth advent/main: 121ad3fa52 | (Elizabeth Mattijsen)++ (committed using GitHub Web editor) | raku-advent-2024/authors.md
Schedule Marcel Timmerman's presentation
17:52
[Coke] with that, looks like we need 8 more blog posts to fill up the advent calendar this year. 18:42
coleman I'm on the list already. I'll get mine drafted soon. 18:43
[Coke] Thanks to everyone volunteering! 18:44
lizmat indeed!
[Coke] I am happy to act as an editor if anyone needs it
guifa zostay : heads up on your DOM::Tiny module, the auth: is off in META6.json 19:12
is there any good way to catch whenever a socket can't be opened? 19:32
lizmat CATCH { } ? 19:33
guifa it doesn't seem to be catching it
I wonder if somehow something deeper in Cro is consuming it?
lizmat ah, Cro... 19:34
:-)
guifa haha yeah
$service.start --> "Nope, can't get the socket"
it's super minor, but feels like from a webapp standpoint you don't really care too much which port you're on, you can launch on a random one 19:36
coleman For local dev? Maybe. But ports matter 19:37
Some languages (Go?) allow asking for a random listening port by passing 0 for the port number, e.g. net.Listen("tcp", ":0") 19:38
guifa yeah I was just about to try that to see if I could do 0
coleman The #cro channel is fairly active with Raku community members, too 19:39
xinming is it possible to get idx along val within .map method? 21:11
m: m: my @x = <a b c>; ((0 .. @x.elems) Z @x).map({ "index: {.[0]}, value: {.[1]}".say; }); 21:13
camelia index: 0, value: a
index: 1, value: b
index: 2, value: c
[Coke] instead of map you could do .kv.map?
my @x = <a b c>; @x.kv.rotor(2).map({say .[0], .[1]}) 21:15
evalable6 0a
1b
2c
[Coke] kv gives you a flat list, so you have to rotor it back to get the structure.
xinming [Coke]: Thanks, that's what I want.
[Coke] my @x = <a b c>; for @x.kv -> $k, $v { say $k, $v} 21:16
evalable6 0a
1b
2c
xinming the .grep with :k returns index, the .kv thing returns idx with values. Quite handy.
[Coke] ^^ if you can do a for, that's a little cleaner IMO
xinming Yea, I think pair is more useful in my case 21:17
m: my @x = <a b c>; @x.pairs.map({ "index: {.key}, value: {.value}".say; });
camelia index: 0, value: a
index: 1, value: b
index: 2, value: c
xinming :-)
bed time, thanks 21:18
[Coke] cool!
xinming I can sleep well without question hang in my head.
[Coke] the most relaxing 21:24
nahita3882 when map's mapper has arity 2, it also DWIMs, so we don't need to rotor actually 22:26
m: my @x = <a b c>; @x.kv.map(-> $k, $v {say "$k$v"})
evalable6 0a
1b
2c
Raku eval 0a 1b 2c
nahita3882 or with placeholders: 22:27
m: my @x = <a b c>; @x.kv.map({ say "$^k$^v" })
Raku eval 0a 1b 2c
evalable6 0a
1b
2c
nahita3882 conveniently ord("k") < ord("v")
[Coke] nice 22:28
librasteve m: my @x = <a b c>; @x.kv.map(~).say 22:56
evalable6 (exit code 1) ===SORRY!=== Error while compilin…
Raku eval (0a 1b 2c)
evalable6 librasteve, Full output: gist.github.com/f964d6fec078ff2894...dcd6d069fa
librasteve m: my @x = <a b c>; @x.kv.map(*~*).say 22:57
evalable6 (0a 1b 2c)
tbrowder lizmat: re advent: i’m having serious computer isd 23:31
*issues and will probably not be able to start on the first few days… 23:32