🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
00:02 reportable6 left 00:06 lucerne left, lucerne joined 00:29 simcop2387 joined 00:30 perlbot joined 01:30 bloatable6 left, linkable6 left, unicodable6 left, sourceable6 left, coverable6 left, quotable6 left, greppable6 left, committable6 left, bisectable6 left, nativecallable6 left, notable6 left, tellable6 left, benchable6 left, shareable6 left, statisfiable6 left, evalable6 left, releasable6 left, squashable6 left 01:31 notable6 joined, bisectable6 joined, linkable6 joined 01:32 tellable6 joined, unicodable6 joined, coverable6 joined 01:33 bloatable6 joined
Geth ¦ problem-solving: coke assigned to codesections Issue Consider renaming default branch from master to main github.com/Raku/problem-solving/issues/298 02:05
02:30 sourceable6 joined 02:31 nativecallable6 joined, releasable6 joined 02:33 shareable6 joined, benchable6 joined 03:05 reportable6 joined 03:15 tejr joined 03:31 squashable6 joined, quotable6 joined, greppable6 joined 03:32 statisfiable6 joined 04:32 quotable6 left, bloatable6 left, unicodable6 left, bisectable6 left, notable6 left, reportable6 left, statisfiable6 left, nativecallable6 left, sourceable6 left, releasable6 left, benchable6 left, greppable6 left, linkable6 left, tellable6 left, coverable6 left, shareable6 left, squashable6 left, evalable6 joined, nativecallable6 joined, linkable6 joined, squashable6 joined 04:33 coverable6 joined 04:34 releasable6 joined, statisfiable6 joined, benchable6 joined, bisectable6 joined 04:35 tellable6 joined, sourceable6 joined
Geth doc: b00ffb3476 | (Daniel Sockwell)++ (committed by Juan Julián Merelo Guervós) | doc/Language/objects.pod6
Document attribute aliases

Part of the spec in Roast S12-class/attributes.t
linkable6 Link: docs.raku.org/language/objects
05:32 shareable6 joined 05:34 unicodable6 joined, notable6 joined 06:34 unicodable6 left, shareable6 left, linkable6 left, notable6 left, benchable6 left, releasable6 left, tellable6 left, bisectable6 left, nativecallable6 left, statisfiable6 left, evalable6 left, coverable6 left, sourceable6 left, squashable6 left, abraxxa joined 06:35 bloatable6 joined, nativecallable6 joined 06:36 linkable6 joined, benchable6 joined 06:37 shareable6 joined, squashable6 joined, notable6 joined, coverable6 joined 06:41 abraxxa left 06:42 abraxxa joined 07:03 reportable6 joined 07:32 greppable6 joined 07:33 quotable6 joined 07:43 Sgeo left 08:14 dakkar joined 08:28 lichtkind joined 08:31 committable6 joined 08:35 releasable6 joined, bisectable6 joined 08:37 statisfiable6 joined, tellable6 joined, evalable6 joined, unicodable6 joined 09:13 pounce left 09:18 frost joined 09:19 pounce joined 09:42 pounce left 09:43 pounce joined 10:04 immedlate joined
grondilu "fooooooo" ~~ /o+/; # how do I get the number of 'o's from $/ ? 10:05
$/.chars won't work if there was no o 10:07
m: "" ~~ /o+/; say $/.chars
camelia Use of Nil.chars coerced to empty string

