03:29
stanrifkin_ joined
03:31
stanrifkin left
05:31
kjp left
05:32
kjp joined
05:33
kjp left,
kjp joined
|
|||
timemelon | how come when doesn't short circuit its block when used as a statement modifier? | 09:07 | |
feel like an odd decision to make it more or less an alias of if in that case | |||
lizmat | gist? | 09:11 | |
timemelon | what do you mean? | 09:19 | |
lizmat | could you make a gist of the perceived problem? | 10:22 | |
showing what it does and what your expect ? | |||
timemelon | I don't necessarily think it's a problem, I'm just curious about the rationale | 10:33 | |
raku given 3 { when 3 { say 'is 3' } say 'not 3'; } says is 3, but raku given 3 { say 'is 3' when 3; say 'not 3'; } says is 3 and then also not 3 | 10:34 | ||
this is documented, I just wanna know why this behaviour was chosen | 10:35 | ||
lizmat | understand the question now | 10:38 | |
I wonder whether it is an implementation artefact | |||
you could consider "say "foo" when X" as { say "foo" when X } | 10:44 | ||
and in that sense, it also exits the outer scope | 10:45 | ||
librasteve | @timemelon my swag is that the rationale of statement modifiers is that they are syntax sugar to allow simple english language style one liners to be thrown in to your code to handle ad hoc branching behaviour, consider this: | 18:11 | |
sub fn($x) { given $x { say "three" if $_ == 3; say "Int" when Int; say "defined" with $x; } } [3,4].map: *.&fn; #three #Int #defined #Int #defined | |||
so this code is written in the spirit of one liners that can leverage the subtle nature of the various alternates - if (and unless) is just perl5 brought into raku, when is used here to clean up the type test, with is used here to clean up the definedness test | 18:15 | ||
given this proposition, then imo the best design to allow ad hoc mixing of these one liners is to have them behave in a more restricted way - it would be super confusing if some exit the outer but others don't ... NB this is on contrast to the structured use case of given - when which is to be a short circuiting case / switch statement | 18:19 | ||
timemelon | that makes some sense | 19:28 | |
22:01
stanrifkin_ left
23:41
swaggboi left
23:45
swaggboi joined
|