🦋 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.
Geth doc/special-chars-in-char-ranges: 3a0d01c988 | (Daniel Sockwell)++ (committed using GitHub Web editor) | doc/Language/regexes.pod6
Fix whitespace

Remove trailing whitespace.
03:09
Geth doc: 9741c66cc2 | (Daniel Sockwell)++ (committed using GitHub Web editor) | doc/Language/regexes.pod6
Explain behavior of non-alphanumerics in <[ ]>

The docs previously mentioned that you can use \ to escape characters inside <[ ]> ; this commit adds the fact that you don't need to escape most non-alphanumeric characters the way you do in the portion of a regex outside <[ ]> and that you must escape (rather than quote) characters inside <[ ]> for them to have their literal meaning.
04:03
linkable6 Link: docs.raku.org/language/regexes
Geth doc: 3a0d01c988 | (Daniel Sockwell)++ (committed using GitHub Web editor) | doc/Language/regexes.pod6
Fix whitespace

Remove trailing whitespace.
doc: c6b9012fee | (Will Coleda)++ (committed using GitHub Web editor) | doc/Language/regexes.pod6
Merge pull request #3948 from Raku/special-chars-in-char-ranges

Explain behavior of non-alphanumerics in <[ ]>
tib Hello :) 05:26
dev.to/thibaultduponchelle/the-eph...oudot-2a1a and dev.to/thibaultduponchelle/the-eph...atria-2m5h jjatria maybe plans to talk about Raku (?) 05:27
aleksb hi, something counter-intuitive is happening, if this isn't a compiler bug can someone please explain this behaviour? 05:35
sub test {
gather {
loop (my $d = 1; $d < 5; $d++) {
take (0, $d);
} 05:36
}
}
say test(); # output: ((0 1) (0 2) (0 3) (0 4))
say eager test(); # output: ((0 5) (0 5) (0 5) (0 5))
MasterDuke m: sub test { gather { loop (my $d = 1; $d < 5; $d++) { take (0, $d); } } }; say test(); say eager test() # aleksb fyi you can run code here 07:11
camelia ((0 1) (0 2) (0 3) (0 4))
((0 5) (0 5) (0 5) (0 5))
gfldex m: sub test { gather { loop (my $d = 1; $d < 5; $d++) { take (0, $d); } } }; say eager test(); 07:12
camelia ((0 5) (0 5) (0 5) (0 5))
moon-child m: sub test { gather { loop (my $d = 1; $d < 5; $d++) { take (0, $d); } } }; my $x = eager test; say $x[0] === $x[1] 07:13
camelia False
moon-child huh. Thought that might be it
gfldex m: sub test { gather { loop (my $d = 1; $d < 5; $d++) { take (0, $d); } } }; my $l := eager test(); say $l.WHAT; 07:18
camelia (List)
gfldex m: sub test { gather { loop (my $d = 1; $d < 5; $d++) { take (0, $d); } } }; my $l := eager test(); dd $l.WHAT;
camelia List
gfldex m: sub test { gather { loop (my $d = 1; $d < 5; $d++) { take (0, $d); } } }; my $l := eager test(); dd $l;
camelia ((0, 5), (0, 5), (0, 5), (0, 5))
gfldex m: sub test { gather { loop (my $d = 1; $d < 5; $d++) { take 0, $d; } } }; my $l := eager test(); dd $l; 07:19
camelia ((0, 5), (0, 5), (0, 5), (0, 5))
MasterDuke m: sub test { gather { my $d = 1; while $d < 5 { take (0, $d++); } } }; say test(); say eager test()
camelia ((0 1) (0 2) (0 3) (0 4))
((0 1) (0 2) (0 3) (0 4))
gfldex aleksb: "the variable is declared as a lexical variable in the loop's outer or containing scope so that it can be used in code following the loop statement." 08:45
gfldex and gather/take must preserve the scope 08:46
aleksb gfldex: does (0, $d) capture a reference to $d rather than its value? Using [0, $d] instead does what I expect 09:23
aleksb m: sub test { gather { loop (my $d = 1; $d < 5; $d++) { take [0, $d] } } }; say eager test() 09:23
camelia ([0 1] [0 2] [0 3] [0 4])
aleksb m: sub test { gather { loop (my $d = 1; $d < 5; $d++) { take (0, $d) } } }; say eager test() 09:24
camelia ((0 5) (0 5) (0 5) (0 5))
MasterDuke aleksb: yeah, i seem to recall someone wrote a blog post recently talking about the difference between Arrays and List and how they interact with containers/values 09:29
aleksb m: my $x = 1; my $y = (0, $x); $x++; say $y 09:32
camelia (0 2)
aleksb well, I guess that's just how it works... seems strange for "immutable" lists to be so easy to change 09:39
MasterDuke well, it's a matter of perspective. the lists themselves can't change, but the things in the lists can 09:41
aleksb Is there a "correct" way to store the value, not the variable, in the list? I can do +$d or $d.clone 09:50
MasterDuke m: my $x = 1; my $y = (0, $x<>); $x++; say $y # another way 09:53
camelia (0 1)
aleksb ah I think I needed that operator for something recently thanks 09:54
MasterDuke it's the decont (de-containerizer) operator 09:55
mentioned in docs.raku.org/language/containers (and probably other places, but that's the first place i looked) 09:56
aleksb yeah thanks I need to review that 09:57
frost hello, does raku have the similar things as [x;y;z] in python, where i can use index from x to y counting by z steps? 10:48
lizmat m: my @a = ^20; say @a[1,3..*] 10:49
camelia (1 (3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19))
lizmat m: my @a = ^20; say @a[1,3...*]
camelia (1 3 5 7 9 11 13 15 17 19)
frost oh, thanks lizmat 10:52
lizmat or any other algorithm you can think of with ...
frost Yes, it is really impressive. 10:56
MasterDuke m: my @a = ^20; say @a.skip.rotor(1 => 1).flat # TIMTOWTDI 10:57
camelia (1 3 5 7 9 11 13 15 17 19)
frost Yes, it is really impressive. 10:58
camelia (1 3 5 7 9 11 13 15 17 19) 10:58
neither hi, I have a class `A` and its implementation in a file. I also have some infix operator declarations for type `A` outside the class e.g., to have `$a1 + $a2`. Can I move these operator subroutines to another file and `use` them along with the class? 11:01
frost MasterDuke thanks, it's also a good way,TMTOWTDI! 11:02
MasterDuke benchable6: compare my @a = ^20; my @b; @b = @a[1,3...*] for ^10_000; ||| my @a = ^20; my @c; @d = @c.skip.rotor(1 => 1).flat for ^10_000;
benchable6 MasterDuke, ¦my: «Cannot find this revision (did you mean “nom”?)»
MasterDuke benchable6: HEAD compare my @a = ^20; my @b; @b = @a[1,3...*] for ^10_000; ||| my @a = ^20; my @c; @d = @c.skip.rotor(1 => 1).flat for ^10_000; 11:03
benchable6 MasterDuke, starting to benchmark the 1 given commit
MasterDuke, No new data found
MasterDuke benchable6: compare HEAD my @a = ^20; my @b; @b = @a[1,3...*] for ^1_000; ||| my @c = ^20; my @d; @d = @c.skip.rotor(1 => 1).flat for ^1_000; # i didn't the sequence version would be that much slower 11:05
benchable6 MasterDuke, starting to benchmark the 1 given commit
MasterDuke, ¦HEAD: «04===SORRY!04=== Error while compiling /tmp/Q5mKSSUk5I␤Missing block␤at /tmp/Q5mKSSUk5I:1␤------> 03y $b = Bench.new; $b.cmpthese(10, %subs)08⏏04<EOL>␤»
gfldex m: sub f { gather for ^19 { state $i = 1; take $i++ } }; say (my @a = ^20)[&f];
camelia (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)
gfldex frost: subscripts also take callables ^^^
MasterDuke benchable6: compare HEAD my @a = ^20; my @b; @b = @a[1,3...*] for ^1_000; ||| my @c = ^20; my @d; @d = @c.skip.rotor(1 => 1).flat for ^1_000; 11:06
benchable6 MasterDuke, starting to benchmark the 1 given commit
benchable6 MasterDuke, gist.github.com/cea6e1eb84580f6f21...953295b805 11:06
gfldex neither: The operators will refere to the type object produced by the class. As long as those are available at compile time, you can put the operators where you like. 11:07
MasterDuke ugh, don't know why that took so long to get right
neither gfldex: Yes that's the issue: I get `Invalid typename 'A' in parameter declaration.` as you say. I don't know how to make it available at compile time. 11:14
gfldex neither: did you try a forward declaration? 11:15
neither: You will have to `use` the module with the class definitions in the file with the operators. 11:19
neither gfldex: I have 3 files: `main.rakumod`, `ops.rakumod` and `script.raku`. If I `use` the `main` module in `ops`, rakumod files are compiling fine. Aim is to `use main` from `script.raku` and to be able to use the class in `main` module along with its operations available, e.g., `$a1 + $a2` to be possible. But from `script.raku`, it doesn't see the 13:03
operators.
lizmat clickbaits rakudoweekly.blog/2021/08/30/2021-...perseding/ 13:46
phogg Whoever figured out the BUILD/TWEAK constructor split was a genius. The more I try to use more rigid non-Raku languages the more I'm convinced nothing else is sane. 21:46
Xliff phogg: Examples, pls? I'm interested in seeing how other people have been using that. 22:02
phogg I have nothing particularly worth sharing, just a general delight in the way that composition with them works 22:05
for a work project I and one of my co-workers liberally stole the Raku object model and implemented it in PHP, and it is there where we have repeatedly found the objects and APIs to be superior 22:06
things I have in real Raku are too trivial by comparison
[Coke] phogg: are you able to consider switching to Raku wholesale? 22:32
phogg [Coke]: would if we could
[Coke] I hear that.
phogg a couple million lines of code don't get rewritten overnight
[Coke] What if there was an Inline::PHP? 22:33
phogg we had been saying for years "sure would be nice if the APIs and libraries in PHP didn't suck" and then in 2017 my co-maintainer said "I am just going to write a version of Str."
phogg One thing lead to another, and things are much better now. If you box hard enough you can get pretty far even without a language that really supports modifying itself 22:34
lack of multiple inheritance is a pretty hard limit
I should eventually port our extensions to Str and other things out and put them up as raku modules. There are some useful things maybe others would want. 22:35
[Coke] cool. 22:36
phogg if there was a working Inline::PHP that would help a lot. 22:39
that would give us an easier incremental transition path without having to stop and rewrite the world. 22:40