🦋 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:04 reportable6 joined
patrickb tony-o, moon-child: Thanks for your input! I'm off to bed. 00:08
o/ 00:09
00:09 patrickb left 00:42 pony left
Geth doc: rakool++ created pull request #3990:
Fix error re: delegation and simplify some text.
00:47
00:58 discord-raku-bot joined 01:05 riffraff18 joined 01:10 riffraff18 left
tbrowder .tell lizmat i published yr day 4 article, mine is in draft for day 5. for some reason i cannot find the way to schedule the post, just publish manually. 01:18
tellable6 tbrowder, I'll pass your message to lizmat
01:19 discord-raku-bot left 01:20 discord-raku-bot joined
Summer > The iterator of this Seq is already in use/consumed by another Seq 01:39
Summer adds .cache to everything with a @
nothing changes aaaaa
[Coke] can you golf it? 01:42
Summer oh it was a list of seqs 01:46
[Coke] rant: why did we call it Seq and not Sequence?
It's not like we create them by hand a lot.
moon-child same reason it's grep and not global-regular-expression-print
?
;)
[Coke] no, *we* call it grep because perl did. 01:47
Summer i'll have you know I have my own specs fork just to fix that bug with grep
01:48 discord-raku-bot left
[Coke] I mean, I get it's shorter, but seems like we could have used the full name for clarity there. 01:48
Summer I kinda like it, ending on a q is cute 01:49
so you know how assigning a Seq to a @variable makes it into an Array? I wish that would continue into its children too 01:50
I know that would open a problimatic pile of discussions, la other types, custom types, etc, so better left untouched, but still, every year for AoC thats my number one stumbling blocks 01:51
- my @input = $*ARGFILES.lines.map: *.comb; 01:52
+ my @input = $*ARGFILES.lines.map: *.comb.Array;
01:56 discord-raku-bot joined 02:08 discord-raku-bot left, discord-raku-bot joined
SmokeMachine Would you people want to use my post for the advent calendar? I don’t think I’ll have time to make it better… (that’s ok if it’s not used… I just tried to help to have enough posts) 02:44
(gist.github.com/FCO/8ad2bd4cc3723e...1690ed9df) 02:45
03:04 swaggboi left 03:05 riffraff18 joined 03:10 riffraff18 left 04:10 nativecallable6 left, quotable6 left, greppable6 left, reportable6 left, notable6 left, linkable6 left, coverable6 left, bisectable6 left, unicodable6 left, bloatable6 left, statisfiable6 left, squashable6 left, committable6 left, sourceable6 left, evalable6 left, releasable6 left, shareable6 left, tellable6 left, benchable6 left, committable6 joined 04:11 releasable6 joined, bisectable6 joined, squashable6 joined 04:12 coverable6 joined, greppable6 joined, unicodable6 joined, nativecallable6 joined 04:13 statisfiable6 joined 04:30 riffraff18 joined 04:31 riffraff18 left, riffraff18 joined 05:11 notable6 joined, sourceable6 joined 05:12 reportable6 joined, shareable6 joined 05:13 bloatable6 joined
Geth doc/codesections-d-is-dec: b662d1aa96 | (Daniel Sockwell)++ (committed using GitHub Web editor) | doc/Language/regexes.pod6
\d is for decimal

