🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
ab5tract m: my @z = <a b c> Z <x y z>; dd @z[*;0], @z[*;1] # another alternative 00:01
camelia ("a", "b", "c")
("x", "y", "z")
ab5tract Sometimes I worry that the sheer number of different approaches can be more harmful than helpful 00:02
m: my $z := ("a"..*) Z ("A"..*); sub some-of-inf($until, Positional $z) { $z[0..$until;0], $z[0..$until;1] }; dd some-of-inf(555, $z) 00:09
camelia (("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj", "ak", "al", "am", "an", "ao", "ap", "aq", "ar", "as", "at",…
00:18 greaser|q left, greaser|q joined 00:19 greaser|q is now known as GreaseMonkey 00:30 wayland76 joined 00:31 wayland left 00:57 guifa left 00:58 guifa joined
guifa there might be lots of solutions but I think the most common time people want to use it is when it's being used for iteration in for loops, and for @a Z @b -> ($a, $b) { ... } works rather nicely 01:00
(and in fact was so designed)
ab5tract to be clear, I'm not advocating for fewer solutions :) 01:10
01:14 kylese left 01:15 kylese joined
wayland76 Question: What's up with the old-issue-tracker repo? Are there plans that these bugs will be fixed, or do we have to re-lodge the bugs if we want them fixed? 01:17
Voldenet github.com/Raku/problem-solving/bl...ng-Plan.md 01:24
I think the plan was to move them 01:25
wayland76 Interesting -- that plan has been fully executed, but the status of the tickets is not clear. 01:26
The plan says that a) we move them to the perl6 org, then move out any tickets that aren't related to rakudo, then b) we move the remaining tickets into rakudo/old-issue-tracker 01:27
That's all been done, but it doesn't say whether those tickets will be seen/addressed at all. 01:28
And I note that the ones I've looked at don't have any participants at all, so if I comment on them, those comments will be seen by no-one. 01:30
Voldenet I'd say it'd be best to add a new issue in with a reference to the old one 01:34
otherwise practically nobody will look at them
wayland76 Yeah, that was my guess -- I just thought maybe there was a cleanup plan or something.
Oh! My bad! The Perl6 org was probably renamed to Raku. So that plan was never finished -- they/we never moved the remaining tickets to the rakudo org (and may never have moved out the tickets that *aren't* related to Rakudo) 01:43
02:15 kylese left, kylese joined 02:30 kylese left 02:34 kylese joined
guifa ah how about this 02:49
sub V (@x) { class Alt does Iterator { has $.i; has @.x; method pull-one { @!x.is-lazy || (@!x > $!i) ?? @!x[$!i] !! IterationEnd andthen ($!i += 2 and .return); } }; return Seq.new(Alt.new: :@x, :0i), Seq.new(Alt.new: :@x, :1i) }; say V <a x b y c z>; say V ^Inf 02:52
evalable6 ((a b c) (x y z))
((0 2 4 6 8 10 12 14 16 18 20…
guifa, Full output: gist.github.com/32eb5d1a8524a3260f...5551d7c904
ugexe I wrote a draft of a blog post I'll probably never get around to publishing about what I consider lesser known best practices for your META6.json files - gist.github.com/ugexe/e93a5d28815b...dd95e2d8ac 03:24
06:08 abraxxa-home joined 06:20 abraxxa-home left 06:22 abraxxa-home joined 06:33 Sgeo left 06:51 camelia left 06:52 nine left 06:59 camelia joined 07:03 nine joined 07:38 sena_kun joined 07:45 sena_kun left 07:51 sena_kun joined 07:52 derpydoo joined 07:55 sena_kun left 09:36 derpydoo left
wayland76 Does anyone know how you get a reference to a method? I'm wanting to wrap a proto, and try calling *all* matching candidates for a routine, not just the first one that matches. 09:58
10:02 Chanakan left
ab5tract wayland76: I *think* the most idiomatic way to do that is to re-dispatch with `callsame` 10:05
m: class C { multi method m(Str $a where *.comb == 3) { say "most"; callsame }; multi method m(Str $a) { say "middle"; callsame }; multi method m(Any $a) { say "least"; callsame } }; C.m("abc")
camelia most
middle
least
wayland76 Yeah, I know I could do "callsame" in each one, but I'm trying to do like Prolog does and match all the items, so that I could make a parent class, and all the child classes could just declare their multis, and know that all of them were going to be called, and they'll get an array of all the return values. 10:10
Ultimately I'd like to make a Slang with an alternative to "method" that calls all the candidates, but one step at a time :) . 10:11
Incidentally, I think I found the answer (run this in TWEAK): self.^method_table()<fatherOf>.wrap: method (Signature $signature) { 10:18
Maybe not the best, but it seems to work :)
10:21 derpydoo joined
ab5tract ah, nice :) 10:24
10:34 bdju left 10:36 bdju joined
wayland76 Does anyone know how, when creating a Signature class ( docs.raku.org/type/Signature#Runti...and_later) ) it's possible to tell it to return nothing? 11:10
lizmat --> Nil
aka: returns => Nil 11:11
should probably be documented there
wayland76 Hmm. I'm also getting it trying to return a literal Nil when I print the signature after. 11:12
If I can't figure it out in a few minutes, I'll post a gist.
lizmat m: sub a(--> Nil) { }; dd a
camelia Nil = Nil
lizmat yes that will return it, and Nil can be taken a sign for the optimizer to do various optimizations if in void context 11:13
wayland76 m: 'my $s = Signature.new(returns => Nil); say $s.raku; 11:14
camelia ===SORRY!=== Error while compiling <tmp>
Unable to parse expression in single quotes; couldn't find final "'" (corresponding starter was at line 1)
at <tmp>:1
------> nature.new(returns => Nil); say $s.raku;⏏<EOL>
expecting …
wayland76 m: my $s = Signature.new(returns => Nil); say $s.raku;
camelia :( --> Nil)
wayland76 Also, when one is creating a signature for a method, how does one create the special first parameter that's an object specifier 11:17
lizmat ah, good question, I actually wouldn't know 11:18
I guess with a Parameter named "self" ? 11:19
wayland76 Oh, nice idea! I'll try that.
m: class Foo { submethod TWEAK { my $s = Signature.new(params => (Parameter.new(name => q"self", type => "Foo"), Parameter.new(name => q"$param"))); say $s.raku; } } ; my $f = Foo.new() 11:27
camelia :(Foo sself, Any $param --> Mu)
11:27 derpydoo left
lizmat wonder whether that's LTA in the .raku or really an issue with the name? 11:28
wayland76 m: class Foo { submethod TWEAK { say self.^method_table()<foo>.signature }; method foo($a, $b) {} }; my $f = Foo.new() 11:30
camelia (Foo: $a, $b, *%_)
wayland76 For comparison
The one you didn't know -- was that why it returns Nil, or was that the one about the special first parameter? 11:35
lizmat special first parameter
wayland76 OK, thanks! Any idea why I got the results I did (at 14 past the hour) where it returned Nil? 11:37
11:37 rir__ joined 11:41 rir_ left
ab5tract wayland76: the one at 14 past was due to an unbalanced starting Quixote character 11:49
s/Quixote/quote/
Ah, never mind you fixed that :) 11:50
m: my $s = Signature.new(returns => Nil); say $s.raku;
camelia :( --> Nil)
ab5tract Is this what you were referring to?
Aedil $foo = "bar"; 11:55
m: $foo = "bar";
camelia ===SORRY!=== Error while compiling <tmp>
Variable '$foo' is not declared. Perhaps you forgot a 'sub' if this
was intended to be part of a signature?
at <tmp>:1
------> <BOL>⏏$foo = "bar";
ab5tract m: no strict; dd $foo = “bar” 11:56
camelia Any $foo = "bar"
wayland76 Yeah, that's what I meant. But it turns out that the answer is probably that we just don't specify, and I was confused by the slightly different outputs from running .raku on a Signature and a method. 12:02
I've also figured out that, to be able to specify a parameter as the invocant (ie. "the special first parameter that's an object specifier"), I need to fiddle with the $!flags variable on the Parameter class. 12:03
So, I needed: my constant $SIG_ELEM_INVOCANT = 1 +< 6; Parameter.new(type => 'Kinship', flags => $SIG_ELEM_INVOCANT) 12:14
Not very happy about having to copy that flag from the Raku source, but it works. 12:15
ab5tract Not totally ideal either, but 12:19
m: use nqp; dd nqp::const::SIG_ELEM_INVOCANT
camelia 64
wayland76 Oh, I like that better! Thanks! 12:20
lizmat wayland76: which source are you using? feels outdated? 12:26
the current rakudo source uses nqp::const::SIG_ELEM_INVOCANT 12:28
12:51 sena_kun joined 13:46 abraxxa-home left
ab5tract wayland76: R#5579 13:57
linkable6 R#5579 [open]: github.com/rakudo/rakudo/pull/5579 Add :invocant option to Parameter.new
16:39 teatime left 16:40 teatime joined 16:56 gdown joined 17:47 japhb left 18:10 gdown left 18:24 japhb joined 18:29 Altai-man joined 18:32 sena_kun left 19:29 Altai-man left 19:30 Altai-man joined 19:33 sena_kun joined 19:34 Altai-man left 20:30 wayland joined 20:31 wayland76 left
wayland lizmat: running, a pretty old one, but for poking around in the code, I have the latest. 20:33
(as in, master checked out of github)
lizmat eh... you mean "main" ? 20:34
wayland Yeah, that's the one
lizmat we switched to "main" as the default branch quite a while ago
ok, *phew8
wayland Force of habit, soz
lizmat understood
wayland ab5tract: thanks! 20:35
21:09 sena_kun left
wayland lizmat: Good catch -- turns out I *was* on master. Switched to main now. Thanks! 21:26
Question regarding github.com/rakudo/rakudo/blob/b088...kumod#L128 -- why does it compare the containers? Is this because binding has already happened or something? 21:29
...but signatures don't bind to each other. So I'm just confused. 21:32
21:40 Chanakan joined
wayland (but still don't know the answer) 21:46