This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
01:02 teatime joined 01:04 teatwo left 01:06 teatwo joined 01:07 teatime left 01:16 tea3po joined 01:20 teatwo left 02:20 MasterDuke left 05:51 hudo left, hudo joined 07:51 dakkar joined 10:17 hudo left 10:33 hudo joined
rcmlz What Regular Expression would match "all arbitrary strings that contain at most one digit"? Actually im am building a regex for "all arbitrary strings that contain any None-Number-Sting except Spaces, but at least two numbers" raku /<:!Number - :Space_Separator> || <-[<:Number>]>** 2..* / 12:08
so my second part is wrong. I do not know how to negate 12:09
e.g. I need "12ab45 45" => True, "1" => True, "12" => False, "1 2" => False``` 12:13
Found a solution: raku / <:!Number - :Space_Separator> || ^^ <:!Number>* <:Number>? <:!Number>* $$ / 13:35
16:39 dakkar left 17:22 avuserow left 17:23 avuserow joined
Tirifto I’ve run into this error message with a multi subroutine of mine: ‘Circularity detected in multi sub types’. Does anyone know what exactly it means? `o` 17:30
librasteve nope - but if you post all the candidates we can take a look for any snags 18:56
Tirifto @librasteve, I have posted the code in question here: tirifto.xwx.moe/d/raku-circular-er...ample.html 20:02
It’s not runnable since the custom module is missing, but I could extract the relevant parts thereof, too, if that helps. 20:04
librasteve consider this 20:26
m: role X {}; role Y {}; class X::Y does X does Y {}; my $z = X::Y.new; say $z ~~ X; say $z ~~ Y;
Raku eval True True
librasteve the multi signatures are smartmatching to File or Directory, however both File and Directory smartmatch to In ... so when you present the multi with a File::In, my premise is that it will try to smartmatch to File::In first (both are False) and then it will try to walk up the tree and smartmatch the parents - on one branch that's either File or In and on the other that's either Directory or In ... and so 20:31
there is a tie since both multis match In ... admittedly the error message is LTA
you could test this thesis by replacing multi sub recurse(File $node, Code $code) { $code($node) } with multi sub recurse(File::In $node, Code $code) { $code($node) } 20:33
does that fix the error? 20:34
oh sorry - I see that the bottom part of your snippet you have done exactly that - so I rest my case 20:35
my first guess at how to fix this is to make the multi sigs use coercion types like this: 20:45
20:45 cleo left
multi sub recurse(File() $node, Code $code) { $code($node) } multi sub recurse(Directory() $node, Code $code) { ... } 20:45
Tirifto @librasteve Hmmm… I’m not sure I follow the logic. File::In does File and does In, but File and In have no relation otherwise. The multi (with either signature) shouldn’t care if the argument matches In or not; it should only care if it matches File (or Directory), right? And I’m not aware of any object possibly matching both of those. :o 20:47
librasteve does any candidate smartmatch File::In? answer = neither does [File::In is not the same as File, nor is it the same as Directory] 20:49
so, in the absence of an initial match, the despatcher walks up the declaration of File and Directory and tries to match their parents - namely File and In and Ditrectory and In 20:51
now it matches both sides since File::In matches In on both sides 20:52
it's a bit of an obscure situation --- one certain fix is to have your multi signatures test all four case File::In, File::Out, Directory::In, Directory::Out ... if you have a much larger number of variations then you can use subsets and samewith to slice up the space ... but I dont think that's worth the bother for 4 variations 20:56
Tirifto I’ll probably end up doing that… but I’d still like to wrap my head around this. `o` 20:57
The dispatcher tries to match the (type of the) argument against the type given in the signature, right?
librasteve sure ... 20:58
Tirifto Or rather… my understanding of the dispatch is that it should check if the argument’s type is the same as any of the multi’s types. If it is, that multi is called. And if it isn’t, the parents of the argument’s types should be checked against the multi’s types. Is that how it should work? :o 21:00
(The parents being the parent classes and the roles, I suppose.) 21:02
librasteve that's what I am saying too
BUT File::In does NOT match File exactly, so both sides of the multi are checking parent matches 21:04
at the parent level File::In matches both multis because File does In and Directory does In 21:05
thus the error 21:06
Tirifto But File (the role) does not do In (the role). File::In (the class) does both File (the role) and In (the role) directly. :o 21:08
For what it’s worth, File and Directory (both roles) each carry the class Node. So File::In could match against that. `o` 21:11
(Assuming the dispatcher checks for that.)
librasteve your are checking if File::In (the class) matches File (a type derived from the role) - it is not an exact match ... so the dispatcher checks the parents 21:12
since File::In does File - good you have a match at the parent level, BUT since File::In does In and Directory::In does In then BOTH multis match the In-ness of FIle::In so there is an error 21:14
anyway --- that's my interpretation of what is going on --- does my coercer guess fix the problem? 21:15
this is my best understanding given the example ... perhaps it would be more definitive to read the source or have one of the core folks that understand the dispatcher design chime in --- I am always happy to learn more 21:17
sorry getting late.... afk
Tirifto But it shouldn’t try to match the In-ness, since neither of the signatures refers to the role In in any way. `o` Well, good night, I’ll try the coercer fix! 21:18
Nope, still running into circularity. I’ll go with the ::In ::Out duplication. 21:21
Thanks a lot for the help and patience!
Alright, I think I understand what’s going on… but still not why. 21:40
m: class C {;}; role R is C {;}; role S is C {;}; say R ~~ S; say S ~~ R;
camelia False
False
Tirifto Oh. On my installation that prints «True␤True␤». cx 21:41
So the one time I can’t check my code with camelia it’s probably a bug that’s been fixed in a recent version. xP 21:42
I’m running Rakudo v2022.12 from Debian’s repositories. I’ll try to grab a fresh version and see if that fixes the problem! 21:44
ikarus13 What kind of webframework/stack would you be using for a simple Web application? I found Humming-Bird and Cro. So far I have tried Humming-Bird and it seems to work. Is this the way to go? What kind of templating would one use? Template::Mojo? 21:49
dev.to/rawleyfowler/how-i-like-to-...jects-50nm 22:20
22:52 DarthGandalf left 22:53 DarthGandalf joined
Tirifto @librasteve Okay so the code works with Rakudo v2024.03. In my old version (v2022.12), two roles matched if both of them carried the same class, so what probably happened was that File matched Directory, since both File and Directory carried the class Node. Now everything makes sense. x) 23:23