🦋 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.
perryprog Oh my goodness... how have I not seen this: www.ozonehouse.com/mark/periodic/ 02:23
immediate hi, why doesn't `substr` without arguments fail directly but hang 07:33
immediate m: "this".substr 07:33
camelia MoarVM panic: Memory allocation failed; could not allocate 157600 bytes
immediate isn't the first parameter mandatory 07:34
moon-child immediate: looks like bug 07:34
j 07:35
found the culprit. Cool.substr with no args forwards to Str.substr with no args, but that is not a thing 07:39
github.com/rakudo/rakudo/pull/4544 PR'd fix 07:43
moon-child (actually I'm kinda surprised it OOM'd. Guessing there's no TCO to mmaintain tracebacks?) 07:45
immediate moon-child: thanks for the fix :d 07:46
immediate But `"this"` is already a string why that method should be called? 08:11
m: say "this".^mro
camelia ((Str) (Cool) (Any) (Mu))
immediate ah okay because there is no matching candidate in Str's methods, sorry 08:14
moon-child Str does Cool, for obvious reasons. Str defines a number of substr candidates, all of which take one or two parameters. Cool defines substr candidates of one and two parameters, which look like: multi method substr(Cool:D: \x) { self.Str.substr(x) }. Normally those will never get selected for an actual Str, but for an Int, it is converted to a Str and substr is called on the resulting Str
oh you got it...ninja'd! 08:15
immediate :d
lizmat the problem is the missing Str.substr candidate.... fixing now
moon-child oh, there _should_ be a zero-argument Str.substr?
what's it do, return self?
moon-child m: proto f(|) returns Int {*}; multi f($x) returns Str { ';o' }; say f 5 08:17
camelia ;o
moon-child why is ^^ legal?
lizmat moon-child: I'd say that should be a compile time error 08:18
moon-child yeah. But even if not compile time, why not run time? 08:19
(and still passes if I leave off the return type on the multi candidate--it's not inherited from the proto. Should I file a bug report?)
lizmat moon-child: pretty sure it will be a run-time error if you make the proto something other than {*} 08:21
moon-child what else can I make it that lets the other candidate run? 08:23
hmm, docs.raku.org/syntax/proto has examples with multis returning something other than the proto. So intended maybe? 08:25
lizmat m: proto foo(--> Int) { say "foo"; {*} }; multi foo(--> Str) { "bar" }; foo()
camelia foo
Type check failed for return value; expected Int but got Str ("bar")
in sub foo at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat moon-child: I think the problem is that the compiler assumes it can ignore the proto if it only consists of {*} 08:26
moon-child that makes sense! 08:29
moon-child anyway ix.io/3Au6/perl6 demonstration of multis being less dangerous than methods 08:30
though hmmm, it works if I make it a multi method! 08:31
however that requires the child class to declare it as a multi method. So it is easy to bypass. You can't express the constraint entirely in the parent role 08:32
lizmat moon-child: please make an issue for the proto / multi return constraint you found 08:43
moon-child done! I assume the class method behaviour is intentional? 08:46
Voldenet m: say (20/3) div 2 18:34
camelia Cannot resolve caller infix:<div>(Rat:D, Int:D); none of these signatures match:
(Int:D $a, Int:D $b --> Int:D)
(int $a, int $b --> int)
in block <unit> at <tmp> line 1
Voldenet m: multi sub infix:<div> { ($^a - $^a % $^b) / $^b }; say (20/3) div 2
camelia 3
Voldenet I wish it was already defined
melezhik . 18:36
tellable6 2021-09-29T23:37:04Z #raku <tbrowder> melezhik try Inline::Perl5 with Perl modules from GraphicsMagick
melezhik tbrowder thanks 18:37
hi! I have started to test a water with open source project contest on mybfio, not sure if it matches Raku as current eco system is still not big, anyway here is the link - mybf.io/contest 18:38
I'd appreciate for comments
[Coke] 4 19:19
chloekek m: say ‘哈’ x 10 21:46
camelia 哈哈哈哈哈哈哈哈哈哈