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.
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
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
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
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
I was responding to the original "when without given inside a for" topic 11:49
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
lizmat oh dear 17:37