in block <unit> at <tmp> line 1
grondilu m: "ooooo" ~~ /o+/; say $/.chars 10:08
camelia 5
10:11 lizmat_ joined 10:12 TempIRCLogger left, Geth left 10:13 RakuIRCLogger left, lizmat left
immedlate What about `$/.defined ?? $/.chars !! 0` 10:19
m: "" ~~ /o+/; say $/.defined ?? $/.chars !! 0
camelia 0
immedlate "oOo" ~~ /o+/; say $/.defined ?? $/.chars !! 0
evalable6 1
immedlate or with `with`: `($/.chars with $/) or 0` 10:20
similarly `with $/ { $/.chars } else { 0 }`
or `without $/ { 0 } else { $/.chars }` 10:21
grondilu that's quite verbose
it's a bit of a hassle to have to deal with the special case of 0 10:22
raydiak could always just change the + to *
grondilu damb 10:23
Altreus or you could use the fact it didn't match "foooo" ~~ /o+/ ?? $/.chars !! 0;
in case your case is more complex 10:24
grondilu of course with * it works, I'm dumb, sorry 10:26
raydiak don't be too hard on yourself. with so many tools in reach it's easy to overlook one 10:28
Altreus We had a similar question the other day when the answer was to change the question :D 10:32
easily overlooked
gfldex m: "" ~~ /o+/; say +$/.?chars 10:59
camelia Use of Nil.chars coerced to empty string
in block <unit> at <tmp> line 1
gfldex m: "" ~~ /o+/; say +($/.?chars // 0) 11:00
camelia Use of Nil.chars coerced to empty string
in block <unit> at <tmp> line 1
gfldex m: "" ~~ /o+/; say ($/ // "").chars.Int
camelia 0
gfldex m: "ooo" ~~ /o+/; say ($/ // "").chars.Int
camelia 3
gfldex There may be a simple way to handle that in the Regex directly. 11:02
m: Nil.^methods.grep(*.name eq 'FALLBACK').say; 11:05
camelia (FALLBACK)
gfldex ok, .? on Nil is silly
11:13 linkable6 left, evalable6 left
grondilu iteration over a hash is undeterministic or something? 11:15
gfldex order of keys are randomised by design 11:16
grondilu ok, noted
Altreus kawaii_: by design! 11:17
11:21 timo left 11:41 lizmat_ left 11:42 lizmat joined
grondilu I tried to count the number of leading zeros in a list with `+(@a ...^ +*)` but this hangs if @a is full of zeros. Any suggestion? 11:48
no loop please ;)
m: +((0, 0) ...^ +*) 11:50
camelia (timeout)WARNINGS for <tmp>: 11:51
grondilu m: say +((0, 0, 1) ...^ +*)
camelia 2
Altreus ok I can't parse that. What's going on there :D 11:55
grondilu again, I'm just trying to count the number of leading zeros in a list. 11:56
I bet there is a simple, nice way to do it but I don't see it. 11:57
Altreus yeah but I don't understand what the magic spell you wrote actually does
leading zeroes implies strings, no 11:58
do you mean the number of zeroes in a list before the first nonzero
grondilu yes
Altreus gotcha
grondilu I don't want to write a loop. That would be lame. 11:59
Altreus is it just @a.first({ * != 0 }, :k) 12:00
i.e. the index of the first nonzero value
... plus one
no not plus one :D
grondilu m: say +(0, 0, 1).first: +* 12:01
camelia 1
grondilu m: say +(0, 0, 0, 1).first: +*
camelia 1
grondilu m: say +(0, 0, 0, 1).first: +*, :k
camelia 3
grondilu m: say +(0, 0, 0).first: +*, :k 12:02
camelia Use of Nil in numeric context
in block <unit> at <tmp> line 1
Altreus aha!
so it's that or the length of the list
12:02 reportable6 left
grondilu couldn't I do that with a grep and a flip flop? 12:07
12:08 Geth joined, RakuIRCLogger joined 12:11 TempIRCLogger joined
grondilu m: say <0 0 0 1 2 0>.grep({ 0 ff none(0)}) 12:12
camelia (0 0 0 1 0)
grondilu m: say <0 0 0 1 2 0>.grep({ 0 fff none(0)})
camelia (0 0 0 1 0)
grondilu m: say <0 0 0 1 2 0>.grep({ (state $ = 1) &&= !$_ }) 12:16
camelia (0 0 0) 12:17
grondilu I guess I'll use .first 12:18
gfldex grondilu: Do you mind if I qoute you on "I don't want to write a loop. That would be lame." ? :-> 12:25
grondilu well not sure I want to be quoted on that tbh ;) 12:28
I do hate writing loops though 12:29
Altreus explicit loops are rare in my experience
they're usually maps in disguise
raku certainly makes it a lot easier to avoid them 12:30
plus there's new structures like react-whenever, which I'm not sure whether they count as loops or not 12:31
12:32 immedlate left
gfldex m: multi sub prefix:«+\c[COMBINING RING ABOVE]»(\r) { r.defined ?? +r !! 0 }; say +̊(0, 0, 0).first: +̊*, :k; 12:43
camelia 0
gfldex And no, my terminal can display that operator correctly either. 12:44
gfldex Adds an item to the mischief list. 12:45
grondilu I'm confused by the ring above the opening parenthesis 12:46
the one above the * I get (I think) 12:47
13:05 reportable6 joined 13:10 immedlate joined
gfldex grondilu: not even Firefox is displaying that one correctly 13:11
the circly is above the + but not centered 13:12
so the +̊( looks like a ligature 13:13
I don't think I'm gonna do that again…
13:13 linkable6 joined
immedlate what terminal do you use gfldex if you dont mind sharing 13:14
gfldex Putty+screen right now
13:15 evalable6 joined
gfldex immedlate: here is the complete setup gfldex.wordpress.com/2016/08/31/on...ingertips/ 13:15
Altreus looks fine for me 13:16
so you did it right, at least :D
"No, it's the children who are wrong"
gfldex I'm not sure if I want to be right on your screen but not on mine. 13:17
Altreus Well I mean at least there's nothing for *you* to fix 13:18
grondilu gfldex: do you ssh from windows? 13:26
gfldex yes
grondilu do you know that the Windows terminal has a native ssh client now? 13:27
and the Windows terminal is actually good, with full unicode support for instance. 13:29
github.com/Microsoft/Terminal Microsoft has been quite open-source friendly lately. 13:30
gfldex grondilu: Does it work well with GNU Screen on the other end?
grondilu gfldex: I don't know about screen but I was using tmux with no issue. 13:31
13:31 Sgeo joined
Slaytanical i found: github.com/rakudo/rakudo/blob/mast...unning.pod and: github.com/ugexe/zef#more-cli are there more sources of environment variables i'd have to make myself aware of to isolate a raku environment to a USB drive? 14:08
or am i better off still compiling from source in something like msys2? 14:09
Xliff Hi! 14:12
Will a % parameter accept an Associative $? 14:13
m: sub a (%h) { say 'hash' }; my $a = 1 but Associative; a($a)
camelia hash
Xliff Hah!
Slaytanical nevermind on the msys2 bit, i forgot it's not an isolated environment really. 14:26
[Coke] wonders how quickly after a new set of unicode emojis is announced that they are available on win & mac. 14:30
(some nifty/funny ones in emoji/14)
14:31 evalable6 left, linkable6 left 14:32 evalable6 joined 14:35 sourceable6 joined 14:38 jess left 14:41 cnx left, cnx joined
codesections is there a good way to check the exit status of a command run with qx { }? I know I could add ; echo "$?" } to the end, but that feels a bit sloppy 14:48
(or just use &shell) 14:49
ugexe even if there was an e.g. $! for "last ran process exit status" it would be just as sloppy due to its inherit race condition 14:56
codesections m: say shell("invalid").exitcode 14:58
camelia /bin/sh: invalid: command not found
codesections ugexe: I'm not sure I understand? I was thinking of something like ^^^ but for qx. There's no race condition there, right? 14:59
ugexe if you want the Proc itself then why would you use qx? 15:00
so yes there is no race condition there
codesections fair enough. I guess I just like qx -- it feels less like I'm just passing strings around. But it isn't really, so I should probably just use shell 15:02
jdv even in the same thread it couldn't be fetched in a non-racy way? 15:06
codesections (it looks like the source for qx is at github.com/rakudo/rakudo/blob/mast...#L261-L265 In my ideal world, I think I'd have that return an IntStr that numifies to the exit code, the way Procs do) 15:08
jdv that seems like unnecessary magic but it might be easier than trying to get it to work if you fetched it in the next instruction or something like that 15:10
ugexe jdv, maybe but even then im not sure since i believe it uses async processes under the hood
jdv yeah, right... 15:11
forgot its built on async 15:15
Xliff codesections: gist.github.com/Xliff/b9d290cc5262...111434d7e9
15:19 squashable6 left
codesections Xliff :) But that loses the ability to use arbitrary unicode pairs as the delimiter for qx, which is a big part of its appeal vs &shell, imo 15:20
ugexe and i guess even if it was in the same thread you'd then have to have the equiv of `my $!;` to keep processes spawned in other unrelated threads (not just reentrant ones) from setting it
gfldex codesections: do you get a non-0 exit code to indicate failure? If so, there is a module for that. 15:26
codesections gfldex oh? 15:31
15:33 melezhik joined
melezhik :m sub foo ($a) {} 15:33
m: sub foo ($a) {}
camelia ( no output )
melezhik m: sub foo ($a) {}; foo(1);
camelia ( no output )
melezhik m: sub foo ($a) {}; my $a; foo($a);
camelia ( no output )
melezhik how can deal with this error - `Type check failed in binding to parameter '$user'; expected Any but got Mu (Mu)` ? 15:34
my function declared as `foo ($user) {}`
15:34 linkable6 joined
melezhik however if a $user is not defined and calls `foo($user)` I get this error 15:34
codesections the brute-force way is to declare it as `foo(Mu $user) {}`, but you might want to deal with the Mu before the callsite 15:35
15:35 frost left
melezhik I wonder why my function complains about this at all 15:36
for example it works fine when I do this: `my $user; foo($user)`
codesections well, the default constraint for params is Any. And the default type for $-sigiled vars is Any 15:37
so that works fine
melezhik github.com/melezhik/mybutterflies/...p.raku#L99
here $user and $token get passed by cro as cookes 15:38
15:38 timo joined
melezhik and get this `mbf Type check failed in binding to parameter '$user'; expected Any but got Mu (Mu)` 15:38
changed the signature 15:40
codesections I suspect you want `get -> 'project', $project, 'edit-review', :$user! is cookie, :$token! is cookie` for that signature
Xliff codesections: Hmmm... good point. Would have to write a module with an included slang to get that working. :/
melezhik github.com/melezhik/mybutterflies/...d1f23be1a6
works fine nw
thanks codesections 15:41
codesections but note the difference between `:$user` and `:$user!` for Cro. The first matches *regardless* of whether the client has a user cookie (which is why it's sometimes Mu). The second only matches if the have a user cookie 15:42
melezhik ^^^ 15:43
melezhik yes, I am aware
cookies might not be set
codesections Ok, just making sure :)
15:49 melezhik left 16:12 Woodi left
gfldex codesections: see: github.com/gfldex/raku-shell-pipin...r-handling 16:13
16:21 squashable6 joined 16:22 Woodi joined 16:42 dakkar left 17:03 melezhik joined
melezhik hi Raku people! I've launched a better version of "My Butterflies" - a place where one can rate software they like. I'd appreciate for feedback from community. Eventually I am going to get a DSN and whatnots. But I am very interested to get a feedback before - 17:05
if someone wants to bragg about their projects - feel free - let me know and I put them to list. Raku projects are priority ... )))) 17:06
also please be nice, even though you review python stuff , ha-ha :') 17:08
daxim evalable6: subset List5 of List where .elems == 5; my @foo = List5.new: <q w e r t>; # how is this supposed to work? my List5 @bar = <q w e r t>?? 17:15
evalable6 (exit code 1) You cannot create an instance of this type (List5)
in block <unit> at /tmp/LaV96KsfdJ line 1
17:17 melezhik left
japhb subset List5 of List where .elems == 5; my @foo is List5 .= new: <q w e r t> 17:21
m: subset List5 of List where .elems == 5; my @foo is List5 .= new: <q w e r t>
camelia You cannot create an instance of this type (List5)
in block <unit> at <tmp> line 1
japhb Oh interesting
m: subset Array5 of Array where .elems == 5; my @foo := Array5.new: <q w e r t> 17:22
camelia You cannot create an instance of this type (Array5)
in block <unit> at <tmp> line 1
japhb hum 17:23
17:32 melezhik joined
melezhik weekly: www.reddit.com/r/rakulang/comments...e_reviews/ 17:32
notable6 melezhik, Noted! (weekly)
Altreus melezhik: interesting idea but is there any moderation on what counts as software?
like, maybe you get raku and then maybe you get modules and then maybe you get ... functions?! I dunno
deduplication seems like a task as well 17:33
melezhik Altreus , that's the very idea of dog fooding, not only check the web site, but also test the idea itself. I am flexible, it could be any software and I have not yet decided on the level of granularity ... 17:38
I just think - it's cool to have a place where engineers write about software, honest, in depth reviews, instead of smarmy marketing stuff ... 17:39
and I like to check it with raku community first, before expand to other languages/communities ... 17:40
Geth doc: 2faaff0c55 | Coke++ | xt/word-variants.t
18:02 reportable6 left 18:04 reportable6 joined 18:17 silug4 joined, silug left, silug4 is now known as silug 18:22 abraxxa left 18:25 abraxxa-home joined
grondilu you know, I wish there was a $*MODULUS environment variable to set up modular arithmetics. Wouldn't that be neat for crypto stuff? 18:49
Could this be done in user/module space? 18:50
lizmat m: PROCESS:<$FOO> := 42; say $*FOO # yes ?
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix := instead.
at <tmp>:1
------> 3PROCESS:<$FOO> :=7⏏5 42; say $*FOO # yes ?
lizmat m: PROCESS::<$FOO> := 42; say $*FOO # yes ?
camelia 42
18:51 melezhik left
grondilu I know setting the variable can be done, but could it be made to affect Int arithmetics? 18:51
lizmat ah. that? not without affecting performance of *all* Int arithmetic 18:52
18:52 abraxxa-home left
grondilu what about changing the interpretation of literal integers? That could be done, right? 18:55
from user code, I mean. 18:56
with macros or something?
lizmat possibly
moon-child grondilu: what are you trying to do? 18:57
grondilu use Mod13; say 12 + 1; # 0 18:59
lizmat use Mod13 could export a proto infix:<+> with all new candidates 19:01
so you *can* do that in a module
grondilu indeed, not sure why I didn't see it that way. 19:02
hang on 19:03
lizmat it will *only* affect that lexical scope, yes 19:04
grondilu I can't override core candidates, can I?
lizmat sure you can, by exporting a proto
grondilu ok but inside that candidate how would I call the core ones? 19:05
moon-child lizmat: I thought operator overloads sometimes had dynamic scope, at least conceptually
there was a pr not long ago to make sort respect overridden &[cmp]
lizmat m: proto infix:<+>(|) {*}; multi sub infix:<+>(Int \a,Int \b) { 42 }; say 999 + 42e0 19:07
camelia 5===SORRY!5=== Error while compiling <tmp>
Calling infix:<+>(Int, Num) will never work with any of these multi signatures:
(Int \a, Int \b)
at <tmp>:1
------> 3nfix:<+>(Int \a,Int \b) { 42 }; say 999 7⏏5+ 42e0
lizmat m: proto infix:<+>(|) {*}; multi sub infix:<+>(Int \a,Int \b) { 42 }; say 999 + 666 19:08
camelia 42
lizmat moon-child: yeah, but the problem is that &[cmp] is that List.sort *lexically* only sees the &cmp of the core
and the question is: should it only look lexically for that, or also dynamically 19:09
and that's what the PR is about
grondilu m: dd &COMPUNIT::infix:<+> 19:10
camelia Any element{'&infix:<+>'} = Any
grondilu m: proto infix:<+>(|) {*}; multi sub infix:<+>(Int \a,Int \b) { &COMPUNT::infix<+>(a, b) mod 13; }; say 12 + 1 19:11
camelia Cannot resolve caller infix:<mod>(List:D, Int:D); none of these signatures match:
(Real $a, Real $b)
in sub infix:<+> at <tmp> line 1
in block <unit> at <tmp> line 1
grondilu m: proto infix:<+>(|) {*}; multi sub infix:<+>(Int \a,Int \b) { &COMPUNIT::infix<+>(a, b) mod 13; }; say 12 + 1
camelia Cannot resolve caller infix:<mod>(List:D, Int:D); none of these signatures match:
(Real $a, Real $b)
in sub infix:<+> at <tmp> line 1
in block <unit> at <tmp> line 1
grondilu see what I mean? 19:12
moon-child hmm, there may be an easier way
one moment
grondilu maybe with the routine form of the operators. Not sure what it is though 19:13
moon-child hmm, no. I thought you might be able to say: augment class Int { method new(\x) { self.bless(x mod 13) } }. But apparently it has to be a multi, and that candidate never gets selected 19:15
grondilu I could make a role of course 19:20
19:20 vrurg left
grondilu like, my $n = 7 but Modular(13); or somethinp 19:22
but I think I had tried that before and I still didn't like it. Too verbose.
moon-child you could just overload == and leave all the other operators the same 19:23
grondilu well that would be inefficient. And that wouldn't work for modular inverse. 19:24
making a role was kind of messy too because of the possibility of having several modulus in an expression. 19:25
like what to do with (5 but Modulo(13)) + (6 but Modulo(7)) 19:26
thus me thinking of having a single modulus as an environment variable. 19:27
oh wait isn't there a keyword to delegate a method to the next candidate or something? 19:31
moon-child nextsame? 19:32
grondilu yeah, under "re-dispatching" in the docs 19:33
m: proto infix:<+>(|) {*}; multi sub infix:<+>(Int \a,Int \b) { callsame mod 13; }; say 12 + 1
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
mod used at line 1
grondilu m: proto infix:<+>(|) {*}; multi sub infix:<+>(Int \a,Int \b) { callsame() mod 13; }; say 12 + 1
camelia Cannot resolve caller infix:<mod>(Nil:U, Int:D); none of these signatures match:
(Real $a, Real $b)
in sub infix:<+> at <tmp> line 1
in block <unit> at <tmp> line 1
grondilu m: proto infix:<+>(|) {*}; multi sub infix:<+>(Int \a,Int \b) { callsame(); }; say 12 + 1 19:35
camelia Nil
grondilu m: proto infix:<+>(|) {*}; multi sub infix:<+>(Int \a,Int \b) { return callsame(); }; say 12 + 1
camelia Nil
grondilu whispers
moon-child because the builtin &[+] isn't a candidate for the new proto you just made 19:36
grondilu oh yeah makes sense
so I overwrite everything or nothing, I guess. That's not very useful. 19:39
lizmat note that you *can* override all and still access the old 19:42
grondilu Maybe I should just define a 'm' suffix. 19:44
lizmat m: BEGIN my &old = &infix:<+>; proto sub infix:<+>(|) {*}; multi sub infix:<+>(\a, \b) { old(a,b) }; say 42 + 666
camelia 708
lizmat m: BEGIN my &old = &infix:<+>; proto sub infix:<+>(|) {*}; multi sub infix:<+>(\a, \b) { old(a,b) }; my $a = 42; say $a + 666
camelia 708
grondilu neat trick 19:45
lizmat grondilu: ^^ between the proto and the catchall, you can insert your own candidates
grondilu m: BEGIN my &old = &infix:<+>; proto sub infix:<+>(|) {*}; multi sub infix:<+>(\a, \b) { old(a,b) mod 13 }; say 12 + 1 19:46
camelia 0
grondilu nice
so it's feasible 19:48
19:49 bgran joined
grondilu I'm so going to write a secp256k1 module now ;) 19:50
lizmat ++grondilu 19:59
20:30 immedlate left 21:19 melezhik joined
melezhik how can I remove cookies using cro ? 21:19
I have very strange bug when my cookies works fine when tested with safari and I see random issues with working with another browsers, like Mozilla 21:23
for mbf -
I don't think that cookies format is specific to browsers? 21:24
basically I use standard cro function - github.com/melezhik/mybutterflies/....raku#L232
to set cookies on server side ...
that is it
duck duck go browser works fine as well ... 21:28
yeah, just checked things, looks like does not work properly in Firefox (( 21:31
21:39 [Coke] left
melezhik github.com/croservices/cro-http/issues/155 21:50
21:55 melezhik left 22:05 melezhik joined
melezhik if cro caches GET requests? if so, how to disable this cache? 22:15
22:24 melezhik left 22:47 lichtkind left 23:47 linkable6 left, evalable6 left 23:50 linkable6 joined, squashable6 left 23:51 squashable6 joined