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.
00:00 kjp left 00:01 kjp joined 00:02 codesections1 joined 00:07 codesections left, codesections1 is now known as codesections 01:32 discord-raku-bot left, discord-raku-bot joined 02:31 frost12 joined 02:32 frost12 left, frost52 joined 02:40 frostsdasd joined 02:41 Kaiepi joined 02:42 razetime joined 02:43 frostsdasd left, frost52 left, frost48 joined, frost48 left 02:44 frost56 joined, frost56 left 02:56 frost joined 04:08 razetime left 05:19 Kaiepi left, razetime joined 06:57 razetime left 08:00 sivoais left, nicole left, nicole joined 08:10 sivoais joined 08:21 razetime joined 08:40 Kaiepi joined 09:09 dakkar joined 09:28 frost left 09:52 lizmat_ joined 09:55 lizmat left 09:57 lizmat_ left, lizmat joined 10:11 habere-et-disper joined
habere-et-disper In trying to simplify: 10:13
for @array -> $character {
    given $character {
        when ...
    }
}
I thought this would work:
for @array -> $character {
    when ...
}
But `when` needs a `given`. So maybe:
forgiven @array -> $character {
    when ...
}
I thought it -Ofun to see `forgiven`! :-) 10:14
(Or maybe `when` should not only take from the topic?) 10:17
kjp Try plain "for @array { when ... } 10:18
habere-et-disper I did and that works as expected, but I wanted to name the topic. 10:23
10:24 kueppo joined
kjp But "when" operates on $_, so even if you call it something else you'll still need "given" to get back to $_. 10:25
habere-et-disper So either `when` could be tempted to take from more than just the topic or we could entertain the -Ofun idea of `forgiven` ? 10:26
Nahita :pp forgiven would be so cool! 10:39
BTW, `when` doesn't *need* `given` but they are used frequently i guess to emulate a (powerful) switch-case of other langs
maybe you can do `$_ = $character` or vice versa at the beginning of the loop but... that's not nearly as cool as `forgiven`
habere-et-disper Can we locally extend `for` or `given` and create the keyword `forgiven`  without much fuss or is this straight into the weeds? 10:42
10:46 kueppo left 11:14 discord-raku-bot left 11:15 discord-raku-bot joined
lizmat you could 11:18
guifa You could do it now with a slang, but (and I swear I feel like I'm a broken record with this) when rakuAST comes out it'll be easy as pie 11:26
basically you'd convert forgiven @foo -> $bar { … } to for @foo -> $bar { $_ := $bar; … } 11:27
(or for @foo { my $bar := $_; … }; classic six half a dozen thing) 11:28
Nahita is it possible you show an example of that or point to where similar thing is made please? 11:29
habere-et-disper Sounds wonderful. Where are the roast stats? It is good to see progress. :-)
guifa blogs.perl.org/users/damian_conway/...ratch.html <-- closest example I can think of off the top of my head, but it's simpler than the proposed 11:30
Nahita thankyou 11:33
11:35 habere-et-disper left
guifa tbh what might be more interesting is allowing for a twigil that marks something as a topic. so you'd be able to do for @foo -> $_bar { … } and then a .xyz would be called on $bar, but you could still use $bar as its self (maybe for nicer argument passing via :$bar ) 11:36
lizmat that feels... like a good idea now, but...
guifa lizmat: I will find a way :-) 11:38
Obviously, _ is out, since $_foo is a valid identifier
Nemokosch I don't know 11:39
`for @array -> $character {
when $character ~~ check {`
what is the matter with this?
seems to me that this is exactly the intended use-case of smartmatch 11:40
lizmat agree 11:41
guifa laziness? ha I admit I've one or two times where I've had the situation I described (wanting to do .calls but also :$args ) and unfortunately in a for loop, you get .calls with foo @foo { … } and you get :$args with for @foo -> $args { … } but you can't get both 11:43
'tis but a minor annoyance, but I mean, are we really former Perlmongers if we don't grumble over minor annoyances? hahahha 11:44
Nemokosch guifa: oh I hadn't made it to your example when I wrote that 11:48
11:49 Kaiepi left
I was responding to the original "when without given inside a for" topic 11:49
12:06 Kaiepi joined 12:21 habere-et-disper joined 13:13 habere-et-disper left 14:17 dakkar left 17:11 nd3i joined
nd3i I'm having trouble getting either raku-debug or rakudo-debug to load my code. While raku -c myfile.raku shows no errors, raku-debug dies with: 17:12
Unexpected structure of 'when' statement QAST node:
- QAST::Op(if)  :when_block<?> :statement_id<35> when \"raw\" { }\n\t
17:37 razetime left
lizmat oh dear 17:37
18:15 nd3i left 19:25 codesections left 19:49 nicole left, nicole joined 20:03 Guest38 joined 20:57 Guest38 left 22:19 codesections joined 22:42 Guest38 joined 23:15 Guest38 left 23:54 codesections left 23:55 codesections joined, codesections left 23:56 codesections joined, codesections left 23:59 codesections joined, codesections left