🦋 Welcome to the IRC channel of the core developers of the Raku Programming Language (raku.org #rakulang). This channel is logged for the purpose of history keeping about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Logs available at irclogs.raku.org/raku-dev/live.html | For MoarVM see #moarvm Set by lizmat on 8 June 2022. |
|||
01:19
AlexDaniel left
04:30
epony left
04:49
epony joined
05:54
epony left
05:56
epony joined
07:55
sena_kun joined
09:09
sena_kun left
10:15
Voldenet left
10:16
Voldenet joined
|
|||
lizmat | notable6: weekly | 11:22 | |
notable6 | lizmat, No notes for “weekly” | ||
tellable6 | 2024-01-02T13:07:23Z #raku-dev <lizmat> notable6: weekly | ||
11:48
nine left,
nine joined
13:09
japhb left
13:26
japhb joined
16:01
japhb left
16:05
japhb joined
16:15
japhb left
16:19
japhb joined
|
|||
[Coke] yawns | 17:55 | ||
18:53
sena_kun joined
|
|||
patrickb | lizmat: Would it be difficult to make explicit return inside of LEAVE blocks a compile time error? | 19:40 | |
In RakuAST that is. | |||
Hm, given that return is just a subroutine call, doing so is also kind of dirty. Doing so at runtime might be cleaner, but would impose a performance penalty with every return. Ugh... | 19:50 | ||
vrurg | patrickb: what's so bad about explicit return? What if one wants to alter the return value? | 20:00 | |
Voldenet | it doesn't work in runtime now, but compiles | 20:06 | |
m: sub x { LEAVE { return 2 }; 1 }; x | |||
camelia | Attempt to return outside of any Routine in sub x at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
patrickb | vrurg: In general I'm unsure if this would be a helpful mechanism and I suspect it brings with it some foot guns. I'm currently looking at gist.github.com/patrickbkr/36e2591...c5c8766eb5 | ||
m: sub x { LEAVE { return 5; } return 2; }; x | 20:07 | ||
camelia | ===SORRY!=== Error while compiling <tmp> Strange text after block (missing semicolon or comma?) at <tmp>:1 ------> sub x { LEAVE { return 5; }⏏ return 2; }; x expecting any of: infix infix stopper … |
||
patrickb | m: sub x { LEAVE { return 5; }; return 2; }; x | ||
camelia | Attempt to return outside of any Routine in sub x at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
patrickb | m: sub x { with Nil { } else { LEAVE { return 5; }; return 2; } }; x | 20:09 | |
camelia | ( no output ) | ||
patrickb | m: sub x { with Nil { } else { LEAVE { return 5; }; return 2; } }; say x | ||
camelia | 5 | ||
Voldenet | …huh | 20:11 | |
m: sub x { { LEAVE { return 2 }; return 1 } }; x | |||
camelia | ( no output ) | ||
Voldenet | Huh. | ||
it makes a bit of sense, but it's weird | 20:12 | ||
some languages (java/js) allow return, some languages (C#) don't | 20:15 | ||
nemokosch | how does it make sense? | 20:19 | |
does the LEAVE return terminate the surrounding function, then? | 20:20 | ||
m: sub x { { LEAVE { return 2 }; return 1 }; return 42 }; say x | |||
evalable6 | 2 | ||
Raku eval | 2 | ||
nemokosch | perhaps... | ||
well yeah, it makes sense implementation-wise but not if you actually want to read the code | |||
it's horribly unstructured | 20:21 | ||
vrurg | To me LEAVE, as a part of routine body, should be able act as such. Best explanation for it in the most simple words would be: it is the code being ran the last before `return`. Correspondingly, it's rather natural for it to be able to return earlier. | 20:28 | |
Voldenet | in all languages LEAVE can throw, but in some it can't return Result<T>, so it makes sense to support it | 20:33 | |
vrurg | Besides, the error message about `return outside of routine` is highly misleading because if the phaser is outside then how come it has access to the lexicals? | ||
Voldenet | imo, after all, it should work | 20:34 | |
nemokosch | it should work but not from outside of the scope... right? | 20:35 | |
it shouldn't act like a hook embedded after the function | |||
Voldenet | it should act like it's written at the end of the block imo | 20:36 | |
nemokosch | at the end, inside the block | ||
Voldenet | ofc, inside | ||
nemokosch | so change the return | ||
like the try-finally magic in JS 😄 | |||
Voldenet | m: sub db-query { LEAVE { return Failure.new("Cleanup failed"); }; … } # This makes perfect sense | ||
camelia | ( no output ) | ||
nemokosch | yep | 20:37 | |
then I think all 3 of us said basically the same thing | |||
Voldenet | meaning it's a good idea ;) | ||
nemokosch | of course! you know what they say about great minds... | ||
patrickb | Thanks for the input! | 21:29 | |
Off to bed for me. o/ | |||
23:40
sena_kun left
|