|
🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel! Set by lizmat on 6 September 2022. |
|||
|
00:04
lichtkind left
00:11
simcop2387 joined
00:12
jdv joined
|
|||
| SmokeMachine | Does that make sense? | 00:22 | |
|
00:22
Sgeo joined
|
|||
| SmokeMachine | lizmat: about the wrap/assuming issue, assuming does not solve the problem… I need that for a trait_mod to modify a sub… the code I was writing when I needed that is this one: github.com/FCO/Deps/blob/baf1d7e24...akumod#L74 | 00:50 | |
|
01:25
Sgeo left
01:31
Sgeo joined
01:46
arkiuat_ joined
01:49
arkiuat left
01:53
hulk joined,
kylese left
02:15
hulk left
02:16
kylese joined
03:27
vasko left
03:31
vasko joined
03:45
kylese left
03:47
kylese joined
04:10
Aedil left
04:11
melezhik joined
04:16
Aedil joined
05:05
arkiuat_ left
05:18
arkiuat joined
06:22
arkiuat left
06:46
arkiuat joined
06:51
arkiuat left
07:19
arkiuat joined
07:24
arkiuat left
07:47
arkiuat joined
07:52
arkiuat left
07:53
Sgeo left
08:10
apac joined
08:13
dakkar joined
08:21
arkiuat joined
08:22
lichtkind joined
|
|||
| Voldenet | SmokeMachine: that approach with named dependencies seems ok, but if it was a variable, then it would be more resistant to typos and in the best case wouldn't even require string-hash lookup | 08:31 | |
| also, there's that case `deps-root { start { … use deps-root } }` deps-root would end before the "start" ends - for only this case some lower level api would be needed probably | 08:33 | ||
| SmokeMachine | When passing the deps (I mean on injectable and injected) it also accepts a Deps object instead of a Str… but now you mentioned, I’ll make it (deps, deps-root and deps-scope) to, if :$deps is rw, to store the obj into that variable instead of using that as a name… | 08:35 | |
| Voldenet | the latter problem would probably need some trait like `:dangling` implying that it would be menually cleaned up | 08:37 | |
| SmokeMachine | Yes… the start would be a problem… I was wondering if wrapping start to get the dyn var, put it into a local var, call the original start, create a new dyn var with the content of the local var and call the original block would make sense… but I’m not sure about that… | 08:38 | |
| Voldenet | dyn vars and threading are causing problems sometimes | 08:39 | |
| it works, but if it doesn't then it's pain to debug | |||
| SmokeMachine | Yes… | ||
| Voldenet | Oh, in some cases it's necessary to keep all the scopes around (like when you start websocket connection, store in the CurrentWebsocket and keep all the scopes in one big array) | ||
| so that the scopes would be per websocket connection session | 08:40 | ||
| and closing one websocket would send "websocket has disconnected" notification to all others | |||
| SmokeMachine | Maybe deps should accept a :$use optional arguments that would make use that internally… that way we could: deps-root :deps($root), { start { deps :use($root), { … } } } | 08:41 | |
| Voldenet | you could discard one {} probably | 08:42 | |
| SmokeMachine | Yes… | 08:43 | |
| Voldenet | `deps-root :deps($root), { start deps :use($root), { … } }` | ||
| but | |||
| SmokeMachine | Would that make sense? | ||
| Voldenet | `deps-root :deps($root), :dangling { start deps :use($root), { … } }` | ||
| since otherwise root would cleanup before start used the root | 08:44 | ||
|
08:44
arkiuat left
|
|||
| SmokeMachine | Sorry, what the word dangling means? | 08:44 | |
| Voldenet | it's from `dangling pointer`, but probably not the best word here | 08:45 | |
| :no-cleanup | 08:46 | ||
| maybe | |||
| SmokeMachine | Ok, now I got it! :) | ||
| Voldenet | deps method would basically invoke all the cleanups on the end | ||
| unless it was told not to | 08:47 | ||
| SmokeMachine | Other thing it could do is that if it returns a Promise, add a then on that to cleanup only when the promise is finished… | ||
| (By it I mean the block) | |||
| Voldenet | ah, that would prevent multiple cleanups | 08:48 | |
| SmokeMachine | (We do something similar with Red on red-do :transaction, { start … } | 08:50 | |
| (If I still remember it correctly) | 08:51 | ||
|
09:01
librasteve_ joined
|
|||
| Voldenet | I'm unsure whether multiple cleanups should fail or if child scopes should cleanup when parent is cleaned up | 09:03 | |
|
09:04
arkiuat joined
|
|||
| Voldenet | maybe `try-cleanup` should not fail, `cleanup` should, parent should have children's try-cleanup registered | 09:06 | |
| or parent could just show warning when any child is not cleaned up, but not clean it up | 09:07 | ||
|
09:09
arkiuat left
|
|||
| librasteve | Hi everyone o/ - I have volunteered to make a prototype new version of the raku.org website - following on from [Coke]'s request for input and feedback, please can you visit github.com/librasteve/raku-org-25-proto and provide your inputs and comments - either raise an issue for discussion, or via a PR if it is more concrete. [You will see that I have tried to get the ball rolling with a strawman ... but happy to adapt | 09:11 | |
| and work with everyone to get to a concensus on what is needed...] I have set a completely arbitrary deadline of 5 days to complete the (non technical) requirements so that we can keep some momentum. | |||
| SmokeMachine | librasteve_: sorry, I forgot the release… I just did it now. | 09:13 | |
| Voldenet: I think I’ll leave the cleanup implementation for a future step… after having a few examples where that’s needed… what do you think? | 09:16 | ||
| Voldenet | SmokeMachine: makes sense, in a few days I'll probably extend my examples to incorporate full lifetime for things | 09:18 | |
| I'll add object pool and some other basics so the "why need cleanup" is more obvious | 09:20 | ||
| and hopefully also test it on the way | |||
| SmokeMachine | Voldenet: when you do that, please let me know that I’ll convert it to Deps… | 09:22 | |
| melezhik | librasteve_: I skimmed very the requirements.md looks good. Maybe in plus with to mentioned all battery included ecosystem - cro, HARC for web development, Red - database ORM, Sparrow - automation framework - those are just examples, not a pitch ))) | ||
| So the focus on solutions and ready tools not just language | 09:23 | ||
| SmokeMachine | Voldenet: it may be just a toy project… but I’m liking what it’s becoming… | ||
| melezhik | Quite important from people without huge programming background and CS | ||
| Voldenet | librasteve: I feel that raku can be written a lot like java, because it has interfaces, inheritance, exceptions - maybe it'd be nice to actually write out an example of various languages and raku side-by-side | 09:26 | |
| to express how powerful the "multiparadigm" is | 09:27 | ||
| However, imo raku is not very much like javascript | 09:29 | ||
| inheritance and js is completely different, operators also try very hard not to throw exceptions | |||
| m: "a" - 1 | 09:31 | ||
| camelia | WARNINGS for <tmp>: Useless use of "-" in expression "\"a\" - 1" in sink context (line 1) Cannot convert string to number: base-10 number must begin with valid digits or '.' in '<HERE>a' (indicated by <HERE>) in block <unit> at <tmp> line 1 |
||
| Voldenet | this is valid code in js and gives proper result - not a number :> | ||
| Promises are js-like, but whole async is also entirely different | 09:32 | ||
| SmokeMachine | I really think Promises could be MORE js-like… | 09:34 | |
| Voldenet | they actually could | 09:37 | |
|
09:38
arkiuat joined
|
|||
| Voldenet | the biggest difference is that .then will execute the code regardless of Promise state | 09:38 | |
| m: my $p = Promise.new; $p.then({ say "uh oh" }); $p.vow.break("nope"); await $p | 09:39 | ||
| camelia | uh oh An operation first awaited: in block <unit> at <tmp> line 1 Died with the exception: nope in block <unit> at <tmp> line 1 |
||
| Voldenet | while in javascript there's `.then` (which comes from jquery's Deferred, so it) and it has two arguments | 09:41 | |
| s/so it/ | |||
| because of that, then in java's reactor, ContinueWith in C# and then in raku are actually a mess to deal with | 09:42 | ||
|
09:43
arkiuat left
|
|||
| Voldenet | the simple js code `fetch("thing").then(t => t.json()).then(j => fetch(j.otherThing)).then(x => Math.pow(x, 2)).catch(x => console.error(x));` is an absolute madness to write anywhere else | 09:44 | |
| if anything, it shows how much closer raku is to java, probably | 09:49 | ||
| SmokeMachine | Not only that, but also what then receives, and what it does when the block returns another promise | 09:51 | |
| But I don’t think Raku is close to Java… but you can write code as if it was… | 09:52 | ||
| librasteve | SmokeMachine: thanks! | 09:56 | |
| all - great to see some constructive ideas - and its always nice to chat - but don't forget to create an issue over on the GH repo so that they can get folded into the prototyping | 09:58 | ||
| (yes I COULD copypasta over there - but then I want the contribution to be clear - and I want to be able to try and consolidate common threads - thus the GH repo ;-) ) | 09:59 | ||
|
10:01
abraxxa-home joined
|
|||
| Voldenet | Huh | 10:01 | |
| m: my $p = Promise.new; $p.andthen({ say "uh oh" }); $p.vow.break("nope"); await $p | |||
| camelia | An operation first awaited: in block <unit> at <tmp> line 1 Died with the exception: nope in block <unit> at <tmp> line 1 |
||
| Voldenet | So apparently it is possible to write that, just it is not documented | ||
| I'm standing corrected - `andthen` and `orelse` methods change my views on the usefulness of Promise entirely | 10:04 | ||
|
10:04
abraxxa-home left
10:05
abraxxa-home joined
|
|||
| SmokeMachine | m: start({ 42 }).andthen: *.say | 10:06 | |
| camelia | ===SORRY!=== Error while compiling <tmp> Undeclared routine: start used at line 1. Did you mean 'sort', 'spurt', 'sqrt'? |
||
|
10:06
arkiuat joined
|
|||
| SmokeMachine | m: start({ 42 }).andthen: &say | 10:06 | |
| camelia | ===SORRY!=== Error while compiling <tmp> Undeclared routine: start used at line 1. Did you mean 'sqrt', 'spurt', 'sort'? |
||
| SmokeMachine | m: (start { 42 }).andthen: *.say | 10:07 | |
| camelia | ( no output ) | ||
| SmokeMachine | m: (start { 42 }).andthen: &say | 10:08 | |
| camelia | ( no output ) | ||
| SmokeMachine | It does not receive anything??? | ||
| Voldenet | but it does, however promises are always running asynchronously | 10:11 | |
| librasteve | Ok seems like I have caused some confusion - sorry. So I have started a couple of Discussion Issues over at the GH repo to try and help ... | ||
| github.com/librasteve/raku-org-25-...o/issues/1 ... Discussion: Mention High Value Modules this has melezhik's comments ... pretty straightforward idea imo... | 10:12 | ||
| SmokeMachine | m: await (start { 42 }).andthen: &say | ||
| camelia | Promise.new(scheduler => ThreadPoolScheduler.new(uncaught_handler => Callable), status => PromiseStatus::Kept) | ||
| Voldenet | m: await (start { 42 }).andthen: *.result.say # but of course | ||
| camelia | 42 | ||
| SmokeMachine | Different from js that receives what the previous step returned, it receives the promise itself… | 10:14 | |
| librasteve | github.com/librasteve/raku-org-25-...o/issues/2 Discussion: Comparison Languages to Illustrate Multiparadigm ... this is an empty discussion intended to capture Voldenet remarks - I thought about copying comments over from here, but tbh I am confused about all the concurrency examples ... | ||
|
10:14
abraxxa-home left
|
|||
| SmokeMachine | That may make sense… but I’m just pointing a difference… | 10:15 | |
| librasteve | so dear Voldenet, please can you head over to that Issue and explain your idea briefly there (typically you need ot explain to me like you would a dog or a small child) | ||
|
10:15
abraxxa-home joined
|
|||
| SmokeMachine | m: say await (start { 1 }).andthen({ 2 }) | 10:16 | |
| camelia | 2 | ||
| Voldenet | librasteve: the concurrency examples are actually separate hole I accidentally dropped into, sorry | ||
| SmokeMachine | m: say await (start { 1 }).andthen({ start { 2 } }) | 10:17 | |
| camelia | Promise.new(scheduler => ThreadPoolScheduler.new(uncaught_handler => Callable), status => PromiseStatus::Kept) | ||
| SmokeMachine | In js it would print 2… | ||
| Voldenet | in js promises automatically get unwrapped before entering .then | ||
| so… | |||
| m: say await (start { 1 }).andthen({ start { 2 } }).result.result | 10:18 | ||
| camelia | An operation first awaited: in block <unit> at <tmp> line 1 Died with the exception: Can only specify Awaitable objects to await (got a Int) in block <unit> at <tmp> line 1 |
||
| Voldenet | m: say await (start { 1 }).andthen({ start { 2 } }).result | ||
| camelia | 2 | ||
| Voldenet | right, there's an await | ||
| SmokeMachine | m: multi aawait(Awaitable $a) { aawait await $a }; multi aawait($a) { $a }; say aawait (start { 1 }).andthen({ start { 2 } }) | 10:23 | |
| camelia | 2 | ||
| Voldenet | librasteve: I've added some example that you might be familiar with :) | 10:33 | |
| m: multi aawait(Awaitable $a) { aawait await $a }; multi aawait($a) { $a }; say aawait start start start start { 42 } | 10:35 | ||
| camelia | 42 | ||
| Voldenet | that's nice | ||
| m: await Promise.broken("boo").orelse({ 42 }).then( -> $r { say $r.result }) | 10:40 | ||
| camelia | 42 | ||
| Voldenet | Docs attempt for those methods has been made, because I'll forget it if I don't do that asap: github.com/Raku/doc/pull/4584 | 10:55 | |
| SmokeMachine | glot.io/snippets/h7sotvz66u | 11:04 | |
| Voldenet | SmokeMachine: it'd be enormously nice if the default implementation did that, in fact andthen and orelse were not documented, so maybe it's possible to sneak these changes | 11:06 | |
| SmokeMachine | Voldenet: I think that would be great! | 11:07 | |
| Voldenet | in fact, in case of `then` it's needed to have the promise to get its state | 11:08 | |
| SmokeMachine | But for andthen, that’s not needed… | ||
|
11:10
arkiuat left
|
|||
| Voldenet | I've added that as a comment to `github.com/Raku/doc/pull/4584`, I'll add an issue with this | 11:14 | |
|
11:29
arkiuat joined
|
|||
| Voldenet | SmokeMachine: I've added issue with these two methods github.com/rakudo/rakudo/issues/5892 - feel free to suggest the change about unwrapping the promises recursively - I only propose to do one-level unwrap | 11:39 | |
| it's possible to maybe add some sort of method like `.unwrap` (are we Rust yet ;>) | |||
| SmokeMachine | Comment added… what does .unwrap do? | 11:44 | |
|
11:49
apac left
|
|||
| Voldenet | SmokeMachine: convert Promise<Promise<T>> to Promise<T> | 12:25 | |
| (though rust unwrap is notoriously used to extract T from `Result<T, E>` or `Option<T>` or panic if it's not possible | 12:28 | ||
| …so if you are sure that the value is there in the context and execution doesn't make sense otherwise, .unwrap() gets used) | 12:30 | ||
| I'm not a big fan of unwrap, but having promise being a result of andthen is rare | 12:39 | ||
|
12:42
euandreh joined
|
|||
| SmokeMachine | I don’t think that’s rare… I would say I do that in most of my já code… | 12:55 | |
| s/já/js/ | |||
|
13:19
Sgeo joined
13:26
abraxxa-home left
13:34
yewscion joined
|
|||
| Voldenet | eh | 13:40 | |
| it's not that rare in js, but I wonder how necessary is that in raku | 13:47 | ||
|
13:48
arkiuat left
|
|||
| Voldenet | m: sub foo { await Promise.in(1); $^n + 1 }; say await gather for ^20 { take Promise.kept($_).then({ my $f = foo(.result); say .result; $f }) } | 13:51 | |
| camelia | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) |
||
| Voldenet | this is async yet not | ||
| it's weird because you can have code that's not inside a promise yet it is async | 13:52 | ||
| and it's normal, full async | |||
| the continuation in js is run synchronously and the piece of code can't suspend in the middle | 13:55 | ||
|
14:01
arkiuat joined
14:06
arkiuat left
14:08
Guest19 joined
14:14
arkiuat joined
14:20
arkiuat left
14:35
arkiuat joined
15:56
yewscion left
15:58
abraxxa-home joined
16:18
arkiuat left
16:25
yewscion joined
16:29
yewscion left
16:30
arkiuat joined
16:31
dakkar left
16:34
yewscion joined
16:37
arkiuat left
16:45
Guest19 left
16:52
apac joined
17:07
arkiuat joined
17:12
arkiuat left
17:32
arkiuat joined
17:37
arkiuat left
17:44
yewscion left
17:52
arkiuat joined
18:08
Aedil left
18:28
yewscion joined
18:30
melezhik left
18:31
Aedil joined
18:48
yewscion left
19:01
yewscion joined
19:09
melezhik joined
19:23
euandreh left
|
|||
| [Coke] | www.reddit.com/r/rakulang/comments...requested/ | 19:29 | |
|
19:34
euandreh joined
19:35
maylay left
19:36
maylay joined
19:38
maylay is now known as theif
|
|||
| librasteve | [Coke]: thanks for the cross post! | 19:40 | |
|
20:07
lucasb joined
20:17
euandreh left
20:23
apac left
20:35
Aedil left
20:41
theif left,
maylay joined
21:09
yewscion left
21:21
arkiuat left
21:28
lichtkind left
21:31
abraxxa-home left
21:50
arkiuat joined
|
|||
| Voldenet | btw, I thought about promises a bit and I think .await callable on promise could be useful | 21:53 | |
|
21:55
arkiuat left
|
|||
| Voldenet | m: Promise.kept("3").&await.say | 21:56 | |
| camelia | 3 | ||
| Voldenet | this is already doable, but plain await would've been less magical | 21:57 | |
|
21:59
lichtkind joined
22:05
arkiuat joined
|
|||
| Voldenet | m: await(Promise.kept("3")).say # the same method with plain await sub | 22:07 | |
| camelia | 3 | ||
|
22:09
arkiuat left
22:13
lichtkind left
22:35
arkiuat joined
22:40
arkiuat left,
melezhik left
22:47
arkiuat joined
23:42
yewscion joined
23:45
yewscion left
23:53
lucasb left
|
|||