šŸ¦‹ Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
00:04 frost joined 00:07 reportable6 left 00:08 reportable6 joined 00:12 frost left 00:19 bigdata left 00:55 p6steve_ joined 00:57 p6steve left 01:09 kaiepi joined 01:48 kaiepi left 02:27 swaggboi left, euandreh left 02:40 swaggboi joined 03:18 euandreh joined 03:52 samcv left 03:53 Guest35 left, samcv joined 04:53 linkable6 left, greppable6 left, reportable6 left, notable6 left, committable6 left, tellable6 left, releasable6 left, bloatable6 left, coverable6 left, nativecallable6 left, benchable6 left, evalable6 left, unicodable6 left, quotable6 left, bisectable6 left, sourceable6 left, shareable6 left, statisfiable6 left 04:54 statisfiable6 joined, greppable6 joined, evalable6 joined, unicodable6 joined, reportable6 joined, nativecallable6 joined 04:55 sourceable6 joined, committable6 joined, releasable6 joined, shareable6 joined, notable6 joined, coverable6 joined, quotable6 joined 04:56 linkable6 joined, bisectable6 joined, tellable6 joined, bloatable6 joined, benchable6 joined 05:09 z4kz joined 05:17 z4kz left 05:56 Sgeo left 06:07 Sankalp left, reportable6 left 06:10 reportable6 joined 06:38 jjido joined 06:49 Sankalp joined 07:01 abraxxa joined 07:03 Sankalp left 07:06 Sankalp joined 07:07 abraxxa left 07:08 abraxxa joined 07:39 jjido left 07:53 kaiepi joined 08:05 dakkar joined 08:19 kaiepi left 08:22 kaiepi joined 08:23 jmcgnh left 08:26 kaiepi left 08:28 kaiepi joined 08:31 jmcgnh joined 08:46 donpdonp|z left, donpdonp|z_ joined 08:49 sivoais left 08:50 sivoais joined 08:53 Sankalp left 08:54 Sankalp joined 09:08 frost joined 09:22 discord-raku-bot left, discord-raku-bot joined 10:10 jaguart joined 10:56 sena_kun left 10:58 sena_kun joined 11:13 p6steve_ left 12:07 reportable6 left 12:08 reportable6 joined 12:15 frost left 12:20 frost joined 12:59 bigdata joined 13:01 jaguart left 13:10 Guest35 joined 13:29 jaguart joined 13:42 hankache joined 13:50 hankache left, hankache_ joined 13:51 hankache_ left 13:53 TempIRCLogger left 13:54 bigdata left 13:55 lizmat left 14:15 Sgeo joined, bigdata joined 14:17 kaiepi left 14:18 kaiepi joined 14:19 hankache joined 14:20 frost left 14:39 kaiepi left 14:46 londoed__ joined 14:50 londoed_ left 15:02 hankache left, hankache_ joined 15:03 hankache_ left 15:48 kaiepi joined 15:57 abraxxa left 16:00 unclechu left 16:01 kaiepi left 16:03 kaiepi joined 16:12 bigdata left 16:30 dakkar left, guifa joined 16:33 RakuIRCLogger left, Geth left, RakuIRCLogger joined 16:34 Geth joined 16:36 TempIRCLogger joined, lizmat joined 16:40 bigdata joined, TempIRCLogger left, TempIRCLogger joined 16:47 hankache joined 16:51 bigdata left
hankache m: say "Hello #raku" 16:58
camelia Hello #raku 16:59
tellable6 2020-06-01T18:36:00Z #raku-dev <tyil> .tell hankache maybe you can help here stackoverflow.com/questions/621372...in-windows
17:13 euandreh left 17:19 euandreh joined
El_Che hankache: it's been a while :) 17:24
hankache El_Che indeed it has! 17:28
I hope all is well :) 17:29
El_Che :) 17:38
17:52 Sankalp left 18:02 Sankalp joined, Manifest0 joined 18:07 reportable6 left, reportable6 joined 18:26 hankache left 19:02 juanfra__ joined 19:15 n1to joined 19:19 n1to left 19:20 n1to joined 19:23 jjido joined 19:28 discord-raku-bot left 19:29 discord-raku-bot joined 19:30 guifa left 19:39 discord-raku-bot left, discord-raku-bot joined 20:39 reportable6 left, sourceable6 left, benchable6 left, notable6 left, unicodable6 left, evalable6 left, tellable6 left, quotable6 left, linkable6 left, nativecallable6 left, bloatable6 left, bisectable6 left, greppable6 left, coverable6 left, statisfiable6 left, committable6 left, releasable6 left, shareable6 left 20:40 tellable6 joined, bisectable6 joined, releasable6 joined, committable6 joined, greppable6 joined, evalable6 joined, statisfiable6 joined 20:41 nativecallable6 joined, benchable6 joined, coverable6 joined, shareable6 joined, notable6 joined, linkable6 joined 20:42 reportable6 joined, sourceable6 joined, unicodable6 joined, quotable6 joined, bloatable6 joined 21:01 sena_kun left 21:02 sena_kun joined 21:10 jaguart left 21:19 grondilu joined
grondilu Hi. Is there such a thing as a mutator method? One that would define the semantics for `$instance.rw-attribute = $some-value` ? 21:23
I guess I can write a `set-attribute` method. 21:32
Voldenet grondilu: this could be applicable docs.raku.org/type/Proxy 21:35
I've checked, it's not working as I expected 21:37
21:38 jjido left 21:41 jjido joined, z4kz joined
grondilu Voldenet: that might be what I need, though. What do you mean it's not working? Is it broken or something? 21:44
m: my $x; my $p = Proxy.new: FETCH => method { 2*$x }, STORE => method ($y) { $x = $y }; $p = 5; say $p; 21:46
camelia Use of uninitialized value of type Any in numeric context
5
in method <anon> at <tmp> line 1
grondilu m: my $x = 2; my $p = Proxy.new: FETCH => method { 2*$x }, STORE => method ($y) { $x = $y }; $p = 5; say $p;
camelia 5
grondilu šŸ¤” 21:47
meh, I can write a set method until I figure out this. 21:48
still... 21:50
m: my $x = 2; my $p = Proxy.new: FETCH => method { 2*$x }, STORE => method ($y) { note "using STORE!"; $x = $y }; $p = 5; say $p;
camelia 5
grondilu m: my $x = 2; my $p = Proxy.new: FETCH => method { 2*$x }, STORE => method ($y) { $x = $y }; $p = 5; say $p ~~ Proxy;
camelia False
japhb Bind the Proxy to $p, I think 21:56
Otherwise you're sticking a Proxy inside a Scalar, and the Scalar's assignment semantics win. 21:57
m: my $x = 2; my $p := Proxy.new: FETCH => method { 2*$x }, STORE => method ($y) { $x = $y }; $p = 5; say $p ~~ Proxy; 21:58
camelia False
japhb m: my $x = 2; my $p := Proxy.new: FETCH => method { 2*$x }, STORE => method ($y) { $x = $y }; $p = 5; say $p
camelia 10
japhb m: my $x = 2; my $p := Proxy.new: FETCH => method { 2*$x }, STORE => method ($y) { $x = $y }; $p = 5; say $p.VAR ~~ Proxy
camelia True
japhb grondilu: ^^ 21:59
grondilu japhb: noted, thanks
grondilu goes to sleep 22:00
22:00 grondilu left 22:09 z4kz left
Voldenet grondilu: by `not working as expected` I meant storing Proxy in an attribute, it's possible to use it if you can accept that accessing the setter always allocates the proxy 22:16
tellable6 Voldenet, I'll pass your message to grondilu
22:24 n1to left 22:38 juanfra__ left, juanfra__ joined 23:09 guifa joined 23:19 z4kz joined 23:34 grondilu joined
grondilu is back, couldn't sleep. 23:34
tellable6 2022-05-05T22:16:09Z #raku <Voldenet> grondilu: by `not working as expected` I meant storing Proxy in an attribute, it's possible to use it if you can accept that accessing the setter always allocates the proxy
grondilu or maybe inherit from Proxy and make the whole class the Proxy? That's what I just tried and failed: 23:36
m: my $p := class :: is Proxy { multi method new { samewith: FETCH => method { pi }, STORE => method ($v) { } } }.new; say $p
camelia ===SORRY!=== Error while compiling <tmp>
Cannot find method 'is_dispatcher' on object of type BOOTCode
at <tmp>:1
Voldenet I'm unsure if it's valid to store a proxy somehow 23:39
grondilu m: my %h; say %h<foo> := Proxy.new: FETCH => method { pi }, STORE => method ($v) { } 23:40
camelia 3.141592653589793
Voldenet Binding operator is crucial, not sure if you can bind to an attribute of an instance
m: class X { has $.p := Proxy.new(FETCH => { 42 }, STORE => method ($n) { say "storing " ~ $n }); } 23:41
camelia ===SORRY!=== Error while compiling <tmp>
Cannot use := to initialize an attribute
at <tmp>:1
------> => method ($n) { say "storing " ~ $n })ā; }
grondilu well that is a very explicit error message 23:42
Voldenet m: class y { method p is rw { Proxy.new(FETCH => { 42 }, STORE => method ($n) { say "storing " ~ $n }); } }; say y.new.p = 45
camelia storing 45
42
grondilu nice 23:43
Voldenet it sounds like it would allocate a lot
and also
m: class y { method p is rw { Proxy.new(FETCH => { say "fetch"; 42 }, STORE => method ($n) { say "storing " ~ $n }); } }; say y.new.p = 45
camelia storing 45
fetch
fetch
fetch
fetch
fetch
42
Voldenet I didn't benchmark this, but java style getters/setters (explicit methods) sound faster 23:44
grondilu why the many calls to FETCH?
Voldenet ā€¦absolutely no idea 23:45
grondilu I could also use FALLBACK with rw trait, I suppose 23:49
m: class { method FALLBACK($str, $value) is rw { say "$value" } }.new.foo("bar") 23:50
camelia bar
grondilu with that I can do anything I want.
23:51 Altai-man joined
Voldenet I like FALLBACK, but I'm expecting serious drawbacks when trying to tool it anyhow 23:52
grondilu m: class X { has $.x; method FALLBACK($str, $value) is rw { Proxy.new: FETCH => method { $!x }, STORE => method ($v) { say "storing!"; $!x = $v } }; my X $x .= new: x => pi; $x.x = 3; 23:53
camelia ===SORRY!=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> } }; my X $x .= new: x => pi; $x.x = 3;ā<EOL>
grondilu m: class X { has $.x; method FALLBACK($str, $value) is rw { Proxy.new: FETCH => method { $!x }, STORE => method ($v) { say "storing!"; $!x = $v } } }; my X $x .= new: x => pi; $x.x = 3;
camelia Cannot modify an immutable Num (3.141592653589793)
in block <unit> at <tmp> line 1
23:54 sena_kun left
grondilu wth am I doing? 23:54
Voldenet you're trying to modify constant pi ;)
I'm glad you couldn't
grondilu If I use fallback I don't need a proxy anymore, but I have to process the arg and check it's an attribute name. 23:55
Voldenet m: class X { has $.x is rw; method FALLBACK($str, $value) is rw { Proxy.new: FETCH => method { $!x }, STORE => method ($v) { say "storing!"; $!x = $v } } }; my X $x .= new: x => pi; $x.x = 4; say $x.x
camelia 4
Voldenet m: class X { has $.x is rw; method FALLBACK($str, $value) is rw { Proxy.new: FETCH => method { $!x }, STORE => method ($v) { say "storing!"; $!x = $v } } }; my X $x .= new: x => pi; $x.x = 4; say $x.x; say now - BEGIN { now } 23:56
camelia 4
0.01807157
grondilu the proxy wasn't called
FALLBACK can't be triggered since there is a candidate 23:57
but that's actually what I want for my project
I want to emulate attributes through a hash that contains names of pseudo-attributes 23:58
so FALLBACK will be triggered. 23:59
It might be perfect.