🦋 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.
[Coke] raku-musings.com/sedol-middle.html - points out that "-123" isn't accepted if you have a MAIN arg declared as Int. 123 does, but not -123 00:59
japhb Confusion with argument parsing? Might work with "-- -123 01:53
"
sena_kun Xliff, cause I remember github.com/raku-community-modules/...h/pull/130 and was wondering why would you want to. ANd if you're working with postgres, I wonder if DB::Pg is another option to consider. 07:54
tbrowder g'day, mates, a raku ? if you pls 12:51
*plz
CIAvash Shouldn't the new-dispatch release have been delayed until the bugs involving ecosystem modules get fixed? 12:53
lizmat CIAvash: any particular ecosystem module you're referring to ? 12:54
Altai-man CIAvash, what bugs were not fixed, github.com/rakudo/rakudo/issues/4562 ? Jonathan has stated the behaviour of previous releases are buggy as itself, so it is not feasible to for it to be a blocker. 12:55
s/are/is/
tbrowder i have a class i want to instantiate from a hash. for a given key 'foo', i want to set class attribute $!foo to hash key 'foo's value. i naively tried "$!{$key} = $value" but that doesn't work.
Altai-man tbrowder, self.bless(|%hash)? 12:56
tbrowder i know there is a way to do it, but not sure how
Altai-man m: class A { has $.a; has $.b; }; my %h = a => 42, b => 50; A.new(|%h).say;
camelia A.new(a => 42, b => 50)
Altai-man like this?
tbrowder Altai-man: looks good, thanks! i'll go try it out.., 12:57
CIAvash Altai-man: yes, (module involved is Curry), so should I wait for correct behavior to be decided or find a workaround? 12:58
Altai-man CIAvash, if I would be a release manager, I'd make the ticket a blocker and suggested delaying updates, monthly releases are not that far off. Finding a workaround is maybe a good idea, it might also help golfing down the issue. Ah, and golfing down the issue would help _a lot_ in getting a fix faster. 13:00
[Coke] japhb: -- -123 worked. Sadly doesn't look like Arne allows comments. 13:58
Altreus that seems like one of those problems that could be solved by backtracking in the option parser
melezhik weekly: weekly updates of Raku projects on mybfio - mybf.io/?language=Raku 14:02
notable6 melezhik, Noted! (weekly)
melezhik does Raku have a dummy operator, that does nothing? 14:55
Altai-man melezhik, for routines? 14:57
RaycatWhoDat ..., right?
melezhik no, for while loop
Altai-man ignore my question
no, ... is a bit different. 14:58
melezhik, can you provide a small example of what you want to do?
lizmat melezhik: while 1 { Nil } ??
melezhik m: 1 while "aaa" ~~ s/a/b/;
camelia WARNINGS for <tmp>:
Useless use of constant integer 1 in sink context (use Nil instead to suppress this warning) (line 1)
Cannot modify an immutable Str (aaa)
in block <unit> at <tmp> line 1
melezhik m: Nil while "aaa" ~~ s/a/b/;
camelia Cannot modify an immutable Str (aaa)
in block <unit> at <tmp> line 1
melezhik m: 1 while "aaa" ~~ s/a/b/;
camelia WARNINGS for <tmp>:
Useless use of constant integer 1 in sink context (use Nil instead to suppress this warning) (line 1)
Cannot modify an immutable Str (aaa)
in block <unit> at <tmp> line 1
melezhik this is an example 14:59
I don't want `Useless use of constant integer 1 in sink context` warnings
lizmat Nil while .... is what I use for those cases
melezhik m: my $a = "aaaa"; Nil while $a ~~ s/a/b/;
camelia ( no output )
lizmat m: my $foo = "aaa"; Nil while $a ~~ s/a/b/; say $foo
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$a' is not declared
at <tmp>:1
------> 3my $foo = "aaa"; Nil while 7⏏5$a ~~ s/a/b/; say $foo
melezhik thanks lizmat
it workas 15:00
works
lizmat m: my $foo = "aaa"; Nil while $foo ~~ s/a/b/; say $foo
camelia bbb
lizmat m: say "aaa".subst(/a/, "b", :global)
camelia bbb
melezhik :g does not work for me 15:01
lizmat m: my $foo = "aaa"; $foo ~~ s:g/a/b/; say $foo
camelia bbb
lizmat or that ^^
melezhik i have more complex regexp pattern, where :g does not do what I want, so I have to do `Nil while $a ~~ s///;` workround
lizmat that feels... weird 15:02
melezhik ok. let me show MY example
give me 5 minutes 15:07
m: my $res = ":home: ::ok:: :foo:bar: :fire: :man:"; Nil while $res ~~ s!( ^^ || \s+ ) ':' (<-[\:]>+) ':' ( $$ || \s+ )!{$0}<span class="icon"><i class="fas fa-{$1}"></i></span>{$2}!; say $res; 15:09
camelia <span class="icon"><i class="fas fa-home"></i></span> ::ok:: :foo:bar: <span class="icon"><i class="fas fa-fire"></i></span> <span class="icon"><i class="fas fa-man"></i></span>
melezhik so this is WORKING solution without `g`
I can't make it work using `~~ s:g` 15:10
the tricky part regexp replacement should only replace `:foo:` but not `::foo::` or `foo::foo` 15:11
Altai-man that's the only possible input you have or do you parse arbitrary messages where anything can be? 15:13
melezhik so basically it should only replace anything between `:` but WHEN there is no none space symbols before first `:` and no none space symbols after the second `:`
Altai-man if yes, then I don't think a regex is necessary at all, just split the string and check properties you want with starts-with / ends-with / substring.
lizmat I was thinking along similar lines :-) 15:14
melezhik yes, but my first thought was to use regexp replacement with global, because this what replacement is designed , I don't want to write extra code for split, etc ...
Altai-man if regex solution starts to become a real pain maybe it's not the right toot at all.
extra code... 15:15
Altreus m: my $res = ":home: ::ok:: :foo:bar: :fire: :man:"; $res ~~ s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' ( $$ || \s+ )!{$0}<span class="icon"><i class="fas fa-{$1}"></i></span>{$2}!; say $res; # what DOES it do?
camelia <span class="icon"><i class="fas fa-home"></i></span> ::ok:: :foo:bar: <span class="icon"><i class="fas fa-fire"></i></span> :man:
melezhik I am not sure if this is bug or not by my `s:g` attempts failed, let me show youy
Altreus oh
it doesn't reënter as you'd expect
melezhik ? 15:16
Altreus well it seems like it got most of it right but didn't reapply the regex as you'd have expected when it finished :fire:
does it perhaps consume the space twice?
such that when you use a loop it forgets it consumed it
melezhik Altreus loop code works correctly for me 15:17
Altreus yes
but I think the problem with s:g is that you've asked for a space at the start and end, and there's only one space between :fire: and :man:, so you can't have both
melezhik m: my $res = ":home: ::ok:: :foo:bar: :fire: :man:"; $res ~~ s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' ( $$ || \s+ )!{$0}<span class="icon"><i class="fas fa-{$1}"></i></span>{$2}!; say $res; 15:18
camelia <span class="icon"><i class="fas fa-home"></i></span> ::ok:: :foo:bar: <span class="icon"><i class="fas fa-fire"></i></span> :man:
Altreus m: my $res = ":home: ::ok:: :foo:bar: :fire: :man:"; $res ~~ s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' <?before ( $$ || \s+ )>!{$0}<span class="icon"><i class="fas fa-{$1}"></i></span>{$2}!; say $res; # what DOES it do? 15:19
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in metachar:sym<( )>; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3 (<-[\:]>+) ':' <?before ( $$ || \s+ )>7⏏5!{$0}<span class="i…
melezhik so this one does not work as you can see, as it ignore the last `:man:`
but it should not
Altreus m: my $res = ":home: ::ok:: :foo:bar: :fire: :man:"; $res ~~ s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' <?( $$ || \s+ )>!{$0}<span class="icon"><i class="fas fa-{$1}"></i></span>{$2}!; say $res; # what DOES it do? 15:20
camelia 5===SORRY!5===
Unrecognized regex metacharacter < (must be quoted to match literally)
at <tmp>:1
------> 3 s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' <?7⏏5( $$ || \s+ )>!{$0}<span class="icon"><
Couldn't find terminator !
at <tmp>:1
-…
melezhik m: my $res = ":home: :fire: :man:"; $res ~~ s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' ( $$ || \s+ )!{$0}<span class="icon"><i class="fas fa-{$1}"></i></span>{$2}!; say $res;
camelia <span class="icon"><i class="fas fa-home"></i></span> :fire: <span class="icon"><i class="fas fa-man"></i></span>
melezhik here is another example of incorrect work, where `:fire` in the middle gets ignored
Altreus m: my $res = ":home: ::ok:: :foo:bar: :fire: :man:"; $res ~~ s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' <? $$ || \s+ >!{$0}<span class="icon"><i class="fas fa-{$1}"></i></span>{$2}!; say $res; # what DOES it do?
camelia 5===SORRY!5===
Unrecognized regex metacharacter < (must be quoted to match literally)
at <tmp>:1
------> 3 s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' <?7⏏5 $$ || \s+ >!{$0}<span class="icon"><i
Couldn't find terminator !
at <tmp>:1
-…
melezhik so I ended up with `Nil while $res ~~ s///` alternative, at least it works 15:21
m: my $res = ":home: :fire: :man:"; Nil while $res ~~ s!( ^^ || \s+ ) ':' (<-[\:]>+) ':' ( $$ || \s+ )!{$0}<span class="icon"><i class="fas fa-{$1}"></i></span>{$2}!; say $res;
camelia <span class="icon"><i class="fas fa-home"></i></span> <span class="icon"><i class="fas fa-fire"></i></span> <span class="icon"><i class="fas fa-man"></i></span>
Altreus I do not understand why it has a problem with my <
melezhik so like I said, _maybe_ rakudo regexp bug?
Altreus noooooo I'm pretty sure the problem is that it consumes the space and continues looking *after* the space 15:22
and you've asked for it to have a space or ^^, which now there is not
e.g.
m: my $res = ":home: :fire: :man:"; $res ~~ s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' ( $$ || \s+ )!{$0} (({$1})) (({$2}))! 15:23
camelia ( no output )
Altreus oops
m: my $res = ":home: :fire: :man:"; $res ~~ s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' ( $$ || \s+ )!{$0} (({$1})) (({$2}))!l; say $res;
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3' ( $$ || \s+ )!{$0} (({$1})) (({$2}))!7⏏5l; say $res;
expecting any of:
infix
infix stopper
statement end
Altreus m: my $res = ":home: :fire: :man:"; $res ~~ s:g!( ^^ || \s+ ) ':' (<-[\:]>+) ':' ( $$ || \s+ )!{$0} (({$1})) (({$2}))!; say $res;
camelia ((home)) (( )):fire: ((man)) (())
Altreus hmm! 15:24
I guess not!
melezhik I also tried to use word boundaries `<<` `>>` but for some reasons this did not work either
yes, it's possible to golf to more concise example
afk & 15:26
Altreus m: my $res = ":home: ::ok:: :foo:bar: :fire: :man:"; s:g/ <?after \s || ^^> ':' (<-[^\:]>+) ':' <?before \s || $$> /[[$0]]/; say $res; 15:35
camelia Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
:home: ::ok:: :foo:bar: :fire: :man:
in block <unit> at <tmp> line 1
Altreus m: my $res = ":home: ::ok:: :foo:bar: :fire: :man:"; $res ~~ s:g/ <?after \s || ^^> ':' (<-[^\:]>+) ':' <?before \s || $$> /[[$0]]/; say $res;
camelia [[home]] ::ok:: :foo:bar: [[fire]] [[man]]
Altreus melezhik: This seems to work :)
replace [[ ]] with span etc 15:36
Altai-man Xliff, ping? 15:40
.tell Xliff wrt your question about local modules in Comma. I didn't think about it yesterday, but jnthn has suggested to just add the other modules you have locally as "modules" of the project and now I don't see why wouldn't it work as you want. 15:42
tellable6 Altai-man, I'll pass your message to Xliff
Xliff Altai-man: How is this done? 15:44
Altai-man Xliff, File -> Project Structure -> Modules -> Import Module. 15:45
Xliff Thank you.
Altai-man and if it doesn't work, at least you will have some steps to reproduce like "Download the distribution locally from X, then create a dummy project and try to add it as a module". 15:46
melezhik Altreus I was also thinking about look ahead / look behind constructions for this , I just did not know the Raku syntax for them 16:30
I guess it's more or less most logical way to solve this, however the question why this does not work without loop and look behind/ahead ? 16:31
is not it a bug?
Altreus no I still think you're consuming too much but I'm struggling to prove it 16:36
by using look-around the match becomes zero-width and can therefore match both before pos() and after it, basically 16:37
oh!
m: my $res = ":home: :fire: :man:"; $res ~~ s:g!( ^^ || \s ) ':' (<-[\:]>+) ':' ( $$ || \s )!{$0} (({$1})) (({$2}))!; say $res;
camelia ((home)) (( )) ((fire)) (( )) ((man)) (())
Altreus m: my $res = ":home: :fire: :man:"; $res ~~ s:g!( ^^ || \s ) ':' (<-[\:]>+) ':' ( $$ || \s )!{$0} (({$1})) (({$2}))!; say $res;
camelia ((home)) (( )):fire: ((man)) (()) 16:38
Altreus melezhik: you were consuming *all* the whitespace
so the first match consumed ':home: '
And then :g needed ' :fire: ' for the next match, but in fact it was only ':fire: '
I tried to prove it with more spaces but it just consumed those too :D 16:39
melezhik Altreus++ 17:23
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2021/10/25/2021-43-thank-you/ 17:49
codesections lizmat++ I think the 17:53
Vue + Raku link points to the previous video
lizmat meh 17:55
indeed
should be fixed now # codesections++ 17:56
[Coke] thank you lizmat! 18:13
melezhik lizmat++ 18:15
Ulti just tried the latest release and my bioinformatics tests are 2x as fast compared with December 2020 19:54
El_Che nice
Ulti 20850 deopt before down to 142... I'd say that's a significant improvement! 19:55
50% jitted frames to 85% 19:56
MasterDuke nice 19:57
Ulti prime benchmark has gotten a little bit slower gist.github.com/MattOates/c5879a07b1ef2c013097 but only a tiny bit 20:06
[Coke] laments not having enough cycles to work on a .NET backend yet. 20:19
(though at least I do have some admin stuff written in Raku that is making my job much easier) 20:22
japhb Ulti: Aside from arguably the last two tests (primes-naive-grep and primes-naive-parallel-grep), the runtimes for the various prime benchmarks are now all too short to be stable in the face of basic OS scheduling. 21:36
wayland_ Hi all! Is there a way to tell if there's more data waiting on an IO::Socket::INET without blocking? 21:40
japhb wayland_: Well, you could pull the native-descriptor and use it with select() or so. Or maybe use IO::Socket::Async instead (docs.raku.org/type/IO::Socket::Async) if what you really want is an async API? I guess the real question is -- why do you want to do this? 21:44