lizmat | reading news.ycombinator.com/item?id=42638508 I wonder whether we could use a NOTFIRST phaser in Raku | 00:10 | |
coleman | What would be different from "once" (in loops) docs.raku.org/syntax/once | 00:16 | |
timo | so a shortcut for `if $++ { ... }`? | 00:18 | |
m: for ^10 { if True ^ff^ False { say "ah" }; say $_ } | 00:19 | ||
camelia | 0 ah 1 ah 2 ah 3 ah 4 ah 5 ah 6 ah 7 ah 8 ah 9 |
||
timo | m: for ^10 { if $++ { say "ah" }; say $_ } | ||
camelia | 0 ah 1 ah 2 ah 3 ah 4 ah 5 ah 6 ah 7 ah 8 ah 9 |
||
coleman | that's elegant | 00:29 | |
timo | m: for ^10 { if $++ { say "ah"; if $++ { say "ah!"; if $++ { say "Ah!"; if $++ { say "AH!" } } }; say $_ } | 00:30 | |
camelia | ===SORRY!=== Error while compiling <tmp> Missing block at <tmp>:1 ------> Ah!"; if $++ { say "AH!" } } }; say $_ }<HERE><EOL> |
||
timo | m: for ^10 { if $++ { say "ah"; if $++ { say "ah!"; if $++ { say "Ah!"; if $++ { say "AH!" } } } }; say $_ } | 00:31 | |
camelia | 0 ah 1 ah 2 ah 3 ah 4 ah 5 ah 6 ah 7 ah 8 ah 9 |
||
timo | not like that hm? | ||
the inner ifs are all closure-cloned? | |||
coleman | meaning they're 0 every time maybe? | 00:32 | |
timo | yeah a simple $++ inside of the first if $++ is always 0 sadface | 00:51 | |
i guess that's what you get for anonymous state variables, they just attach to the closest block they're in | 00:52 | ||
coleman | Seems like a bug but I don't know if it technically violates any rules. if isn't supposed to topicalize, but that's technically not the same thing | 01:22 | |
ah nevermind; the docs say it gets reset in each lexical scope | 01:23 | ||
docs.raku.org/syntax/$ | |||
02:40
guifa joined
03:48
guifa left
04:33
nine left,
camelia left,
nine_ joined
04:41
camelia joined
|