As we correctly note [further down the page](docs.raku.org/language/regexes#Pre..._classes), `\d` matches _decimal digits_
  (Unicode `Nd`) not all numbers (Unicode `N`). This commit fixes the description here, adds an example of where that makes a difference, and provides
a way to match against Numbers if that's what the user meant.
05:32
doc: codesections++ created pull request #3991:
\d is for decimal
05:33
06:00 riffraff18 left 06:01 riffraff18 joined 06:02 reportable6 left 06:03 reportable6 joined 06:12 benchable6 joined 07:12 quotable6 joined, evalable6 joined 07:34 seednode left 07:35 seednode joined 08:11 tellable6 joined 08:35 swaggboi joined 08:49 Sgeo left 08:50 Sgeo joined 09:05 riffraff18 left, riffraff18 joined 09:10 riffraff18 left 09:13 linkable6 joined 09:19 Oshawott joined 09:23 archenoth left 09:36 riffraff18 joined 10:29 squashable6 left 10:31 squashable6 joined
Geth doc: 2ea6db7ed1 | rir++ (committed using GitHub Web editor) | doc/Language/objects.pod6
Fix error re: delegation and simplify some text. (#3990)

  * Fix error re: delegation and simplify some text.
  * Clarify quantity of delegated methods.
10:37
linkable6 Link: docs.raku.org/language/objects
10:38 linkable6 left 10:39 linkable6 joined
SmokeMachine Would you people want to use my post for the advent calendar? I don’t think I’ll have time to make it better… (that’s ok if it’s not used… I just tried to help to have enough posts) gist.github.com/FCO/8ad2bd4cc3723e...e1690ed9df 10:40
10:42 Sgeo left
timo do you still take suggestions? 10:48
Geth doc: aa2ccc2ff2 | Smylers++ (committed using GitHub Web editor) | doc/Language/5to6-perlfunc.pod6
Correct equivalent for split without a pattern (#3988)

  * Correct equivalent for split without a pattern
In Perl, split without a pattern is different from split "" — telling users of the former to switch to the latter changes from splitting by words to splitting by characters.
  * Update 5to6-perlfunc.pod6
  * Update 5to6-perlfunc.pod6
10:49
linkable6 Link: docs.raku.org/language/5to6-perlfunc
10:49 linkable6 left
timo for example, the specialized factory does .title x= 20; does that mean the default value for title gets used from the outer factory? 10:50
a little more text about how exactly traits work and when they are preferable to using attributes. like, can you still pass "archived" to the factory?
10:51 linkable6 joined
Geth doc: 7980f9556d | (Luis F. Uceta)++ (committed using GitHub Web editor) | 2 files
Add clarification about private methods (#3778)

  * Add clarification about private methods
  * Add small clarification
From github.com/rakudo/rakudo/issues/3801
10:57
10:58 linkable6 left 11:17 Skarsnik joined 11:26 Manifest0 left
Geth doc: f9cb0a2655 | (JJ Merelo)++ | doc/Language/exceptions.pod6
Mentioning the role of status in exceptions closes #3977
11:42
SmokeMachine timo: thanks! I’ll try to add that! 11:52
And yes, the outer default value is used 11:53
12:02 reportable6 left
SmokeMachine timo: could you see if it’s better now, please? gist.github.com/FCO/8ad2bd4cc3723e...e1690ed9df 12:03
tbrowder hi, i just saw some code like
*** a with / else block just like an if/ else block. 12:05
how are they different?
i've never looked at with 12:06
much
SmokeMachine tbrowder: `with xyz` is kind of equivalent to `if xyz.defined` 12:07
tbrowder ok, i see, thanks. i see it topicalizes, too. 12:09
SmokeMachine m: sub a($a) { say “if $a” if $a; say “with $a” with $a }; a “bla”; a “”; a Str; a 42; a 0; a Int
camelia if bla
with bla
with
if 42
with 42
with 0
tbrowder i've been pretty casually using if when maybe i should have been using with 12:10
12:11 tejr left
tbrowder m: my $a; say $a if $a 12:12
camelia ( no output )
tbrowder m: my $a; say $a with $a 12:13
camelia ( no output )
SmokeMachine m: my $a = 0; .say with $a
camelia 0
tbrowder m: my $a = 0; say $a if $a; say $a with $a 12:14
camelia 0
tbrowder what i've been doing is "if $a.defined" when i could have used "with $a" 12:15
i'm not sure in my mind if my way isn't clearer but it certainly takes more key strokess 12:17
BUT use of with shows the user is more than a novice at this beautiful language 12:18
lizmat tbrowder: note that there's also "without"
m: my $a; say "without value" without $a
camelia without value
tbrowder ah, my head hurts! 12:19
lizmat: sorry i felt i had to forcecpublished yr art last night. i tried to get you and jj had left the buildng. i didn't see it scheduled so i waited an xra hr just in case 12:21
it did have
lizmat tbrowder: thanks for doing that
I *had* scheduled it for 0100 am UTC I thought 12:22
tbrowder yr welcome
lizmat but apparently WP is then lying to me
tbrowder it may have been but i couldn't see that it was. i did push publish at almost exactly 0100 utc 12:23
as much money as wp makes you would think they could improve the user interface 12:24
how did you get yr comment hook added? 12:25
SmokeMachine lizmat, tbrowder: if there are no enough advent posts, please gist.github.com/FCO/8ad2bd4cc3723e...e1690ed9df
lizmat I have no idea
tbrowder hm, seems a neat thing but i haven't noticed it on the others. 12:26
SmokeMachine: be sure and let jmerelo know 12:27
lizmat SmokeMachine: so if I gather correctly what RedFactory is about, it's about generating objects of a given type with automatic (incremented) setting of attributues 12:29
feels like something that's not exactly related to Red per se?
SmokeMachine lizmat: no, it’s for generating db entries for tests, using Red 12:30
12:31 jjido joined
lizmat but that's just because you're creating Red objects... but what if they weren't ? 12:31
SmokeMachine It’s a way of doing “fixtures” but more clear… because you create each row on your own test code
lizmat but each row corresponds to an instance of the type determined by the table, no? 12:32
SmokeMachine If it was not using Red models, a big part of that would work… but not the .create itself (that uses Red’s .^create) but you could still use factory-new and factory-args… but I don’t see that being very useful… would that be useful? 12:34
yes, each row based on the used model 12:35
lizmat Well, in conjunction with Test::Mock, I guess a generic object factory could be useful 12:41
SmokeMachine It works like: you are testing if, for example, your controller helper returns the user’s full name. But the user table needs a lot of required data, so passing all that data on your test would make it unreadable. So you pre configure your user factory and on your test you can do: `is full-name-helper(factory-create “user”, :first-name<a>, :last-name<b>), “a b”, “returns the right full name”` 12:42
(Much more readable and understandable than using fixtures) 12:43
lizmat right, I understand that 12:44
but that could be useful outside of Red, for any application, whether they'd be using a database backend or not, don't you think? 12:45
SmokeMachine Yes, I think you have a point… 12:46
But there is also a differentiation on when you want to test something you added on your DB and something the is not (or is not anymore) on your DB… the difference between new and create, it is DB specific… 12:48
lizmat but, shouldn't all changes go through the API that Red provides? 12:50
would you really let other processes make changes to the DB when you're using an ORM ?
SmokeMachine No, everything to DB goes through Red… 12:51
RedFactory uses Red for it, using the model’s meta methods 12:52
lizmat so how could the db change then without the objects knowing about it ? 12:56
SmokeMachine lizmat: probably this is the only line where it really needs Red: github.com/FCO/RedFactory/blob/mai...kumod#L137
lizmat: it can’t. My point is that RedFactory needs to know Red’s API to ask it to create new rows 12:57
(And to create a in-memory SQLite for your test…) 12:58
(Creating all needed tables on it)
(All that using Red)
I think I’m probably missing your point, sorry… I’m trying to reread that 13:00
lizmat but isn't "using the Red API" the same as "creating an object" ? 13:03
13:04 reportable6 joined
SmokeMachine 12:29 <lizmat> feels like something that's not exactly related to Red per se? -> I partially agree, the creating obj feature (the method new and the method args-to) are not related to Red, but the DB interaction features (.create and .run) uses Red API 13:04
13:03 <lizmat> but isn't "using the Red API" the same as "creating an object" ? -> almost, but not quite. You can create a row using .new.^save but you can also use directly .^create that has some facilitators ( like creating the row and its relationship rows for you inside a transaction) 13:07
13:08 Ergo444 joined
Ergo444 hello 13:08
how would you convert Buf[uint8] into a hexadecimal string?
SmokeMachine Red’s models are just usual objects, but its metaclass has the methods to interact with the DB. So if I want RedFactory to do everything to me, it needs to know Red’s “meta API” 13:09
Or I would need to instead of doing: `factory-create “user”` I would have to do: `factory-new(“user”).^save` 13:10
And it wouldn’t work for, for example, when the factory also creates its relationships 13:11
lizmat aahh,.. ok, thanks for clearing up that misconception in my minde 13:12
*mond
*mind 13:13
hehe
SmokeMachine "using the Red API" is the same as "creating an object" until you want to interact with the database
Geth doc/codesections-d-is-dec: 9ebcd5dc9d | (Daniel Sockwell)++ (committed using GitHub Web editor) | doc/Language/regexes.pod6
Minor fixes from reviews
13:14
SmokeMachine lizmat: But yes, I think I can remove Red’s dependency where it’s not needed and make it more generic 13:15
13:19 [Coke] left
Ergo444 how can I convert a buffer into hexadecimal strings 13:26
lizmat m: say Buf.new(1,2,3).raku 13:27
camelia Buf.new(1,2,3)
lizmat hmmm
m: say Buf.new(1,2,3)
camelia Buf:0x<01 02 03>
lizmat Ergo444: something like that ^^ ?
m: say Buf.new(1,2,3).substr(7).chop 13:28
camelia No such method 'substr' for invocant of type 'Buf'
in block <unit> at <tmp> line 1
Ergo444 Ad00BfA0
lizmat m: say Buf.new(1,2,3).gist.substr(7).chop
camelia 01 02 03
Ergo444 maybe using map and.. number system stuff
there was unpack in Perl5 13:29
lizmat m: dd Buf.new(1,2,3).map(*.fmt("%02x")).join
camelia "010203"
Ergo444 m: pack("C*", [1, 2, 3]); 13:30
camelia 5===SORRY!5=== Error while compiling <tmp>
Use of pack is experimental; please 'use experimental :pack'
at <tmp>:1
------> 3pack("C*", [1, 2, 3]);7⏏5<EOL>
Ergo444 m: Buf.new(111,2,3).map(*.fmt("%02x")).join 13:31
camelia ( no output )
Ergo444 m: Buf.new(1,2,3).map(*.fmt("%02x")).join
camelia ( no output )
Ergo444 m: say Buf.new(1,2,3).map(*.fmt("%02x")).join
camelia 010203
Ergo444 m: say Buf.new(111,2,3).map(*.fmt("%02x")).join
camelia 6f0203 13:32
Ergo444 that is good enough
lizmat hmmm.. I wonder why we don't have .fmt on Buf 13:34
13:35 Manifest0 joined
Skarsnik probably because Buf does not have an encoding? 14:12
lizmat I guess that's a good point, but I guess for all intents and purposes we could assume ASCII :-) 14:16
Ergo444 Default constructor for 'FileSender' only takes named arguments 14:20
Skarsnik maybe there could be like a .raw method/adverse that say "don't encode' ?
Ergo444 How do I make a class accept positional arguments for the constructor?
Skarsnik constructor are weird x)
s/adverse/abverb/ 14:21
Ergo444 for submethod TWEAK
what is the idea behind TWEAK? 14:22
moritz_ run code at the end of the object creation cycle 14:25
Skarsnik BUILD is before? 14:26
lizmat if you want .new to take positionals, you need to create your own .new 14:31
m: class Foo { has $.bar; method new($bar) { self.bless(:$bar) } }; dd Foo.new(42); 14:32
camelia Foo.new(bar => 42)
lizmat m: class Foo { has $.bar; multi method new($bar) { self.bless(:$bar) } }; dd Foo.new(bar => 42);
camelia Foo.new(bar => 42)
lizmat m: class Foo { has $.bar; multi method new($bar) { self.bless(:$bar) } }; dd Foo.new(bar => 42); dd Foo.new(666); # if you want to allow both forms 14:33
camelia Foo.new(bar => 42)
Foo.new(bar => 666)
14:35 evalable6 left, evalable6 joined
Skarsnik I think that self.bless is not really great if you don't know how Perl 5 class were made. I think like a trait on constructor method would have be more clear. 14:40
14:40 Xliff left
lizmat Skarsnik: class Foo { has $.foo is Positional } ?? 14:42
Skarsnik class Foo { method mynew($bar) is constructor {} 14:43
lizmat but you can make any method a constructor 14:46
Skarsnik I guess you can't control if you want to create the object or not this way 14:47
lizmat m: class Foo { has $.bar; method init($bar) { self.new(:$bar) } }; dd Foo.init(42)
camelia Foo.new(bar => 42)
lizmat afk for a bit& 14:48
14:59 linkable6 joined
Skarsnik blogs.perl.org/users/sylvain_coline...day-2.html if someone has an awnser for my last issue from this x) 14:59
SmokeMachine lizmat: usercontent.irccloud-cdn.com/file/.../image.png 15:06
15:09 MoC joined
Ergo444 is it possible to asm code in Raku? 15:12
to write.
15:13 dextercd joined 15:14 jjido left
Skarsnik I don't think you can directly, since Raku can run on top of the JVM or Javascript 15:15
15:34 monkey_ joined 15:38 simcop2387 left, perlbot left
Skarsnik hm, how do you split an Int to bytes? 15:47
lizmat something with docs.raku.org/routine/read-uint8 perhaps ? 16:14
Skarsnik ^
Skarsnik this is on a Blob x) 16:16
I want like to write 0x4578.something and that give me like (0x45 0x78) 16:17
lizmat well, if you want strings, then: 16:36
m: .say for "0x4578".comb(2).skip
camelia 45
78
lizmat m: say "0x$_" for "0x4578".comb(2).skip
camelia 0x45
0x78
16:38 evalable6 left, linkable6 left
Skarsnik m:0x587.Str.comb(2) 16:39
16:39 evalable6 joined
Skarsnik m:say 0x587.Str.comb(2) 16:39
evalable6 (14 15)
lizmat converting it to a string, will lose its hexiness :-) 16:47
Skarsnik I just want each individual bytes of the Int, the 0x notation is more to see these bytes x) 16:49
16:50 perlbot joined
Skarsnik m: say 0x484.base16.reverse.comb(2) 16:52
camelia No such method 'base16' for invocant of type 'Int'. Did you mean
'base'?
in block <unit> at <tmp> line 1
Skarsnik m: say 0x484.base(16).reverse.comb(2)
camelia (48 4)
16:54 simcop2387 joined
Skarsnik Also found an interesting thing, don't name the argment / in a method an class use has action if you want to do some ~~. like class MyAction {method mytoken($/) {if $/<something> ~~ /foo/}}} The error message is... interesting 16:55
lizmat m: sub bytes(Int:D $a) { (0,8...Inf).map({ (($a +> $_) +& 0xff).fmt("0x%02x") }) }; .say for bytes(12345).head(3)
camelia 0x39
0x30
0x00
Skarsnik xD 16:56
less fancy 17:03
m:sub bytes(Int:D $int) {my $i = $int;my @toret; while $i != 0 {@toret.push($i +& 0xFF);$i = $i +> 8;}; @toret}; say $_.base(16) for bytes(0x4855);
evalable6 55
48
17:03 [Coke] joined
tbrowder .tell tonyo my fez user name was entered as tbrowder. new App::Mi6 expects it to be "zef:tbrowder". can i change it in the .fez-config.json file or do i have to start over with a new fez account, or should mi6 deal with it? 17:25
tellable6 tbrowder, I'll pass your message to tonyo
17:34 hobbs joined 17:37 jjido joined
hobbs is there a nice way to map over all of the elements of a shaped array and get out an array of the same shape? e.g. Array.new(:shape(2,2), [[1,2],[3,4]]).bettermap: *² should give a shaped array containg [[1,4],[9,16]] 17:39
ugexe maybe .tree ?
17:40 monkey_ left 17:41 linkable6 joined
hobbs alternatively/additionally, is there a nice way to take a flat list of n*m*k items and shlurp it up into a shape(n,m,k) array? :) 17:41
17:44 monkey_ joined
Geth doc: rakool++ created pull request #3993:
Simple deletion of "of course" phrases.
17:58
18:02 reportable6 left 18:04 hobbs left 18:09 simcop2387 left, perlbot left
tbrowder lizmat: can you please ck yr .fez-config.json file and see if it has a "zef:" or "fez:" prefix? 18:14
or can any other fez user check the same thing, please?
18:27 monkey_ left 18:35 monkey_ joined 18:41 riffraff18 left, riffraff18 joined 18:46 jjido left, perlbot joined 18:49 riffraff18 left, riffraff18 joined 18:53 perlbot left 19:03 perlbot joined 19:05 jjido joined, patrickb joined 19:09 simcop2387 joined 19:31 monkey_ left 20:04 reportable6 joined 20:20 riffraff18 left, riffraff18 joined
Geth doc: c712268b89 | (Daniel Green)++ | doc/Language/hashmap.pod6
Index "hash slice"
20:23
linkable6 Link: docs.raku.org/language/hashmap
20:26 riffraff18 left 20:27 Sgeo joined 20:40 Guest12 joined
Guest12 I just got "This server could not prove that it is commaide.com; its security certificate expired in the last day. This may be caused by a misconfiguration or an attacker intercepting your connection." 20:41
20:42 monkey_ joined 20:43 [Coke]_ joined 20:44 ptc left 20:45 ptc joined, [Coke] left
Guest12 My guess is that the message is due to an attacker on my system, but confirmation by anyone here that commaidea.com works would be appreciated. 20:45
commaide.com
20:46 riffraff18 joined, Ergo444 left
MasterDuke their cert expired today. i mentioned it to some of the devs a couple minutes ago, but it's kind of late in the evening on a weekend, so they might not be able to fix right away 20:46
but i can confirm i went ahead and downloaded the new comma ok 20:47
20:57 monkey_ left
Guest12 MasterDuke: Thanks! 21:10
MasterDuke np 21:11
21:14 monkey_ joined
pie_flavor Why is it that `((5,5,5),(2,3,4)).grep(5 xx 3)` errors with "The iterator of this Seq is already in use/consumed by another Seq"? 21:26
MasterDuke m: say ((5,5,5),(2,3,4)).grep((5 xx 3).cache) 21:28
camelia ((5 5 5))
pie_flavor no, I know I can cache it, but why's it do that 21:30
I thought reading out a lazy list just made it into a non-lazy list
MasterDuke 5 xx 3 isn't a lazy list, it's a Seq. and those can only be iterated once. grep is iterating it to match it 21:32
21:35 tejr joined 21:40 jjido left 21:42 riffraff18 left
japhb Skarsnik: If you want to be writing large integers and reading bytes, generally a buf8 + the write-int64/read-uint8 methods are what you want. Don't forget to specify BigEndian or LittleEndian (if you're not just using NativeEndian). 22:07
(With a buf8, you can also read the bytes directly by indexing it as a positional as well -- but at least the write needs the method) 22:08
22:27 Guest12 left 22:36 MoC left, [Coke]_ is now known as [Coke]
lizmat tbrowder: my fez config consists of JSON with an "un" and a "key" key 22:38
tbrowder okay, but no "zef:" in front of yr un, right? 22:42
lizmat nope
tbrowder i 22:43
cool, that turned out to be my bad because i had failed to remove the :auth in the module, and it is not ignored, if it exists, it must match. 22:44
but then, when i was well on the way to a good release, there was a problem with fez reporting it couldn't find the meta in the *.tar.gz file. 22:46
so i've made a script log of the whole affair and filed the same issue with fez and mi6. if it's my error again, i guess i owe some beers at the next live raku gatthering. 22:48
pie_flavor if I have a list of lists of lists, why does `».say` give me the inner elements instead of the lists of lists? 22:49
and what's the shortest way to flatten the middle list so it's only a list of lists?
tbrowder at any rate, i'm collecting good notes for an advent blurb
lizmat cool! :-) 22:50
22:55 djerius_ left 22:56 djerius joined 23:01 djerius left 23:02 djerius joined 23:22 dextercd left 23:30 xenu left
[Coke] I have a class with a few array attributes; is there an easy way to get a clone of an object that clones the arrays or do I have to write a clone method ? 23:36
tbrowder .tell tonyo i need help with my fez issue #49. mi6 barfs on the "fez upload --file=Foo.tar.gz" part, and i don't understand yr readme on the tar issue. 23:37
tellable6 tbrowder, I'll pass your message to tonyo
Skarsnik hm, @ attributes are not cloned?
23:38 monkey_ left
[Coke] m: class A { has @.stuf}; my $a = A.new(:stuf<1 2 3 4>); my $b = $a.clone; $a.stuf=<4 5 6>; dd $b 23:39
camelia A $b = A.new(stuf => [IntStr.new(4, "4"), IntStr.new(5, "5"), IntStr.new(6, "6")])
[Coke] eh. replaced the .clone with an explicit .new 23:43
... which I don't think worked either. afk 23:44
23:45 monkey_ joined