🦋 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.
01:17 kylese left, hulk joined 02:04 Maylay left 02:05 guifa left 02:08 Maylay joined 02:15 hulk left, kylese joined 02:24 MasterDuke joined 02:44 derpydoo joined 02:48 teatime joined 02:50 pony joined 05:05 yewscion joined 05:08 yewscion left, yewscion joined 05:09 yewscion left 05:30 Sgeo left 07:24 wayland joined, sena_kun joined 07:53 sena_kun left 08:06 sena_kun joined
wayland Question: In the following gist gist.github.com/wayland/299d245e4b...d4fd6e16a8 is the first line in the method useful, or do I have to duplicate it in each function in the Proxy? 08:08
Hmm. It looks like the first line gets called once, and then the FETCH block gets called repeatedly. 08:11
08:13 jpn joined 08:33 MasterDuke left 08:42 tadzik left, tadzik joined
lizmat without looking at the code, if it's about FETCH being called multiple times: yes, it can 08:58
looking at the gist: the idea of proxies is that they are created once, and then called 09:00
so typically you'd bind a proxy on first access, and subsequent accesses would be automatic
m: my $a := Proxy.new( FETCH => ->$ { say "FETCH"; 42 }, STORE => -> $, $val { say "STORE $val" } ); $a = 666; say $a + $a 09:03
camelia STORE 666
FETCH
FETCH
FETCH
FETCH
84
lizmat wayland: ^^
note you will need to *bind* to the variable to retain its proxyness 09:04
m: my $a = Proxy.new( FETCH => ->$ { say "FETCH"; 42 }, STORE => -> $, $val { say "STORE $val" } ); $a = 666; say $a + $a 09:05
camelia FETCH
1332
09:20 sena_kun left 09:31 discord-raku-bot left 09:32 discord-raku-bot joined 09:39 jpn left 09:44 jpn joined
wayland lizmat: Thanks! That clears things up some. But if I move that line inside the FETCH/STORE routines, it seems that STORE isn't getting called. So, I have class Table { has $.backend-object handles <AT-POS> ... } and I'm calling $table[0]. Should that use the Proxy in $.backend-object ? 09:50
It's calling FETCH on the backend object, but it doesn't seem to be calling STORE. 09:51
Maybe I just have to go digging though.
lizmat could it be you're assigning the Proxy, instead of binding ? 09:52
wayland Could be. It's now the only thing inside the method. I suspect that means that it's getting returned by the AT-POS method, but I don't know where it's getting returned *to*. 09:53
lizmat m: my $a; # $a is bound to a Scalar object, with its own FETCH/STORE logic
camelia ( no output )
lizmat m: my $a := Proxy.new(...); # $a is bound to a Proxy object, with *your* FETCH/STORE logic 09:54
camelia Stub code executed
in block <unit> at <tmp> line 1
lizmat my $a = Proxy.new # creates a Proxy object, on which FETCH is called once and that result is put into the Scalar object in $a 09:55
the Proxy object is then discarded
feels like the latter is going on
09:59 dpk left
wayland OK. Thanks. I'll keep digging and see what I get. 10:00
10:07 dpk joined
wayland I'm struggling to figure out the difference between "is rw" and "is raw". Is the difference that, with "is raw", we don't need to use return-rw? 10:13
lizmat if applied to a routine, yes 10:15
wayland OK, that answers my question :) 10:16
Thanks!
lizmat you can also have "is rw/raw" on parameters, that's why I mentioned routine :-) 10:17
wayland m: my $a := Proxy.new( FETCH => ->$ { say "FETCH"; 42 }, STORE => -> $, $val { say "STORE $val" } ); $a = 666; say $a + $a; dd $a; 10:19
camelia STORE 666
42
FETCH
FETCH
FETCH
FETCH
84
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
FETCH
wayland Huh, that's not what it did on my local. 10:20
Anyway, my question is, is there a way I can tell that an object has a Proxy?
melezhik. Hi patricb: I’ve made a ci for your module - sparky.sparrowhub.io/report/sh-pat...sync/22465 10:24
You may pin a badge by sparky.sparrowhub.io/badge/sh-patr...LSViaAsync 10:25
lizmat m: my $a := Proxy.new(FETCH => -> $ { 42 }, STORE => -> $, $val { say "STORE $val" } ); say $a.VAR.^name # wayland 10:29
camelia Proxy
lizmat m: my $a; say $a.VAR.^name
camelia Scalar
wayland Great! Thanks! 10:30
10:50 derpydoo left
wayland Haha, I've figured it out, I think. $table[0]<name> = 'Narnia' only does fetches on $table, but should do its STORE on $table[0]. 11:05
patrickb melezhik: Nice! 11:13
melezhik: You are relying strongly on Cro, right? Would you be willing to take on some responsibility for the Cro framework itself? We are currently in the process of building up a team. 11:14
Badge added. Apparently the sr.ht markdown supports badges. 11:15
11:35 wayland76 joined, wayland left 11:40 jpn left 11:41 vrurg joined, vrurg_ left 12:21 jpn joined
melezhik. patrickb: thanks for the offer , I am quite busy with life right now, not sure if I will be able to act as a core developer , however I would be happy to give a hand as a infrastructure / ci guy. I am thinking about having integration tests for cro implemented as sparky jobs . Let’s say we want test tls/databases/client integration ? I could put my ideas on cro gh repo or discussion pages , what you think ? 12:28
12:34 jpn left 12:43 jpn joined
patrickb Sounds good! 12:58
Thinking about it, do you have plans to integrate sparky into the GitHub APIs? So that results are reported back to GH. 12:59
If you do, the Rakudo CI bot is a good project to steal from as the GH integration is pretty much completed there. 13:00
melezhik: What we need most in the Cro project is people willing to review PRs. So if you have some knowledge of the code base or are willing to dig into it and feel you are able to judge if something is good or not, that would help a lot. 13:05
[Coke] Happy cloudstrike day to all who are inadvertently celebrating. :( 13:11
greenfork m: "img.jpg".IO.basename.subst(/"." ("jpg")/, "_thumbnail.$0"); 13:17
camelia Use of Nil in string context
in block <unit> at <tmp> line 1
greenfork m: say "img.jpg".IO.basename.subst(/"." ("jpg")/, "_thumbnail.$0");
camelia Use of Nil in string context
img_thumbnail.
in block <unit> at <tmp> line 1
greenfork Can I avoid this "Use of Nil in string", I think that $0 is not initialized when I call subst. How do I make it work for me? 13:18
antononcube @Coke Yeah, I feel better about my GitHub Win64 actions failing. (So, celebration is in order.) 13:26
greenfork m: say S/"." ("jpg")/_thumbnail.$0/ given "img.jpg".IO.basename 13:27
camelia img_thumbnail.jpg
greenfork This form works, though it breaks a method chain. If only there was something like `\1` in other languages to reference a capture regex in a method 13:28
librasteve coke: yaay \o/ 13:30
ugexe greenfork: stackoverflow.com/a/59868119/1772220 13:33
antononcube @greenfork It seems that you have to use match or subst. 13:34
ugexe m: say "xxx".subst(/x $<foo>=(xx)/, {$/<foo>})
camelia xx
ugexe m: say "xxx".subst(/x $<foo>=(xx)/, $/<foo>) 13:35
camelia Use of Nil in string context

in block <unit> at <tmp> line 1
ugexe thus
m: say "img.jpg".IO.basename.subst(/"." ("jpg")/, {"_thumbnail.$0"});
camelia img_thumbnail.jpg
greenfork Very smart, defer the execution, thank you! 13:38
antononcube @librasteve If you didn't comment on Frink in reddit, I would have not known about it. 🙂 13:42
tbrowder any suggestions for naming a module that differs slightly for one OS versus another? at the moment, we assume authors build module X to work for *nix, macos, and windows. but what if it's impossible on, say, windows without a change in dependencies. with zef and the static META6.json file the repos would have to be different. 13:53
tellable6 2024-07-16T22:52:22Z #raku <wayland> tbrowder tbrowder do you mean that we have a shorter version than what lizmat wrote above?
tbrowder .tell wayland i was referring to the last part of the name: use a kebab-case alias 13:55
tellable6 tbrowder, I'll pass your message to wayland
antononcube @tbrowder You can have "X::Unix", "X::Windows", etc.
tbrowder yep, but kind of unwieldy, but i don't have any better ideas. although being able to tag it somehow in raku.land would be nice 13:58
or some special meta key 13:59
"os":"w" or "os":"lwm" 14:00
in addition to a name diff as you suggested 14:02
14:18 Sgeo joined
[Coke] er, I meant CrowdStrike. 16:14
17:21 dustinm` left
patrickb Hey! I'm first time using GTK::Simple. Is there a way to give a widget a fixed size? I've seen size-request(), but iiuc that's a min size. 17:29
17:34 dustinm` joined
patrickb I found out. Can pass a hash to the v/box constructors instead of the widget directly. Then have :!expand in that hash. 17:45
melezhik. patrickb: gh and sparky integration is possible , i guess i can test using my token , but probably better to have some impersonated token for that , meanwhile here is my take on cro core - sparky.sparrowhub.io/report/gh-cro...core/22469 18:23
18:59 guifa joined 19:23 ssoss joined 19:25 ssoss left 19:46 skyesoss joined 19:48 skyesoss left 19:49 skyesoss joined 20:12 jpn left 20:34 jpn joined
guifa m: sub foo ($x) { loop { FIRST my $y = $x; $y--; return 42 if $y < 0 } } 20:58
camelia ( no output )
guifa m: sub foo ($x) { loop { FIRST my $y = $x; $y--; return 42 if $y < 0 } }; foo 4
camelia ( no output )
guifa m: sub foo ($x) { loop { FIRST my $y = $x; $y--; say $y; return 42 if $y < 0 } }; foo 4 20:59
camelia 3
-1
guifa that.... doesn't feel right
21:11 skyesoss1 joined 21:16 sena_kun joined 21:21 sena_kun left
librasteve guifa: its a bit of a mystery to me what you intend with the FIRST here 21:26
m: sub foo ($x) { my $y = $x; loop { $y--; say $y; return 42 if $y < 0 } }; foo 4; 21:27
Raku eval 3 2 1 0 -1
evalable6 3
2
1
0
-1
librasteve i guess 21:28
21:38 guifa left 21:55 skyesoss1 left 22:14 thaewrapt left 22:21 jpn left 22:22 jpn joined 22:40 derpydoo joined 22:42 jpn left 23:22 jpn joined 23:55 jpn left