🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
00:02 japhb left, japhb joined 00:12 brtastic joined 00:24 JRaspass left 00:27 japhb left, japhb joined 00:37 squashable6 left 00:39 squashable6 joined 00:49 neshpion left 00:53 frost-lab joined 00:58 pecastro left 01:11 guifa joined 01:15 lucasb left 01:54 mowcat left, gnufr33dom joined 01:55 frost-lab left 02:03 sortiz left 02:07 ________1 joined 02:09 _________ left 02:16 timlegge_ left 02:17 timlegge joined 02:20 kst joined 02:21 kst left 02:22 kst joined 02:39 brtastic left 02:41 kvw_5 joined 02:43 kvw_5_ left 03:11 Garbanzo joined 03:49 squashable6 left 03:51 wamba joined 03:52 squashable6 joined 04:17 wamba left 05:17 notable6 left, statisfiable6 left, bloatable6 left, squashable6 left, quotable6 left, bisectable6 left, linkable6 left, tellable6 left, sourceable6 left, evalable6 left, committable6 left, benchable6 left, unicodable6 left, nativecallable6 left, coverable6 left, releasable6 left, shareable6 left, greppable6 left 05:18 evalable6 joined, quotable6 joined, committable6 joined, linkable6 joined 05:19 notable6 joined, bloatable6 joined, releasable6 joined, bisectable6 joined 05:20 statisfiable6 joined, shareable6 joined, coverable6 joined, sourceable6 joined, tellable6 joined, nativecallable6 joined, squashable6 joined, benchable6 joined, unicodable6 joined, greppable6 joined 05:40 Benett joined 05:52 rindolf joined
japhb Is there an idiom for calling 'submethod TWEAK' for all *roles* composed into a class? Right now I've got a hack role that I compose into some class in my inheritance hierarchy -- role RoleTweaking { method TWEAK_ROLES(|c) { for self.^roles { my $method = .^lookup("TWEAK"); self.$method(|c) if $method; } } } -- and then call self.TWEAK_ROLES from that class's submethod TWEAK. 05:53
But that feels like a workaround for something I would expect to Just Work. 05:54
Plus there's no guarantee that I will remember to only call TWEAK_ROLES from *one* class in the hierarchy, unless I make some convention like only ever calling it from the base class -- but that means it will be called before any other class TWEAKs in the inheritance tree, even if the TWEAKed roles are only composed into a leaf class. 05:55
(Only ever calling it from *leaf* classes has the problem that leaf classes don't always stay that way -- inherit from one and forget it was once a leaf that called TWEAK_ROLES, and suddenly you're likely to call it twice again.) 05:56
05:58 frost-lab joined
japhb Ugh, it occurs to me that RoleTweaking has yet another problem -- it assumes that no class in the hierarchy only composed *ONE* other role, and thus called its TWEAK normally because it was composed in without conflict. 06:03
06:15 frost-lab left 06:25 ________1 is now known as _________ 06:41 frost-lab joined 07:00 kaiwulf left 07:03 db48x left
japhb After some more thought, it occurs to me that there's no conflict if role submethods have a name extension based on the role name. So for example: role Foo { submethod TWEAK-Foo { ... } }; role Bar { submethod TWEAK-Bar { ... } }. Then it is certain that these TWEAK-related submethods will not be called automatically, which means they can be called from a TWEAK_ROLES that looks up methods to call as 07:09
follows: for self.^roles { my $method = .^lookup('TWEAK-' ~ .^name); ... }
I suppose you could even do that with the class-defined TWEAK submethods, and then walk the .^mro and .^roles(:local) from each to force the whole thing to happen in C3 order. 07:11
Still really feel like I'm overthinking this though ....
07:15 frost-lab left 07:22 berber44 left 07:39 parabolize left 07:58 k-man left 08:13 frost-lab joined 08:26 berber44 joined 08:33 gnufr33dom left 08:39 jmerelo joined 08:51 k-man joined 09:10 frost-lab left 09:13 epony left 09:24 wbiker joined 09:25 Discipulus joined 09:40 Doc_Holliwood joined 09:42 elcaro left 09:44 elcaro joined 09:45 jmerelo left
wbiker Hello all 09:45
Anyone familiar with Test::Mock? I want to use a mock of a class where a method is called twice from the code under test. Is there a way to configure the returning that for each method call another string is given back?
This returns an array instead:
my $mock = mocked MyClass::Client, returning => { get => "Return String One", "Return String Two" };
09:56 epony joined 10:01 brtastic joined 10:04 jmcgnh left 10:22 Sgeo left, ensamvarg left 10:25 ensamvarg joined 10:35 nine_ is now known as nine 10:47 brtastic left 11:27 domidumont joined 11:35 wamba joined
CIAvash wbiker: in that line your'e saying that method `get` on `MyClass::Client` returns list `"(Return String One", "Return String Two") ` (should be in parens) 11:46
wbiker: I don't know what you're doing or how you're testing but you can do `my $strings = ("Return String One", "Return String Two").iterator; my $mock = mocked MyClass::Client, computing => { get => { $strings.pull-one }};` 11:47
wbiker Cool. Thanks @CIAvash I think that it what I was looking for. Using a iterator here! 11:49
12:00 leont joined 12:15 Black_Ribbon left 12:43 pecastro joined 12:45 xelxebar_ left 12:47 xelxebar joined 12:53 shlomif joined 12:55 rindolf left 12:58 shlomif2 joined 12:59 shlomif left 13:08 wamba left 13:19 mowcat joined 13:35 rindolf joined 13:43 wamba joined 13:52 mowcat left 14:03 xinming_ left 14:06 xinming_ joined 14:43 Doc_Holliwood left 14:46 a3r0 left 15:12 patrickb joined
uzl[m] m: .say for &comb.candidates>>.signature 15:39
camelia (Regex $matcher, Cool $input, $limit = *, :$match)
(Str $matcher, Cool $input, $limit = *)
(Int:D $size, Cool $input, $limit = *)
tellable6 2020-05-30T08:15:37Z #raku-dev <JJMerelo> uzl[m] OK, done, but please include closing statements in the PRs and/or commits you're doing for them in the future. 15:40
uzl[m] m: .say for &base.candidates>>.signature
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
base used at line 1
uzl[m] How do I get a method's candidates' signatures?
15:41 parabolize joined 15:43 gnufr33dom joined, vike left
uzl[m] m: .say for Real.^methods.first(*.name eq 'base').candidates>>.signature 15:44
camelia ($?CLASS: Int:D $base, $digits? is copy, *%_)
uzl[m] Oh found it haha
15:50 Doc_Holliwood joined
codesections can anyone explain these results? I'm confused: 16:01
m: use nqp; my int $a = 0; say nqp::isint(nqp::unbox_i($a)); say nqp::isint($a)
camelia 0
16:20 vike joined 16:23 neshpion joined 16:33 maggotbrain left 16:35 maggotbrain joined 16:54 Doc_Holliwood left 16:57 natrys joined 16:59 epony left 17:02 epony joined
MasterDuke it only work in real nqp-land 17:23
nqp: my int $a := 0; say(nqp::isint(nqp::unbox_i($a))); say(nqp::isint($a))
camelia 1
17:34 JRaspass joined 17:39 sena_kun left 17:40 sena_kun joined 17:52 gnufr33dom left 17:57 Altai-man_ joined, sena_kun left 18:09 Doc_Holliwood joined 18:14 berber44 left
xinming_ m: (<x y> => "test").raku.say; 18:18
camelia ("x", "y") => "test"
xinming_ m: Pair.new(:key(<x y>), :value<test>).raku.say; 18:19
camelia $("x", "y") => "test"
xinming_ How can we use Pair.new syntax to create a pair which the key is a List?
I mean, without the $() 18:20
summerisle m: Pair.new(:key<x y> :value<z>).key.WHAT
camelia ( no output )
summerisle m: Pair.new(:key<x y> :value<z>).key.WHAT.say
camelia (List)
summerisle m: Pair.new(:key<x y> :value<z>).key.say 18:21
camelia (x y)
summerisle m: Pair.new(:key(<x y>) :value<z>).key.WHAT.say
camelia (List)
summerisle m: Pair.new(:key(<x y>) :value<z>).key.say
camelia (x y)
summerisle seems fine to me
18:25 domidumont left, xinming_ left, xinming_ joined
xinming_ summerisle: What I mean is, the output should be the same as ("x", "y") => "test" :-) 18:26
18:26 Sgeo joined
uzl[m] m: Pair.new(:key(<x y>) :value<z>).key.raku.say 18:27
camelia ("x", "y")
uzl[m] m: Pair.new(:key(<x y>) :value("test")).key.say
camelia (x y)
summerisle on rakudo v2021.02, :key(<x y>) and :key<x y> (which should be directly equivalent) both seem to create a pair with a non-scalar key, so
i'd say it's working as you expect
codesections xinming_: you can use positional args: 18:28
m: Pair.new(<x y>, 'z').raku.say
camelia ("x", "y") => "z"
codesections MasterDuke: Thanks. I'd forgotten about *real* nqp land :D 18:29
18:45 __jrjsmrtn__ left 18:46 __jrjsmrtn__ joined 19:02 mowcat joined 19:05 maggotbrain left 19:07 maggotbrain joined 19:17 eseyman left 19:18 maggotbrain left 19:19 maggotbrain joined 19:21 eseyman joined 19:25 aborazmeh joined 19:31 jmcgnh joined 19:34 MasterDuke left 19:37 MasterDuke joined 19:47 MasterDuke left 19:50 MasterDuke joined 20:38 rindolf left 20:50 Doc_Holliwould joined, Doc_Holliwood left 20:51 Objective_Releas joined, aborazmeh left 20:52 Objective_Releas left 21:00 natrys left 21:03 neshpion left, neshpion joined
codesections m: sub f( --> (Int, Int)) { 42, 47 } 21:04
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed return value
at <tmp>:1
------> 3sub f( -->7⏏5 (Int, Int)) { 42, 47 }
21:04 aindilis left
codesections is there any way to dwim ^^^^? 21:04
21:06 pierrot_ is now known as pierrot, pierrot left, pierrot joined, patrickb left
codesections Or is that the usecase that needs to wait for lizmat's work on tuples? 21:08
21:13 xinming_ left 21:14 xinming_ joined
gfldex m: subset ListOfInt of List where { .all ~~ Int }; sub f( --> ListOfInt ) { 42, 47 } 21:24
camelia ( no output )
gfldex m: subset ListOfInt of List where { .all ~~ Int }; sub f( --> ListOfInt ) { 42, 47 }; f;
camelia ( no output )
gfldex m: subset ListOfInt of List where { .all ~~ Int }; sub f( --> ListOfInt ) { 42, 47 }; say f;
camelia (42 47)
gfldex codesections: ^^^ you can make the subset as strict as you need
codesections Hmmm, yeah. But that's not really in the spirit of what I want -- `f(--> Int)` is a constraint, but it's also using types as concise API documentation that &f always returns a single Int. I'd like to be able to say "f always returns a pair of two Ints" in the type system, but that's only worth doing if the syntax is there to say it naturally 21:29
but thanks, gfldex, that's helpful & appreciated 21:31
gfldex codesections: subsets can be exported. That way you can allow the user of your API to use them in their code. This can be quite helpful to avoid typos and bad copy pasta. 21:42
codesections Yeah, I get that :-) And I like and use subsets
But that's a different usecase than "function signature as documentation" 21:43
(though with some overlap, to be sure)
21:52 kaiwulf joined 21:53 xinming_ left 21:54 xinming_ joined 22:02 tejr left 22:03 tejr joined 22:09 neshpion left 22:10 neshpion joined 22:28 finsternis joined 22:30 gnufr33dom joined 22:38 aindilis joined 22:39 kerframil joined 22:45 xinming_ left
lizmat codesections: I don't think this has anything to do with my Tuple module ? 22:45
22:46 xinming_ joined
codesections Oh, ok. I wasn't sure/haven't followed that module closely. In some languages, you'd say that a function with the signatur of f(Int --> (Str, Int)) "takes an Int and returns a Tuple of one Str and one Int". So I was wondering if better support for tuples would be related somehow. But I guess my guess was wrong :) 22:49
lizmat I guess my Rake module gets closer to that 22:54
modules.raku.org/dist/Rake 22:55
22:55 dogbert17 joined 22:56 dogbert11 left 23:03 zolferino joined, zolferino left
guifa Oof 23:17
One good thing about me now creating all of these moduels based around the CLDR is I’m finding how some of my earlier modules sucked :-)
Namely the LanguageTag which needs … a lot of work
23:25 neshpion left 23:30 Altai-man_ left, xinming_ left 23:31 xinming_ joined 23:33 sena_kun joined
codesections .tell vrurg I just had my first occasion to use the new COERCE method, and it's *really* nice. Thanks for your work adding that :) 23:46
tellable6 codesections, I'll pass your message to vrurg
23:46 neshpion joined
vrurg codesections: you're welcome! :) 23:46
23:46 gnufr33dom left
vrurg can't still believe it all started as a fix for an old github issue... 23:47
23:50 pecastro left