🦋 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.
[Coke] this used to work: a 'proto sub MAIN() { ...; {*} }; in a module and a sub MAIN() { ... } in a script. (from some adventofcode helper scripts I had last year that now don't work) 03:10
[Coke] m: proto MAIN(|) { say "proto"; {*} }; multi MAIN() { say "hi"; } 03:14
camelia proto
hi
[Coke] seems happy enough in a single script 03:15
any thoughts appreciated
tonyo what -v 03:23
[Coke] 2022.07 03:30
ugexe hmm, i always thought only the first MAINline gets run 03:33
but that might be if you have two MAINs in different modules only one of them gets used 03:34
[Coke] ... there has beem a very annoying change on my osx 12.6 box; if I highlight text, ther is no highlight color until I stop the selection. then it highlights. any way to get this back to highlight-as-you-go greatly appreciated.
grondilu check this out, basically RIPEMD-160 as a FP one-liner : github.com/grondilu/libdigest-raku...MD.rakumod 04:05
it's also the fastest version I wrote to date 04:06
grondilu "one-liner" being a figure of speech here ;) 04:07
still, no variable here. Like, there is no C<my>. 04:09
grondilu considers creating a 'constrained programming' contest and grant himself the first prize 😄 04:13
[Coke] ... rebooting fixed my #$%^&* trackpad issues. 04:21
MasterDuke that's certainly something...i like it, but am not sure that i like that i like it 04:38
grondilu m: class { has $.x; multi method new { samewith rand }; multi method new(Num $x) { samewith 06:42
camelia ===SORRY!=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> d }; multi method new(Num $x) { samewith⏏<EOL>
expecting any of:
statement end
statement modifier
statement modifier loo…
grondilu m: class { has $.x; multi method new { samewith rand }; multi method new(Num $x) { samewith :$x } }.new
^I'm not quite sure why this hangs
camelia (timeout) 06:43
grondilu I think I've used that kind of scheme before, a constructor with no parameters to set a random attribute.
For some reason I can't make it work anymore. 06:44
unless I use bless or something but really I shouldn't have to, should I?
m: say class { has $.x; multi method new { samewith rand }; multi method new(Num $x) { self.bless: :$x } }.new.x 06:45
camelia 0.1505676333858187
Nemokosch Guys, what do you think 1 ~~ @foo should return on a lazy list? 09:26
lizmat although I'm not one of the guys, I'd say: no 10:09
Nemokosch You mean _False_? 10:11
github.com/rakudo/rakudo/issues/2468 for context
lizmat the "no" was on the question whether it should return a lazy list 10:12
Nemokosch Sorry but that wasn't the question. "*what* do you think (...) should return *on* a lazy list" 10:15
mscha m: my %h; say 'yes' if %h<a>:exists && %h<b>:exists; 10:53
camelia ===SORRY!=== Error while compiling <tmp>
You can't adverb &infix:<&&>
at <tmp>:1
------> ay 'yes' if %h<a>:exists && %h<b>:exists⏏;
expecting any of:
pair value
mscha m: my %h; say 'yes' if %h<a>:exists and %h<b>:exists; 10:54
camelia ( no output )
mscha m: my %h; say 'yes' if (%h<a>:exists) && (%h<b>:exists);
camelia ( no output )
mscha Does && really bind tighter than :exists??
Nemokosch this seems to be characteristic of adverbs... I still don't know where they go exactly 11:05
design.raku.org/S03.html#Adverbs 11:11
I'd expect that this holds to this day
lizmat yeah, I've heard stories about how difficult it was to get adverbs to work 11:12
grondilu I tried very naively to create a NativeCall to openssl's digest : gist.github.com/grondilu/e5d11be7b...119631c805 11:42
oh wait I thought it wasn't working but maybe it does 11:43
it was printing just "NativeCall::Types::CArray[uint8].new"
I thought that was just an empty array but when I coerce it to Str I get some numbers 11:44
oh yes it does work, I get the good hash. Pretty neat. 11:46
Anton Antonov I wonder how many Rakunistas use Jupyter (with Raku or other language.) Any comments on this? (Or confessions.) 12:38
lizmat confesses nothing :) 12:49
Anton Antonov @lizmat I see. 🙂 I know some Rakuns have hard time putting vi down. That might be more confessable... 12:56
lizmat to that I will confess :-)
mscha m:  say '[[8,7,6]]'.EVAL # Bug or feature? 13:54
camelia [8 7 6]
mscha m: say '[[8,7,6],]'.EVAL # I know, this works, but that's not the data I have - adventofcode.com/2022/day/13 13:54
camelia [[8 7 6]]
Nemokosch [[asd]] is the same as [asd] 13:56
I'm not sure what's the principle behind it since the square bracket is pretty much dedicated to these literals
mscha Too bad, no `.EVAL`-based solution for today's Advent of Code then... 13:57
Luckily, it's also valid JSON, and JSON _does_ do the right thing with [[8,7,6]].  :-) 14:03
Nemokosch so basically JS does 😛 14:09
in fact, it seems you can build whole convoluted structures that still give you an empty array 14:15
[[()[]]] - look at this boi 14:16
jast beautiful
Geth doc: tbrowder++ created pull request #4168:
Improve discussion and examples of programmatically using class method names
14:36
doc: 1d41f3822b | (Will Coleda)++ | xt/aspell.t
use higher level Lock

  tbrowder++, part of #4162
