🦋 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.
Xliff \o 01:33
Fun with supplies and intervals -- replit.com/@Xliff/EasygoingOliveFi...#main.raku
No writeup, yet. If interested, just ping me and I'll whip up a quick one, tomorrow.
lizmat Xliff interested :-) 08:40
gfldex lolibloggedalittle: gfldex.wordpress.com/2023/04/23/not-even-empty/ 11:44
Xliff lizmat: OK. Where is the best place for raku blogs? 15:49
lizmat dev.to ?
Xliff Ah. I'll need to get an account there. Thanks.
lizmat: dev.to/xliff/using-a-supply-to-tra...a-box-3d1b 16:21
Still needs the conclusion.... 16:22
Voldenet Xliff: are you absolutely sure that this code is thread safe? 16:29
Xliff No.
Voldenet probably access to the $bonus needs a lock
Xliff There is an attempt to use locking.
True. But for my purposes.... it's irrelevant. 16:30
Please mention that in the comments when it goes up.
Adding in any discussion about thread safety would muddy the issue. 16:31
lizmat Xliff: why the BUILD method ?
Xliff lizmat: That's because it's there in Supply-factories.pm6
So I just adjusted the source for Suppy.interval to taste. 16:32
lizmat also, why augment Supply? why not create a sub ? 16:34
Xliff Because I didn't know how to do it with a sub. Using a sub does not imply nor promote reusability, and this also points out a missed opportunity with Supply.interval. 16:35
lizmat well, apart from that, but augmenting means you can't precompile
Xliff This is how Supply.interval was implemented. I'm using the same technique Rakudo itself uses to add Supply.interval. 16:36
lizmat sub interval-with-value( $interval, $value, $delay = 0, :$scheduler = $*SCHEDULER)
that may be so, but augment outside of the core, is a very heavy thing to do 16:37
Xliff I prefer it this way.
lizmat ok, just my 2c :-)
Xliff If you want to make that argument, it can be done in the comments. :-) 16:38
Your 2c is more like a quarter, but is best for further discussion, yes?
lizmat sure
Voldenet meh, dev.to requires too much effort to comment, but it's not relevant anyway 16:39
lizmat you can also comment here: www.reddit.com/r/rakulang/comments...tems_in_a/
Voldenet otoh, I'm curious why not just do `Supply.interval(2).map({ [42, $++] })` 16:44
Voldenet it's nice because it automatically creates a scope and it's very likely to be thread safe in scenario like: 17:01
m: my $var = 42; react { whenever Supply.interval(.1).map({ [$var, $++] }).head(5) { .say }; whenever Promise.in(.1) { $var = -1; }}
camelia [42 0]
[-1 1]
[-1 2]
[-1 3]
[-1 4]
Xliff Voldnet: Huh! Not bad. 17:08
I'm not so well versed in react/whenever so that solution did not occur to me.
Voldenet: How well does that .map work with .tap? 17:10
Voldenet .map emits MapSupply
Xliff And that means... ? 17:11
Voldenet It works like a normal tap would
Xliff OK, great!
Voldenet Hmm, I'm still not entirely sure about thread safety of setting var and reading it the way I did - since emit may run before or after $var is changed 17:14
lock would make it clearer 17:17
rf Afternoon folks, I have time today to write a blog post :) 17:38
lizmat ++rf 18:11
rf In Rakudo's source, where is `Supply.interval` declared? 18:27
lizmat src/core.c/Supply-factories.pm6 line 79 18:36
rf Thanks! 18:37
Also dev.to/rawleyfowler/functional-pro...-raku-9ib, had to rush a bit I have family coming so ping me with spelling mistakes or anything :D
lizmat rf I think you forgot WhateverCode as an anonymous function 18:40
my &add = * + * 18:41
rf Ah good catch!
I'm not going to cover it completely but I will make sure to mention it
lizmat++ 18:43
Xliff Can you create a REPL<CStruct> class at runtime? 19:14
lizmat I don't see why not? 19:16
it would be BEGIN time inside the EVAL ?
Xliff No. In a sub using the HOW 19:17
lizmat I suggest write your class, then feed that Str to .AST and say the result. If that produces valid RakuAST code, that would be a way to go about it 19:19
Xliff lizmat: So you do NOT recommend using ^add_method and .^add_attribute? 19:25
Anton Antonov Is anyone else experiencing upload problems with fez / raku.land ? 22:32
It seems that the newest update at raku.land is from 3 days ago. 22:33