🦋 Welcome to the former MAIN() IRC channel of the Raku Programming Language (raku.org). This channel has moved to Libera (irc.libera.chat #raku)
Set by lizmat on 23 May 2021.
Razetime is there any image manipulation library in raku 04:08
japhb Razetime#5187: Some, but I wouldn't say extensive, so it depends on what exactly you need; you can search on raku.land for suspects. 04:17
moon-child there are apparently imagemagick bindings (modules.raku.org/dist/MagickWand:cpan:AZAWAWI). No idea how good they are
japhb Hmmm, raku.land searches should be able to find substrings. One of the searches I did was for 'Magick' but it returned 0 results. :-( 04:18
tbrowder, leont, tonyo, El_Che: Just pushed 0.0.2 of github.com/japhb/serializer-perf , now with support for 3 different TOML modules. Unfortunately, I also had to add bulletproofing and reliability tests because the TOML codecs really struggled for some inputs. Unfortunately, at least one TOML codec/input combo can *still* panic MoarVM. :-( 04:21
.oO( It's japhb sad face time ... )
04:22
japhb (The panic-ing is why it's still not uploaded to fez/zef, just git pushed.) 04:24
nine japhb: do you have a reduced test case for those panics? 08:48
tbrowder moon-child: i've used GraphicksMagic Perl modules and they worked well for me. Some time ago I seem to remember the crowd went from Image* to Graphicks* because of some issue (maybe not keeping up devel). 10:55
tbrowder sorry, that's GraphicsMagick, website outlines genesis of its spinoff from ImageMagick in 2002. imho, any raku effort ought to be with it rather than ImageMagick 12:03
latest update was 2020
Razetime would be useful to have something standalone 13:08
vasko Raku is so cool, I love it. It's so cool I really want to put it in production at work. 16:36
Is hub.docker.com/_/rakudo-star the image to use when you want reliability? 16:37
El_Che star releases are not more reliable than regular releases 16:42
El_Che but, sure, it's certainly a good option 16:44
El_Che for my own use, I create alpine or ubuntu containers with packages github.com/nxadm/rakudo-pkg 16:45
that way the image is smaller 16:46
ymmv
vasko Thanks, do you have a recommend Dockerfile with the zef install and how you manage dependencies? 16:52
Also do any of you use QMK Firmware and Linux? 16:53
I'm wondering what the best way to start typing unicode is.
I'm still painfully copy pasting symbols from the web browsers :(
MasterDuke there's a unicode entry section on the docs website 16:56
i.e., how to enter unicode
Geth doc/py-nutshell-enumerate-patch: bc1de2cd80 | (Trey Harris)++ (committed using GitHub Web editor) | doc/Language/py-nutshell.pod6
Copyediting

  @JJ — I noticed that in this doc, `L<>`’s to routine docs are not in `C<>`’s, so appear as regular text instead of monospaced. This seems to be a case where there’s different styles on different pages—but should I submit a separate patch to change all these routine-link `L<>`’s to code font? Thanks.
18:23
japhb nine: Nope, panic not reduced yet. I'll see what I can do in that direction. :-) 18:29
[Coke] I should be able to return a new Exception (subclass) from a sub, aye? (I Swear I'm returning it in some cases, but when I check the return value type, it's always a Hash (which is the normal happy return path) 19:04
[Coke] ... ah. I think I'm accidentally turning the exception into a fail and then getting an empty string out of it. 19:14
vrurg [Coke]: and it doesn't explode? Are you boolifying it somewhere? 19:37
jdv [Coke]: do you turn a lot of things into fail often? 19:59
[Coke] jdv: it's just one of my powers. 20:05
jdv i knew it! 20:14
codesections Is there a reason why the following is: 20:20
m: say (-1).sqrt; say (-1.Complex).sqrt 20:21
camelia NaN
0+1i
codesections I would have expected those to both return 0+1i (that is, the NaN surprised me) 20:22
[Coke] you have to declare if you want Complex, yes.
m: -1.^name.say
camelia WARNINGS for <tmp>:
Int
Useless use of "-" in expression "-1.^name.say" in sink context (line 1)
[Coke] m: (-1).^name.say 20:23
camelia Int
codesections yeah, I see that that is the case. I would have expected an auto conversion, and I was wondering why we didn't go that route
m: 1.sqrt.^name.say 20:24
camelia Num
codesections plenty of fns convert
[Coke] would you want *every* math operator to upgrade to Complex? 20:25
operator +/or function
An argument could be made either way, but it would be an argument. 20:26
codesections no? I mean, I wouldn't want *every* math operator to upgrade to Num either -- just the ones that need to
How many would need to return a Complex result?
moritz well, Larry was against turning (-1).sqrt into 1i. He said most folks don't know, want or need complex numbers
[Coke] moritz++
moritz and for somebody who isn't familiar with the concept, getting the information that there was an undefined operation is much more useful than some mathematical concept they don't know 20:27
codesections I see. That makes sense – it's trading off consistency, but getting something useful in return.
moritz you could also call Num in, Num out consistent :D 20:28
codesections not sure I agree, but I can see the force of the argument. Thanks, that was exactly what I was asking :D
moritz dates himself by recalling a probably decade-old discussion with TimToady :D 20:29
and you're welcome
codesections well, but Int in, Num out is inconsistent then! (I.e., there's *some* inconsistency with how Raku expands numeric types) 20:30
well, that's why I asked -- I figured there was a years-ago discussion that I hadn't been around for :)
Oh, I see ^^^ in the docs, actually (I was going to add a note, but there's already one there -- I just didn't look in the right place) 20:43
it also points out &roots
m: say (-1).roots(2)[0] =~= i 20:44
camelia True
Util m: class L {has Str $.l}; my $c = 0; multi sub infix:<cmp> (L $a, L $b) { say "called {++$c} times"; $b.l cmp $a.l }; my @a = map {L.new: :l($_) }, <a b c a b c a>; @a .= sort; my $z = @a[0] cmp @a[1]; # Why is my custom cmp not called by .sort? 21:10
camelia called 1 times
codesections I'm not 100% sure this is right, but I believe it's because your &infix:<cmp> isn't in the lexical scope for &sort's definition. But you can pass it in as a custom comparator with .sort(&infix:<cmp>) 21:18
Util codesections: thanks, I am familiar with custom comparitors in sort. I am really playing with .minpairs, which says it uses <cmp>. Sort should also use <cmp> even more frequently, hence my use of it here. 21:22
Also, the infix:<cmp> definition is after the close of the class, so it *is* in lexical scope, for my explicit single call to cmp, and for the sort. 21:23
codesections I agree that it's in lexical scope for your call to cmp. But isn't it in dynamic scope for &sort? (That is, in scope at the callsite, but not where &sort was defined) 21:25
But I might be wrong about how multis handle scope... 21:27
Util I don't quite follow you on scoping. Can you see some variant of what I am doing that would use my custom <cmp> for sorting or .minpairs? 21:29
codesections hmm, not the most elegant, but this would work I think: 21:35
thundergnat m: class L {has Str $.l}; my $c = 0; multi sub infix:<cmp> (L $a, L $b) { say "called {++$c} times"; $b.l cmp $a.l }; my @a = map {L.new: :l($_) }, <a b c a b c a>; @a .= sort(&infix:<cmp>); my $z = @a[0] cmp @a[1]; 21:38
camelia called 1 times
called 2 times
called 3 times
called 4 times
called 5 times
called 6 times
called 7 times
called 8 times
called 9 times
called 10 times
called 11 times
called 12 times
called 13 times
called 14 times
called 1…
thundergnat It IS odd that you need to pass in the declared cmp routine...
codesections m: class L {has Str $.l}; my $c = 0; &infix:<cmp>.wrap(->| { say "called {++$c} times"; $b.l cmp $a.l }) ; my @a = map {L.new: :l($_) }, <a b c a b c a>; @a .= sort; my $z = @a[0] cmp @a[1];
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$b' is not declared
at <tmp>:1
------> 3>.wrap(->| { say "called {++$c} times"; 7⏏5$b.l cmp $a.l }) ; my @a = map {L.new: :
codesections m: class L {has Str $.l}; my $c = 0; &infix:<cmp>.wrap(->$a, $b { say "called {++$c} times"; $b.l cmp $a.l }) ; my @a = map {L.new: :l($_) }, <a b c a b c a>; @a .= sort; my $z = @a[0] cmp @a[1]; 21:39
camelia called 1 times
Died with X::Method::NotFound
in block <unit> at <tmp> line 1

called 2 times
called 3 times
thundergnat It is probably some sort of scoping issue but I am not seeing the reason for it
codesections m: class L {has Str $.l}; my $c = 0; &infix:<cmp>.wrap(->| { say "called {++$c} times"; callsame }) ; my @a = map {L.new: :l($_) }, <a b c a b c a>; @a .= sort; my $z = @a[0] cmp @a[1];
camelia called 1 times
called 2 times
called 3 times
called 4 times
called 5 times
called 6 times
called 7 times
called 8 times
called 9 times
called 10 times
called 11 times
called 12 times
called 13 times
called 14 times
called 1…
codesections (and then unwrap after, which is part of what makes it less elegant) 21:40
jdv it could be a optimization that made overloading cmp impossible? 21:41
lizmat would probably know
lizmat what is the nature of the programmatical emergency? 21:42
jdv just skimming src/core.c/Rakudo/Sorting.pm6 hints at that, maybe
thundergnat There are 14 candidates for cmp. github.com/rakudo/rakudo/blob/efb3...er.pm6#L14
Util Classes should be able to define their own ordering. My understanding is that such should be done via custom `multi sub infix:<cmp>` with 2 params, each of the class. 21:43
lizmat that is the idea, yes
thundergnat Util: I agree, it _should_ work 21:44
Util .minpairs *relies* on it working, since it cannot take a &by custom comparitor at call-time.
lizmat is still not sure what should work 21:45
Util From docs/announce: 21:46
2017.04.md:74: + Made Any.maxpairs/.minpairs use `cmp` and return Seq [5927186]
2018.06.md:54: + Made .minpairs/.maxpairs about 25% faster [788cda94]
2018.12.md:32: + Fixed semantics of `minpairs`/`maxpairs` (ignore undefined values) [7bf7a2c6] 21:47
Unfortunatly, I don't have working Docker Rakudo that far back.
Util There is a note in docs.raku.org/routine/cmp : "if $a eqv $b, then $a cmp $b always returns Order::Same." 22:00
but when I also specify a custom <eqv>, it does not get called.
lizmat Util: do you have a golf? 22:01
Util lizmat: just the one I posted shortly before you originally spoke: 22:03
thundergnat colabti.org/irclogger/irclogger_lo...07-28#l202
Util m: class L {has Str $.l}; my $c = 0; multi sub infix:<cmp> (L $a, L $b) { say "called {++$c} times"; $b.l cmp $a.l }; my @a = map {L.new: :l($_) }, <a b c a b c a>; @a .= sort; my $z = @a[0] cmp @a[1]; # Why is my custom cmp not called by .sort?
camelia called 1 times
Util Maybe relevant parts of Roast:
github.com/Raku/roast/blob/c07c5b9...eric.t#L69 22:04
github.com/Raku/roast/blob/c07c5b9...meric.t#L8
Util The golf of my actual use-case is: 22:06
m: class L {has Str $.l}; my $c = 0; multi sub infix:<cmp> (L $a, L $b) { say "called {++$c} times"; $b.l cmp $a.l }; my @a = map {L.new: :l($_) }, <a b c a b c a>; say @a.minpairs; my $z = @a[0] cmp @a[1]; # Why is my custom cmp not called by .minpairs?
camelia (1 => L.new(l => "b"))
called 1 times
lizmat Util: if you change the sort to "@a .= sort(&[cmp]);" it works 22:08
it will then use the infix:<cmp> known in that scope 22:09
I think this is actually one of the things that new-disp will fix
the &[cmp] that .sort sees, does not include your added candidate 22:10
I'm not sure whether that is actually a bug or not, but it *is* incovenient as hell :-)
Util I strongly view it as a bug. 22:11
lizmat testing some stuff now 22:13
Util I see a branch named `new-disp`, but I don't know it's history. Is there already a summary anywhere?
lizmat 6guts.wordpress.com/2021/04/15/rak...ispatcher/ 22:14
Util Oh, *that* one :^) Thank you. 22:17
lizmat ok, I have a fix, but it involves using CALLERS:: 22:22
and I'm pretty sure jnthn doesn't like that :-)
and it will affect performance for the "normal" case 22:23
codesections Util: does the &wrap workaround I suggested address your usecase? (ugly though it might be) 22:26
lizmat Util: have something that may fix this without too much performance loss for the common case 22:37
will make a PR for it tomorrow, as I would like to have more eyes on it
lizmat is now off to bed :-)
Util lizmat: Thanks! I will try to shore up my argument for how custom <cmp> should change the behaviours of other ops and methods. 22:39
Util codesections: I should not use it for this usecase (exhibition code), but would consider it for real-world, 22:41
if I saw how to actually use it to change the comparator;
`->|` does not give me access to $a&$b to do the real calculation, and `->$a, $b` errors.
Thanks for your efforts, though!
thundergnat, jdv: thank you for contributing! 22:42
codesections (I think you could capture the args in |c and then check if they're $a & $b, but that'd get even uglier and it sounds like there will be a better way soon) 22:43