🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
Geth advent: 7f464f0f98 | Altai-man++ | 20th/articles/rfc188.md
Add RFC 188 article
00:06
advent: 5d36d37078 | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | 20th/articles/rfc188.md
Merge pull request #61 from Raku/rfc-188

Add RFC 188 article
melezhik .tell rba: ssh brezeleisen issue resolved 02:56
tellable6 melezhik, I'll pass your message to rba
mirrorbird i thought i would finally try perl/raku after my hello world program 13-14 years ago. does anyone know a good article which compares Perl and Raku and talks about them in some way? 02:59
guifa2 mirrorbird: there's a guide for people coming from Perl 03:10
guifa2 docs.raku.org/language.html#Migration_guides 03:11
mirrorbird ok. i have no experience with perl but i guess that should do it 03:14
guifa2 Hm, I don't know if there's any great discussions on the two from the perspective of someone who hasn't used Perl. Most Raku users were previously Perlers, so the resources have —for better or for worse— been biased in that way 03:16
mirrorbird that makes sense 03:17
but some new people must be learning these languages. i guess not as much these days
guifa2 mirrorbird: there definitely are. There are a lot of people that have been working on building up documentation and just last week there was some talk about how more resources should be made oriented towards non-Perl folk 03:21
(the ones who brought it up were similarly not previous Perl users, hence their interest)
rockxloose I understand Facebook was built on php. Has anything been built with Raku at such a scale? 04:13
rockxloose I understand one strength Perl has is govt document processing. Could Raku take over that role and link to modern uses of tech such as Zoom chats for problems like not waiting 2-months or 6-years for things to happen www.maritime-executive.com/article...explosives 04:29
?
guifa2 rockxloose: parsing is a strength of Raku. People have begun to write programs of larger scale. jnthn in fact does basically exactly that at $day-job, processing some insanely large amount of documents that have to be compiled to instructions and something 06:49
guifa2 I'm trying to find that talk but I forgot which one it wasand he has soo many lol 06:57
justsomeguy This is probably a silly question, but is Raku fast (in terms of runtime performance)? 08:10
JJMerelo Like a PRAYER, TWEAK was introduced in the set of Raku phasers. Learn all about it in today's entry in the 20th anniversary calendar, which was on me raku-advent.blog/2020/08/15/rfc-30...on-cozens/ 08:59
tellable6 2020-08-14T20:43:54Z #raku <[Coke]> jjmerelo I can be ready in about an hour from now.
2020-08-14T20:44:08Z #raku <[Coke]> jjmerelo sorry about the delay!
2020-08-14T21:48:24Z #raku <tbrowder> jjmerelo pls disregard avl-tree prob
2020-08-14T22:18:28Z #raku <[Coke]> jjmerelo committed rfc28, created a placeholder in wordpress... unable to figure out how to paste in markdown.
2020-08-14T22:22:09Z #raku <[Coke]> jjmerelo - ok, figured out how, but when I run the tool, I get 'abort trap 6', presumably related my old "one of cro's deps doesn't work on the mac" problem. I leave it to you to post the article.
JJMerelo .tell [Coke] Ok, many thanks.
tellable6 JJMerelo, I'll pass your message to [Coke]
JJMerelo .tell Altai_man do you want me to upload the article for you too? 09:00
tellable6 JJMerelo, I'll pass your message to Altai-man
JJMerelo .tell [Coke] I'll also try to schedule yours for the last day, as you originally intended. 09:02
tellable6 JJMerelo, I'll pass your message to [Coke]
Altai-man JJMerelo, I have $dayjob now, so that would be nice. I hope code examples would be colored, github gist method works for you? 09:03
JJMerelo Altai-man you probably mean the original script that Tom or zoffix created. 09:04
Altai-man Yes.
I mean, whatever works, IIRC it just uploads a gist, downloads page and extracts certain html block, it can be done even manually.
JJMerelo Altai-man to tell you the truth, I'm not sure it works... I'll give it a try. Generally, if they are short snippets, I let WP handle it; if they are longer, I create a gist manually 09:05
JJMerelo I'm going to schedule it for tomorrow, then. And thanks :-) 09:05
Altai-man modules.raku.org/dist/RakuAdvent::...n:TBROWDER looks relevant 09:08
JJMerelo Hum, uses HTML for input. Thanks anyway, I can always check it out. 09:09
Altai-man Oh, right. :S 09:11
Then Acme::Advent::Highlighter.
Or wait for me this evening.
JJMerelo No problem, I'll do it 09:15
Geth advent: 333e62542d | (Elizabeth Mattijsen)++ (committed using GitHub Web editor) | 20th/articles/rfc159.md
Create rfc159.md
11:16
lizmat Comments welcome ^^ 11:17
.tell JJMerelo please schedule it at your convenience
tellable6 lizmat, I'll pass your message to JJMerelo
lizmat .tell JJMerelo please schedule rfc159.md at your convenience 11:18
JJMerelo lizmat got it. Thanks a lot, Liz, I appreciate. In principle, it will go right behind Altai_man's, next Monday.
tellable6 lizmat, I'll pass your message to JJMerelo
lizmat oki
JJMerelo With [Coke]'s already in, that leaves only two to go. So almost there :-) 11:19
lizmat JJMerelo I do plan to do the RFC200 one as well, is that already included in your calculations? 11:33
JJMerelo No, it's not. Then it's only one to go! 11:34
I can do it if no one else stands up
sena_kun will finish another draft if someone could tell ow export of operators from packages works 11:35
s/ow/how/
lizmat operators are subs 11:36
sub infix:<foo> is export { }
sena_kun lizmat, can I export multi infix:<+> this way? I tried and it said multi need to export proto, so I created proto with is export and then some error I don't clearly remember now. 11:37
lizmat ah, you want to *add* a candidate? 11:38
sena_kun Yes.
lizmat the way I've done that is: 11:39
lizmat looks at an example in one of her modules 11:40
sena_kun My current code is gist.github.com/Altai-man/f01dcc42...ea7f423aa0 I am not sure how what I do should be implemented, to be honest, so the draft I almost finished became useless for this reason. No sense to write about something if you're not 100% good with it. 11:41
lizmat modules.raku.org/dist/Array::Circu...lar.pm6#L3 11:42
and modules.raku.org/dist/Array::Circu...ar.pm6#L34
and modules.raku.org/dist/Array::Circu...ar.pm6#L50
sena_kun Hmm, this is a bit advanced. :S
(not for me, but likely for the reader) 11:43
lizmat I hope the newdisp would allow for an easier way to do this
or maybe jnthn or someone else can point me to a better way of doing that now :-)
perhaps some MOP magic would be possible nowadays 11:44
sena_kun I can share the draft if anyone is interested in tech reviewing it and maybe suggesting another direction where the overall narration should go. 11:46
JJMerelo sena_kun please do that
Nothing is too advanced if there are links to relevant documents, or examples introduce the stuff gradually. 11:47
sena_kun Not really "advanced", the problem is that I drove the post narration to the point where it is broken, so either the premise itself is not good or I wrote some stupid nonsense somewhere along the line and it went downhill. 11:48
Wait, what
lizmat $dispatcher.add_dispatchee($code); seems a lead 11:49
sena_kun Disregard all I wrote.
lizmat ?
sena_kun The article draft I struggled with is about, ahem, RFC 159. :)
lizmat aaahhh? 11:52
JJMerelo I don't think it's a problem that a RFC is repeated. 11:53
sena_kun I guess that's what I got for not using schedule properly.
JJMerelo Unless you think so, of course.
sena_kun Another solution is to take another RFC and write a post, that's it. 11:54
lizmat sena_kun: I didn't know
:-(
sena_kun lizmat, no, it's not your fault, in fact, it is awesome you did it.
Because I clearly lack expertise for it anyway. 11:55
lizmat I originally didn't plan on doing 159, but started writing 200 and saw it needed an intro into 159
and then that grew into a full blog post
sena_kun Yeah, that's great, as now things will be more natural. 11:56
Geth advent: c5c7f3ccba | (Elizabeth Mattijsen)++ (committed using GitHub Web editor) | 20th/articles/rfc159.md
Tweaks suggested by woolfy++
11:57
JJMerelo sena_kun do whatever you think is best. My take is that it's no big deal to have two different takes on the same RFC. You can even link that post if it's already been published. 11:58
lizmat sena_kun: agree 12:00
sena_kun: what error did you get when exporting a multi sub infix? 12:02
I'm not seeing it?
sena_kun lizmat, without proto?
lizmat yeah
sena_kun Weird.
Removing proto now I am not seeing it, but the idea behind this code is very broken, so don't waste your time on it. 12:03
lizmat ok, what I needed was to export a trait_mod: which has its own sets of gnarly bits :-)
sena_kun Yeah, this is a bit more interesting task. :) 12:04
Guest27754 Hey, are there any resources on how to get started with raku available? Seems like an interesting language and I would like to get started. Thanks in advance for any help. 13:08
Guest27754 I have already experience with C/C++ and Python 13:10
lizmat Seems like Guest27754 had a short attention span 13:17
raku.guide would be a good starting point
rindolf lizmat: thanks! :) 13:25
guifa2 o/ 14:49
lizmat guifa2 \o 14:53
guifa2 just found out he's going to be even more productive this year than he thought for Raku stuff
lizmat ++guifa2
guifa2 good/bad reasons lol. They canelled spring break, and pushed back the start of next academic semester, so two month christmas break (yay time to code). but no spring break when I might actually be able to travel 14:54
melezhik how can I coerce Array into List? 16:20
lizmat .List ? 16:22
m: my @a = ^10; my @b := @a.List; @b[0] = 42
camelia Cannot modify an immutable List ((0 1 2 3 4 5 6 7 8 9))
in block <unit> at <tmp> line 1
melezhik thanks 16:24
melezhik I stumble with some "weird" Raku behavior when handling Arrays of Arrays/Hashes 17:09
let me give some examples
m: my $a = [[1,2]]; for $a<> -> $i { say $i}
camelia 1
2
melezhik m: my $a = [[1,2]]; for $a<> -> $i { say $i, " / " }
camelia 1 /
2 /
melezhik m: my $a = [[1,2], %( foo => 1, bar => 2 )]; for $a<> -> $i { say $i, " / " }
camelia [1 2] /
{bar => 2, foo => 1} /
MasterDuke m: my $a = [[1,2],]; for $a<> -> $i { say $i, " / " } 17:10
camelia [1 2] /
melezhik why in the second case `$a<>` split array by bigger chunks?
I've not changed iterator logic, I only pushed to `$a` and Hash
and -> a
this is quite confusing the `<>` logic changes when you push data to array ): 17:11
looks like if I only have a ONE element in array `$a = [ [1,2]] ` it differs from the case when an array has more then ONE element `$a = [[1,2], %( foo => 1, bar => 2)]` 17:15
melezhik looks decontarization happens in the first case 17:21
m: my $a = [[1,2]]; for $a<> -> $i { say $i.^name } 17:23
camelia Int
Int
melezhik m: my $a = [[1,2], [1,2]]; for $a<> -> $i { say $i.^name }
camelia Array
Array
melezhik I expect the first run should produce Array 17:24
so that `<>` will consistently apply the same logic when dealing with arrays, irrespective of array size 17:26
tbrowder hi 17:27
question: i have a recursive sub that writes to stdout.how can i internall 17:28
tbrowder internally capture it all as a string for reformatting or do i need a mutil? 17:30
the sub is acting over a tree structure and writing all nodes' key as it moves to each node. 17:32
[Coke] Ideally, you would have those subs output to the string themselves rather than try to capture stdout. You can temporarily replace stdout with something that does the capture however, and replace it when you're done. 17:35
tellable6 2020-08-15T08:59:50Z #raku <JJMerelo> [Coke] Ok, many thanks.
2020-08-15T09:02:43Z #raku <JJMerelo> [Coke] I'll also try to schedule yours for the last day, as you originally intended.
[Coke] one sec. 17:36
tbrowder i've tried this: my $s = (show-keys($n));
[Coke] m: my $output; { temp $*OUT = class { method print(*@args) { $output ~= @args.join } }; say 3; say 4; say 5 }; say "..$output.." 17:38
camelia ..3
4
5
..
tbrowder i could use a multi and write to a buf or tmp file but i know there's an expert here that use the power of raku to avoid that.
[Coke] tbrowder: ^^
you could go further and make the output an attribute of the class so there's no leaky globalish variables, but I was too lazy 17:39
tbrowder looks pretty spiffy to me. thnx!
[Coke] you could also pull out the class definition instead of inlining it
tbrowder: stole it from myself from the rosettacode examples in roast 17:40
CIAvash melezhik: When you write `my $a = [[1,2]]`, `$a` becomes `[1,2]`. You need to add a comma like MasterDuke showed you.
tbrowder aha, good source%
! 17:41
melezhik I see that, CIAvash it's valid workaround, but this is still _workaround_ :-)) 17:42
[Coke] tbrowder: there's also a nice module in the ecosystem that does more.
CIAvash melezhik: that's how things work, this is not a workaround 17:43
tbrowder since this is a rosetta code thing i will try not to use externals if possible. 17:44
CIAvash melezhik: It's the single argument rule 17:45
timotimo the circumfix:<[ ]> operator will iterate what you give to it, so [1, 2] iterates through 1, 2, and [[1, 2]] will iterate over 1, 2 in the first step to create [1, 2], then it will iterate over [1, 2] in the second step, to create [1, 2] again 17:49
this mechanism also makes [[[[1, 2]]]] give [1, 2]
putting a , in there gives you an actual outer list that will be iterated over instead of the array 17:50
so [[1, 2],] will first iterate over 1, 2 in the middle to give [1, 2] and then it will iterate over ([1, 2],) to give [1, 2] as first element, and no second element, so it gives you [[1, 2],]
this also lets you do stuff like [<foo bar baz>] to give an array instead of a list, since it turns the inner list into an array for you 17:51
melezhik sorry timotimo why I need to put a comma to the end of the array to change iteration logic? 17:59
timotimo you don't change iteration logic 18:00
you just change what the target of iteration is
in one case the array is iterated, in the other it's a list with one entry which is the array
so in the first case you get the contents of the array as the result, but in the second case the array itself is the result, because it's the only entry in the list that's being iterated 18:01
melezhik m: my $a = [[1,2]]; for $a<> -> $i { say $i.^name } 18:02
camelia Int
Int
melezhik m: my @a = [[1,2]]; for @a<> -> $i { say $i.^name } 18:03
camelia Int
Int
melezhik timotimo - "so in the first case you get the contents of the array as the result," - not only that? I mean there is also decontarization happens here, does not it?
why? 18:04
timotimo i need to look at the original code again, hold on 18:06
which of the lines was the "second case"? 18:08
you were comparing [[1, 2]] vs [[1, 2], %( foo=> 1, bar => 2 )] right?
melezhik m: my @a = [[1,2]]; for @a<> -> $i { say $i.^name } 18:09
camelia Int
Int
melezhik this is the first one
timotimo OK
melezhik I would expect here "Array" output not "Int Int"
I mean decontarezation/flattering happening here under the hood 18:10
timotimo m: my @a = [[1, 2]]; dd @a
camelia Array @a = [1, 2]
melezhik and it does not happen with a List
timotimo m: my @a = [[1, 2]]; dd @a; say @a.elems
camelia Array @a = [1, 2]
2
timotimo m: my @a = [1, 2]; dd @a; say @a.elems 18:11
camelia Array @a = [1, 2]
2
timotimo m: my @a = 1, 2; dd @a; say @a.elems
camelia Array @a = [1, 2]
2
timotimo these are all the same
melezhik my assumption (I might be wrong here) that `@a = [[1,2]]` is Array with 1 element, where this element is also is an Array with 2 elements (Strings)
timotimo yes, that is wrong :)
melezhik why? 18:12
timotimo assigning to an array is a "list assignment" and causes iteration to happen
melezhik probably perl5 influence .... but still why?
timotimo and [[1, 2]] is already the same as [1, 2]
CIAvash "The only one of these that is likely to provide a surprise is [[1]], but it is deemed sufficiently rare that it does not warrant an exception to the very general single argument rule." from design.raku.org/S07.html#The_singl...ument_rule 18:18
timotimo sorry i'm AFK half the time 18:20
melezhik timotimo thanks, I need to digest that, but thank you 18:28
tbrowder m: a 21:27
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
a used at line 1
tbrowder m: 'a' cmp 2 21:28
camelia WARNINGS for <tmp>:
Useless use of "cmp" in expression "'a' cmp 2" in sink context (line 1)
tbrowder m: say 'a' cmp 2
camelia More
tbrowder i would for the output to say "LeftMore" (and 'LeftLess' and 'Same') 21:30
*would love it better if the ouput said... 21:32
lizmat recalls discussions about the naming of what became the Order enum
this is what was decided on then 21:33
tbrowder: do you want it to say something different in *your* code only?
tbrowder well, that's a step forward. 21:34
lizmat multi method gist(::?CLASS:D:) { $!key }
so changing that would either involve overriding the .gist method, or changing the `$!key` attribute 21:35
tbrowder i've been struggling with implicit numstr equality comparisons and cmp is the only thing reliable
i've found so far, just a bit awkward to use 21:36
lizmat why?
you can use the Order numerically as -1 0 or 1
m: say +Less 21:37
camelia -1
lizmat m: say +Same
camelia 0
lizmat m: say +More
camelia 1
lizmat if you really want to mess with things:
m: use nqp; nqp::bindattr(Order::Less,Order,q/$!key/,"LeftLess"); say Less
camelia LeftLess
tbrowder because i've assigned the cmp result to a var and use it in a three-way expression later and am not used to using it yet :-) 21:38
no, i'm just whining... 21:39
thanks for letting me vent. cmp is cool. 21:40
but lt and gt are supposed to coerce nums to str for comparison and that wasn't reliable. 21:42
cmp was the answer 21:43
lizmat :-) 21:54
melezhik .tell timotimo I've broken down the Arrays VS Lists principal in Sparrow6 args stringification mechanism - github.com/melezhik/Sparrow6/blob/...-vs-arrays 21:55
tellable6 melezhik, I'll pass your message to timotimo
melezhik hopefully now I am on the same page 21:56
))
tbrowder lizmat: actualy, couldn't i create my own infix opers using cmp behind the curtain? that might be the best for my current situation. 22:07
<=, <, etc.
lizmat that is definitely always an option
timotimo .tell melezhik i'm not sure where the <> operator enters into this, and the `will "convert" args into a List` part seems a little misguided 22:27
tellable6 timotimo, I'll pass your message to melezhik
stanrifkin What GUI lib should i use? 23:19
melezhik .tell timotimo `<>` works here - github.com/melezhik/Sparrow6/blob/...r.pm6#L126 23:22
tellable6 melezhik, I'll pass your message to timotimo
melezhik on "the `will "convert" args into a List` part seems a little misguided"
tellable6 2020-08-15T22:27:39Z #raku <timotimo> melezhik i'm not sure where the <> operator enters into this, and the `will "convert" args into a List` part seems a little misguided
melezhik m: say [ [1,2] ].^name 23:23
camelia Array
melezhik m: say [ [1,2], ].^name
camelia Array
melezhik upps, I expected it to be List
weird
m: for [ [1,2] ]<> -> $i {say $i} 23:24
camelia 1
2
melezhik m: for [ [1,2], ]<> -> $i {say $i}
camelia [1 2]
melezhik timotimo I am still confused in terminology ...
why `[[1]]` and `[[1],]` acts differently with `<>` ? 23:25
I was under impression that just `[[1]]` is an Array and `[[1],]` is List, but I can see now it's not the case 23:26
so if underlying structures are of the same type (Array), why do they act different with `<>` ? 23:27
rypervenche Good ol' zen slices.
melezhik I mean I know now that adding comma to the end of my array will do the trick for me, I am just not sure if I could explain it myself, why, in terms of Raku types ... or whatsover ... 23:30
melezhik also on "putting a , in there gives you an actual outer list that will be iterated over instead of the array" - I am not sure if understand that honestly ... if there is an rakudo doc that describe a `<>` behavior for various cases? 23:35