Geth doc: a0f57177eb | (Will Coleda)++ | 2 files
use higher level Lock

  tbrowder++, part of #4162
14:49
hobbified I didn't think of going via JSON, I just wrote a parser. Which wasn't awful :)
Nemokosch Seems this year is a lot about parsing 😄 14:59
once again I'd like to remind yall of this supposed AoC collection github.com/codesections/advent-of-raku-2022 15:00
I don't think I could dive into this before this weekend 15:01
mscha I used a grammar at first: github.com/mscha/aoc/blob/master/aoc2022/aoc13b 15:24
Then I saw a Perl solution which used eval and though: nice trick, I'm sure Raku can do that as well.  Not... 15:25
My JSON-based solution: github.com/mscha/aoc/blob/master/aoc2022/aoc13b
mscha I used a grammar at first: correct link github.com/mscha/aoc/blob/master/aoc2022/aoc13 15:27
mcmillhj What's the correct way to iterate through an array in pairs in Raku? I was trying `for @d -> ($l, $r) { dd [$l, $r]; }` but that isn't quite right 15:32
tellable6 2022-01-04T08:50:00Z #raku <SmokeMachine> .tell mcmillhj it seems you’ve just missed the sigil… (glot.io/snippets/g5scg1bf5l)
Nemokosch wow 🤣
mcmillhj: can you give an example of what @d would contain? 15:33
mcmillhj yep, sorry.
m: my @d = [[1], [2], [3], [4]]; for @d -> (@l, @r) { dd [@l, @r]; }
camelia Type check failed in binding to parameter '@l'; expected Positional but got Int (1)
in block <unit> at <tmp> line 1
mcmillhj shoot, sorry 1 sec
m: my @d = [[1], [2], [3], [4]]; for @d -> ($l, $r) { dd [$l, $r]; } 15:34
camelia Too few positionals passed to '<anon>'; expected 2 arguments but got 1 in sub-signature
in block <unit> at <tmp> line 1
dutchie m: my @d = [[1], [2], [3], [4]]; for @d -> $l, $r { dd [$l, $r]; } 15:36
camelia [[1], [2]]
[[3], [4]]
mcmillhj oh, what does wrapping `$l` and `$r` in `()` tell to the compiler. I must not quite understand that.
dutchie `-> ($l, $r) {}` takes one argument and deconstructs it
mcmillhj ahh, okay. thank you dutchie. 15:37
mscha m: my @d = [[1], [2], [3], [4]]; for @d.rotor(2) -> ($l, $r) { dd [$l, $r]; } # works as well
camelia [[1], [2]]
[[3], [4]]
dutchie docs.raku.org/type/Signature#Destr..._arguments
Nemokosch I tend to forget that the () is significant there... 15:38
NemokoschKiwi m: my @d = [[1], [2], [3], [4]]; for @d -> @l, @r { dd [@l, @r]; } 15:39
camelia [[1], [2]]
[[3], [4]]
NemokoschKiwi epicc
mcmillhj m: my @L = [[]]; @L; 15:50
camelia WARNINGS for <tmp>:
Useless use of @L in sink context (line 1)
mcmillhj m: my @L = [[]]; dd @L;
camelia Array @L = []
mcmillhj ^ how come `@L` gets collapsed here? The inner empty Array is removed.
Nemokosch very good question, just got mentioned like 2 hours ago 15:52
mcmillhj probably by someone else doing aoc :) I can check the logs
Nemokosch if I were to guess, [] doesn't say "put this inside an array" but "store this as an array" 15:53
I'm afraid this should be checked on the syntax level, unless you are lucky to pinpoint it somewhere in the docs
mscha "someone else doing aoc", yup, me.  :-) 15:54
Final version I'm happy with: github.com/mscha/aoc/blob/master/aoc2022/aoc13b
Nemokosch docs.raku.org/routine/[%20]
luck might be on our side today - this is just an operator 15:55
mcmillhj Oh okay, I initially did today's problem in JS because the input was valid JSON. Was trying to clean it up in Raku. I did a similar multi sub compare but wasn't zipping the two lists together. 15:56
Nemokosch 😂 15:58
mscha The input is also valid Perl with `eval`, but not Raku with `.EVAL`.  Well, it's valid Raku, but it collapses arrays with one element, that's why this came up before.
Nemokosch lately, I've been addicted to this module that helps you look up source code in the compiler 15:59
so here we go: github.com/rakudo/rakudo/blob/704a...rs.pm6#L13
the very line that gets triggered
Array.from-list([]) gives []
the source also hints that [$[]] would indeed be an array inside an array 16:02
Xliff Hi ho! 16:11
tellable6 2022-12-09T20:03:16Z #raku <guifa> Xliff: you can override it by wrapping it
Xliff Congrats on the release of RakuAST to main: nine++, vrurg++
However, can someone tell me why this isn't working?
RAKUDO_RAKUAST=1 raku call.t
vrurg Xliff: do you take into account that RakuAST is far from being complete yet? 16:12
Xliff Yes. 16:13
However the tests should be working, yes?
Is that the correct way to invoke a RAKUAST enabled program? 16:14
And that is t/12-rakuast/call.t -- I thought that one WAS working?
mcmillhj mscha what does the `?*` passed to `.first(?*)` mean in your solution? 16:22
mscha First one with a true value.
Values are Less, Same, More.  More == 0, so ?More = False
Nemokosch bool conversion?
mscha `first(*)` probably works as well. 16:23
Nemokosch you mean, Same == 0
mscha Yes, sorry, Same == 0, so ?Same == False
mcmillhj oh okay, that means the same thing as `.first(* != Same)` right? 16:24
mscha Yes 16:26
That might indeed be the cleanest way to do that 16:27
smol-hors hi 16:35
vrurg Xliff: don't remember right now about call.t. I think it should. But either way, we're not done with post-merge procedures yet, so let it stabilize first.
vrurg is afk
Xliff vrurg: Sure thing. How long do you estimate that will be? 16:38
lizmat clickbaits rakudoweekly.blog/2022/12/12/2022-50-mainified/ 16:39
smol-hors aoc day 13 github.com/esnk86/aoc22/blob/main/13/main.raku 16:40
my correct-order function could have been better, but eh ;p
mscha: looks like we had a similar thought process 16:42
mscha Yes, although it took me quite a while to get there.  :-) 16:43
smol-hors day 12 took me ages
hobbified my @packets = lines.grep(*.chars > 0).map(*.EVAL).List; that shouldn't work though :) 16:52
mscha Problem with .EVAL: 16:53
m: dd '[[[[1]]]]'.EVAL
camelia [1]
mscha But I guess that doesn't actually make a difference for the answer. 16:54
m: use JSON::Fast; dd from-json('[[[[1]]]]'); 16:55
camelia ===SORRY!=== Error while compiling <tmp>
Could not find JSON::Fast in:
/home/camelia/.raku
/home/camelia/rakudo-m-inst-1/share/perl6/site
/home/camelia/rakudo-m-inst-1/share/perl6/vendor
/home/camelia/rakudo-m-inst-1/sh…
mscha Oh well.  But that does work.
Nemokosch okay but the bot doesn't have JSON::Fast installed 🙂 17:28
ugexe m: dd from-json('[[[[1]]]]'); 17:31
camelia Array @result = [[[[1],],],]
Saw 1 occurrence of deprecated code.
================================================================================
Sub from-json (from GLOBAL) seen at:
<tmp>, line 1
Please use JSON::Fast, JSON::Tiny or JSON…
tonyo lizmat: does the wordpress have linkbacks ? 18:15
lizmat think it does, yes
tonyo can you add one so we don't get flagged for the post today? 18:16
should be deathbykeystroke.com/articles/2022...-raku.html
jj gave me authorship but i can't seem to edit that post
lizmat authorship on WP ? 18:17
do you have a WP login? 18:18
tonyo386 ? 18:19
tonyo ^^
tonyo yea 18:34
that's me
lizmat tonyo: you're the author now 18:47
rf Hey folks! Are there any Raku books that people recommend to get started with? I've been using Raku for about a month but i'd like to go deeper into it. 19:00
lizmat raku.org/resources/ has a few book suggestions 19:03
rf Thanks! 19:08
tonyo lizmat: ty 20:07
vrurg .tell Xliff make use you have rakudo correctly installed. call.t passes for me. 20:09
tellable6 vrurg, I'll pass your message to Xliff
mcmillhj @mscha This is how my day13 turned out: github.com/mcmillhj/aoc/blob/main/...gnal.raku. I updated my Array -> Array comparison to use your zip solution since it looked a lot cleaner. Main difference is `multi` subs for compare. 20:54
vrurg .tell Xliff Correction. For test to work with RAKUDO_RAKUAST env RakuAST must fully or nearly fully complete which is far the case. Tests in 12-rakuast are for already implemented nodes only. 20:59
tellable6 vrurg, I'll pass your message to Xliff
hobbified oh, that's smart 21:03
(using multi sub instead of a big type switch) 21:05
Geth doc: 0rir++ created pull request #4169:
Consolidate once from statement-prefixes.pod6 into control.pod6.
21:07
doc: 0rir++ created pull request #4170:
Consolidate start from statement-prefixes.pod6 into control.pod6.
21:08
doc: 0rir++ created pull request #4171:
Consolidate start from statement-prefixes.pod6 to control.pod6.
21:09
Nemokosch bisectable6: say «a bb».raku; 23:48
bisectable6 Nemokosch, Will bisect the whole range automagically because no endpoints were provided, hang tight
Nemokosch, Output on all releases: gist.github.com/1acc5b7889b3af8f89...792874d9fb
Nemokosch, Bisecting by exit code (old=2019.07.1 new=2019.11). Old exit code: 1
Nemokosch, bisect log: gist.github.com/6a25b76c69cf12914e...a25747238d 23:49
Nemokosch, (2019-11-01) github.com/rakudo/rakudo/commit/7c...3c0a81e7ad
Nemokosch, Bisecting by output (old=2017.05 new=2017.06) because on both starting points the exit code is 1
Nemokosch oops
bisectable6 Nemokosch, bisect log: gist.github.com/b26cafc220b44a962e...cb5c3bc71c
Nemokosch, (2017-06-01) github.com/rakudo/rakudo/commit/7c...656b955cd7
Nemokosch, Bisecting by output (old=2016.09 new=2016.10) because on both starting points the exit code is 1
Nemokosch, bisect log: gist.github.com/21d902965bcc028249...b9d51f6e27
Nemokosch, Output on all releases and bisected commits: gist.github.com/aefe8b99dcf9e951fe...b4a5631d72 23:50
Nemokosch bisectable6: dd «a bb»;
bisectable6 Nemokosch, Will bisect the whole range automagically because no endpoints were provided, hang tight
Nemokosch, ¦6c (66 commits): «"a bb"␤»
Nemokosch, Nothing to bisect!
Nemokosch that's... peculiar? 23:51
bisectable6: enum Foo «a b»; say Foo.enums<a>:exists;
bisectable6 Nemokosch, Will bisect the whole range automagically because no endpoints were provided, hang tight
Nemokosch, ¦6c (66 commits): «False␤» 23:52
Nemokosch, Nothing to bisect!
Nemokosch b-but... 23:53
the docs say it's True...
bisectable6: my $a = 42; say << "$a b" c >>.raku; 23:54
bisectable6 Nemokosch, Will bisect the whole range automagically because no endpoints were provided, hang tight
Nemokosch, Output on all releases: gist.github.com/c538dcd87d085bfee9...3f42eb0903 23:55
Nemokosch, Bisecting by exit code (old=2019.07.1 new=2019.11). Old exit code: 1
Nemokosch, bisect log: gist.github.com/e6c40464faf917e728...481ec2e59d
Nemokosch, (2019-11-01) github.com/rakudo/rakudo/commit/7c...3c0a81e7ad
Nemokosch, Bisecting by output (old=2017.05 new=2017.06) because on both starting points the exit code is 1
Nemokosch, bisect log: gist.github.com/fed5764f38156456f8...5d99c73027
Nemokosch, (2017-06-01) github.com/rakudo/rakudo/commit/7c...656b955cd7
Nemokosch, Bisecting by output (old=2016.09 new=2016.10) because on both starting points the exit code is 1 23:56
Nemokosch, bisect log: gist.github.com/8ac89bfc646c588d8f...9e98c2fe26
Nemokosch, Output on all releases and bisected commits: gist.github.com/29836733fe6cd35df3...ee7c7efda4
Nemokosch dayum, the same trap again 23:57
bisectable6: my $a = 42; dd << "$a b" c >>; 23:58
bisectable6 Nemokosch, Will bisect the whole range automagically because no endpoints were provided, hang tight
Nemokosch, ¦6c (66 commits): «("42 b", "c ")␤»
Nemokosch, Nothing to bisect!
Nemokosch also doesn't match the docs! 23:59