🦋 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: ... | Logs can be inspected at colabti.org/irclogger/irclogger_log/raku
Set by lizmat on 1 May 2021.
oddp calling foo('12') for this recurses endlessly: multi sub foo($x) { foo($x) }; multi sub foo(Int $x) { $x }; 00:00
back to 'where /\d+/' it is i guess
00:02 reportable6 left, reportable6 joined
moon-child I wonder if multi sub foo(Int() $x) would work 00:04
m: multi sub foo($x) { say 1 }; multi sub foo(Int() $x) { say 2 }; say foo '5'; 00:05
camelia Ambiguous call to 'foo(Str)'; these signatures all match:
(Int(Any) $x)
in block <unit> at <tmp> line 1
moon-child nope
00:15 rindolf joined
ugexe multi sub foo($x) { foo($x) }; 00:16
where could this dispatch to with foo("12")?
you could use `multi sub foo($x) { nextwith($x) };` but again... what would it dispatch to when the only other candidate requires Int (12) not Str ("12")? 00:18
oddp man, just realized that your example from above works with <1 0> because that produces a IntStr list where as i am using regular str lists 00:50
00:51 lucasb left
oddp well, well, sorry for wasting everyone's time, but i guess i better stick to ruby for now. my brain simply hasn't enough folds for raku 00:52
00:55 oddp left
moon-child eh ruby doesn't even have multiple dispatch, does it? :P 00:55
could just avoid multis
01:37 |Sno| joined, db48x left 01:38 [Sno] left 01:39 kvw_5_ joined 01:42 kvw_5 left 02:02 frost-lab joined 02:29 dataange` left 02:34 clarjon1 left 03:16 parv joined 04:16 bisectable6 left, bloatable6 left, statisfiable6 left, unicodable6 left, benchable6 left, shareable6 left, committable6 left, squashable6 left, coverable6 left, greppable6 left, notable6 left, releasable6 left, linkable6 left, quotable6 left, tellable6 left, sourceable6 left, reportable6 left, nativecallable6 left, evalable6 left, bloatable6 joined 04:17 bisectable6 joined, benchable6 joined, evalable6 joined, squashable6 joined, unicodable6 joined, tellable6 joined, quotable6 joined 04:18 committable6 joined, releasable6 joined, greppable6 joined, notable6 joined, sourceable6 joined, shareable6 joined, statisfiable6 joined 04:19 reportable6 joined, coverable6 joined, nativecallable6 joined, linkable6 joined 04:51 pounce_ is now known as pounce 05:34 parabolize left 05:45 neshpion left 06:01 reportable6 left 06:03 reportable6 joined 06:30 Sgeo_ left 06:38 ufobat_ joined 06:39 domidumont joined, dogbert17 left 06:41 dogbert17 joined 06:44 dogbert11 joined 06:45 mtsd joined 06:46 abraxxa1 joined 06:47 dogbert17 left 06:51 abraxxa1 left, abraxxa1 joined 06:53 squashable6 left 06:54 brtastic joined 06:55 pat_js left 06:57 squashable6 joined 07:11 mtsd left 07:17 brtastic left 07:18 brtastic joined 07:27 ufobat joined 07:29 epony left 07:52 wamba joined 07:54 dakkar joined 08:11 DiffieHellman left 08:12 DiffieHellman joined 08:18 pecastro joined 08:35 aindilis left, aindilis joined 08:45 brtastic left 08:49 brtastic joined 08:51 rindolf left 08:55 Altai-man_ left 08:57 sena_kun joined 09:09 epony joined 09:11 dogbert17 joined 09:15 dogbert11 left 09:16 |oLa| joined 09:18 |oLa| left 09:28 brtastic left, brtastic joined 09:55 wamba left 09:58 wamba joined 10:01 |oLa| joined 10:04 |oLa| left 10:17 dogbert11 joined 10:19 squashable6 left 10:20 squashable6 joined, dogbert17 left 10:25 dogbert17 joined 10:28 dogbert11 left 10:41 |oLa| joined 10:42 |oLa| left 10:48 rindolf joined 11:02 MasterDuke joined 11:07 dogbert17 left, dogbert17 joined
Geth doc: 4cb25dbd56 | (Suman Khanal)++ (committed using GitHub Web editor) | doc/Language/py-nutshell.pod6
Example in raku not working as expected

The last example
   my $list1 = (1, "two", 3, "hat");
   my $list2 = (5, 6, "seven");
... (22 more lines)
linkable6 Link: docs.raku.org/language/py-nutshell
Altreus Was there any further discussion on my ancient question about why we have "multi" when its omission unnecessarily restricts extension? 11:42
Can it not be inferred/ 11:43
11:44 MasterDuke left, MasterDuke joined
moritz requiring "multi" allows to catch accidental re-definition of only subs 11:46
12:02 reportable6 left 12:04 reportable6 joined
Altreus then why not require only instead? 12:19
it also prevents you from intentionally re-defining subs that were not set up to do so 12:20
Which is a problem when you don't own the original
Adding another option for a procedure is good design, in my opinion, and should be encouraged 12:21
Therefore, preventing it by default is bad
multi should be the default
codesections Altreus: IMO, there's a bit of a library/application distinction. When writing _library_ code, I agree that it's best to default to multi for the reasons you say. But in end-user code (esp. scripts) it seems like "only" is a good default (it simplifies the mental model and restricting extension is less of an issue) 12:25
and since library authors tend to be more experienced, I'm ok with having the literal default be the one that fits application code, and asking library authors to opt in 12:26
moritz also, only subs are easier to learn for the beginner 12:27
codesections (esp. since `multi f` is only slightly longer than `sub f` -- though that doesn't apply to methods)
moritz: yeah, that's a more direct way of putting what I meant by "it simplifies the mental model" :D 12:28
Altreus So can you add a multi method to a subclass of a class that doesn't define the original as multi? 12:42
Maybe you can override the multi-ness of the existing one?
m: class A { sub a ($x) {} }; class B isa A { multi sub a ($x, $y) {} }; 12:43
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse class definition
at <tmp>:1
------> 3class A { sub a ($x) {} }; class B is7⏏5a A { multi sub a ($x, $y) {} };
expecting any of:
Altreus er
m: class A { sub a ($x) {} }; class B is A { multi sub a ($x, $y) {} };
camelia ( no output )
Altreus m: class A { sub a ($x) { say $x } }; class B is A { multi sub a ($x, $y) { say "$x ... $y"} }; my $b = B.new; $b.a("A"); $b.a("A", "B") 12:44
camelia No such method 'a' for invocant of type 'B'
in block <unit> at <tmp> line 1
Altreus m: class A { method a ($x) { say $x } }; class B is A { multi method a ($x, $y) { say "$x ... $y"} }; my $b = B.new; $b.a("A"); $b.a("A", "B")
camelia Cannot resolve caller a(B:D: Str:D); none of these signatures match:
(B: $x, $y, *%_)
in block <unit> at <tmp> line 1
Altreus you what
codesections you'd need to add a bit of code to re-dispatch to parent when it doesn't match
Altreus OK then I object to that :) 12:45
this is anti-DWIM
codesections fair
Altreus I'm happy it let me redefine it - I expected an error there 12:52
Although the actual error is worse :D
lizmat m: class A { method foo() { dd } }; class B is A { proto method foo(|) {*}; multi method foo() { dd; nextsame } }; B.foo 13:02
camelia method foo(B: *%_)
lizmat you can use a proto
however, the proto will prevent you from doing nextsame and friends 13:03
Altreus: is that a problem ?
if so, you could do something like;
class A { method foo() { dd } }; class B is A { my constant &a = B.^find_method("foo"); proto method foo(|) {*}; multi method foo() { dd; a(self) } }; B.foo 13:05
evalable6 method foo(B: *%_)
method foo(A: *%_)
lizmat aka, save the previous dispatch chain in a constant (at compile time) *before* the new proto is added 13:06
and refer to that to go up the dispatch chain again
hmmm...self.&a() instead of a(self) probably
codesections and that foo method could be `multi method foo(|)` to come after all your own foos, right? 13:07
lizmat if I understand your question correctly, yes :-) 13:08
13:08 mowcat joined
Altreus I dunno if that's a problem because I'm yak shaving 13:21
But it does seem like a problem if someone provides a class and I have to jump through hoops to extend it
Raku has enough gotchas
lizmat well, most of them in the core have been fixed I think for the publicly accessible methods 13:22
but please correct me if I'm wrong :-)
Altreus I was more thinking about community modules 13:23
Everyone would have to make everything multi just in case
lizmat in any case, I think this was a deliberate decision at one point by @Larry
yeah, that's the consequence of this
Altreus I wonder what the rationale is
lizmat I wonder if newdisp / RakuAST would make changes to this more easy
Altreus Because the outcome is heckin' inconvenient
codesections yeah. But my argument is that it's easier to have best practices for modules than user code 13:24
lizmat moritz was around then, maybe he can shed some light
codesections it feels like it's in the spirit of "torture the implementer", in that it puts a little extra burden on module authors to simplify things for end users 13:25
13:25 parabolize joined
Altreus Seems like a pull request engine to me 13:26
Although with a workaround at least it's not showstopping
lizmat also: with B.can("foo").head it's less meta-oppy 13:27
instead of .^find_method
afk for a few hours& 13:30
Geth doc: sumanstats++ created pull request #3882:
Fix tuple-like structure in Raku
13:30 frost-lab left 13:46 dogbert17 left 13:47 dogbert17 joined
Geth doc: 1fe9282577 | (Suman Khanal)++ (committed by Juan Julián Merelo Guervós) | doc/Language/py-nutshell.pod6
Fix tuple-like structure in Raku

Do a minimal change as suggested in github.com/Raku/doc/commit/4cb25db...36b73da106
linkable6 Link: docs.raku.org/language/py-nutshell
14:10 squashable6 left 14:12 squashable6 joined 14:17 DiffieHellman left 14:18 DiffieHellman joined, wamba left 14:24 Sgeo joined 14:32 dogbert17 left, dogbert17 joined 14:35 ufobat__ joined 14:39 ufobat_ left, ufobat left, ufobat_ joined 14:41 parv left 14:43 antononcube joined
antononcube HI! I asked this question yesterday, but got disconnected, so I do not know about any responses... I wonder should I use Math::Matrix or Math::Libgsl::LinearAlgebra. Has anyone used Math::Matrix for non-trivial matrix computation workflows? 14:45
14:53 kini left 14:57 brtastic left 14:58 kini joined 15:07 wamba joined 15:14 antononcube left 15:23 neshpion joined 15:27 lucasb joined
codesections I haven't, sorry (I know that's not helpful, but I wanted to make sure you know that we're not ignoring the question!) 15:37
15:38 antononcube joined 15:42 wamba left 15:46 dogbert11 joined 15:50 dogbert17 left 15:53 neshpion_ joined 15:55 neshpion left, neshpion_ left
lizmat antononcube: I think I would investigate using Math::Libgsl::LinearAlgebra girst 15:56
15:56 neshpion_ joined
lizmat *first 15:56
15:56 neshpion_ is now known as neshpion 16:03 antononcube left 16:34 dakkar left 17:00 finsternis left 17:03 dogbert11 left 17:04 dogbert11 joined 17:08 domidumont left 17:24 brtastic joined 17:34 dogbert11 left 17:35 dogbert11 joined 17:42 dogbert11 left 17:46 Kaiepi left, Kaiepi joined, dogbert11 joined 17:48 dogbert17 joined 17:50 |Sno| left 17:51 dogbert11 left 17:57 dogbert17 left 17:58 rindolf left, dogbert17 joined 18:00 brtastic left 18:02 reportable6 left 18:04 ufobat_ left, reportable6 joined, ufobat__ left
lizmat . 18:11
18:23 ufobat__ joined, ufobat_ joined 18:26 dogbert11 joined 18:28 dogbert17 left 18:36 patrickb joined 18:38 dogbert17 joined 18:39 wamba joined
Geth doc: 294096359d | Coke++ | doc/Language/py-nutshell.pod6
linkable6 Link: docs.raku.org/language/py-nutshell
18:41 dogbert11 left 18:53 aluaces left 18:56 Kaiepi left, Kaiepi joined 19:02 brtastic joined
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2021/05/10/2021-...-beta-pod/ 19:03
19:07 aluaces joined
eseyman No!!!! Not another one! 19:12
19:27 ufobat_ left, ufobat__ left
patrickb lizmat++ 19:39
19:54 |Sno| joined 21:04 patrickb left 21:15 parv joined 21:16 neshpion left 21:31 MasterDuke left 21:32 MasterDuke joined 21:42 abraxxa1 left 21:48 abraxxa1 joined
Geth doc: da1f28ba08 | (Stoned Elipot)++ | doc/Type/Num.pod6
Use code formatting
linkable6 Link: docs.raku.org/type/Num
21:57 abraxxa1 left 21:58 abraxxa1 joined 22:21 abraxxa1 left, wamba left 22:22 brtastic left, brtastic joined 22:29 |Sno| left 22:33 abraxxa1 joined 22:37 abraxxa1 left 22:38 abraxxa1 joined 22:42 dogbert11 joined 22:46 dogbert17 left 22:54 pecastro left 23:03 |Sno| joined 23:11 brtastic left 23:12 |Sno| left 23:13 abraxxa1 left 23:19 Kaiepi left 23:20 Kaiepi joined 23:23 b2gills left 23:29 |Sno| joined 23:44 b2gills joined