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:44 deoac joined
deoac What's the advantage to using samewith() instead of the name of the multi sub? 01:46
MasterDuke that's a good question. i believe samewith() bypasses multi-dispatch. so if you just call the sub again with new arguments, you could end up in a new multi, but samewith (i believe) will call the exact multi it's in 01:49
obviously you may or may not want that. but samewith gives you the option 01:50
well. ^^^ sounded good. but... 01:54
m: multi sub a(Int $b) { say "got Int $b" }; multi sub a(Str $c) { say "Str $c"; return if $c eq 2; samewith($c.Int) }; a(2); a("2.2")
camelia got Int 2
Str 2.2
got Int 2
deoac I don't understand "you could end up in a new multi".  Could you please give me an example? 01:58
MasterDuke well, what i ran just did. samewith in the Str multi ended up calling the Int multi 01:59
i thought it would end up calling the Str multi again and failing because of the wrong type 02:00
oh, but samewith would allow you to use anonymous recursive multis more easily 02:03
deoac How can you have anonymous multi-dispatch? 02:06
MasterDuke hm. the 'multi' there was a but too much 02:08
m: sub (Int $a) { say "Int $a"; return if $a < 1; samewith($a - 1) }(3) 02:09
camelia Int 3
Int 2
Int 1
Int 0
MasterDuke m: sub (Int $a) { say "Int $a"; return if $a < 1; &?BLOCK($a - 1) }(3) 02:10
camelia Int 3
Int 2
Int 1
Int 0
MasterDuke m: sub (Int $a) { say "Int $a"; return if $a < 1; &?ROUTINE($a - 1) }(3)
camelia Int 3
Int 2
Int 1
Int 0
MasterDuke TMTOWTDI
deoac Ah, I see now!  Thank you. 02:12
MasterDuke np 02:16
02:22 deoac left 07:39 ab5tract left 07:54 dakkar joined 07:56 Manifest0 joined 08:23 teatwo joined 08:24 teatwo left, teatwo joined 08:25 teatwo left 08:26 teatwo joined, tea3po left
lizmat fwiw, I think samewith was a mistake (and mine) 08:41
nemokosch There are some other languages that support recursion without typing the function name 08:55
If really all it does is to trigger a new call for the same function or method, it shouldn't be too bad, right? 08:56
lizmat It's slightly more involved than that 08:58
e.g. in the case of a method, it will need to obtain the invocant
nemokosch That makes sense anyway 08:59
What I can offer for comfort (actually, probably rather discomfort), is an actual hard mistake instead 09:00
The multi resolution rules are not transparent
Last time I was messing around in the core to fix that Range bug, at first I managed to rearrange the order of two candidates I didn't even modify 09:02
This should probably never happen for starters but to make it worse, I found nothing about the rules
10:32 ab5tract joined 11:34 teatwo left 11:35 teatime joined 12:55 jgaz left 12:56 jgaz joined 16:34 dakkar left 20:57 ab5tract left 20:58 ab5tract joined 22:33 Util left 22:35 Util joined 23:24 Manifest0 left 23:37 teatime left 23:38 teatime joined 23:52 teatwo joined 23:55 teatime left