This channel is intended for people just starting with the Raku Programming Language ( Logs are available at
Set by lizmat on 8 June 2022.
00:00 kjp left, kjp joined 01:07 NemokoschKiwi left 02:43 rf left 03:23 Kaiepi left 03:55 Kaiepi joined 07:16 Kaiepi left 08:33 Manifest0 left 11:15 Kaiepi joined 12:44 atroxaper joined
atroxaper Hello, #raku-beginner! Happy New Year! Do you know Raku analogue of C#/Java WeakReference system? The system allows to have a reference to an object, but do not prevents of GC work on it. 12:47
lizmat this feels like an X-Y question 12:56
there are no references in Raku, at least not at a level that a normal user would care about 12:57
atroxaper: could you explain what you're trying to achieve ?
atroxaper There are some cache algorithms where we have a storage with "weak reference" to objects. When GC wants to clean up the object, the weak reference is not a reference for GC. After GC clean up the "weak reference" will point to null. 13:01
lizmat you would have to forcibly evict cached values 13:03
perhaps could be of use ?
otherwise something like: %cache{%cache.keys.head}:delete while %cache.elems > 100 13:04
perhaps better: %cache{%cache.keys.head(%cache.elems - 100)}:delete if %cache.elems > 100 13:05
since the order of keys in a hash is random, this would randomly delete keys 13:06
atroxaper lizmat: It is not about cache issue for me. I'm always ask about strange things:) Imagine, you have on object. You do not control it. But you want to associate a value with the object, but do not want to prevent a GC work. One more think, you want to store the value *outside* the object. So you cannot mixin something to it. 13:08
lizmat you could cache on the .WHICH of the object
atroxaper lizmat: how for example? 13:10
lizmat my %cache; %cache{$object.WHICH} = 42
Nemokosch what are objects stored by in a Hash, by default? 13:11
I would have thought they are stored by WHICH either way
lizmat by their stringification
atroxaper Oh, yes. I read WHAT instead of WHICH :) 13:12
Nemokosch gotcha
lizmat m: my %h; dd %h.of, %h.keyof
camelia Mu
13:12 Kaiepi left
lizmat so the default is coercion to Str 13:13
atroxaper lizmat: then I do not know when $object will gone. I will have a "memory leak".
Nemokosch oh, keyof is new to me
lizmat 13:14
13:15 Kaiepi joined
lizmat atroxaper: perhaps a DESTROY method on the class that updates that cache ? 13:16
Nemokosch Would you understand what this is trying to say, by the way:
> Returns the parameterized key used for the Associative role
atroxaper lizmat: unfortunately, I doesn't control the class :( 13:17
lizmat: Anyway. I have a backup plan to archive the goal. Thank you! :)
lizmat and yet another Rakudo Weekly News hits the Net: 13:57
14:07 atroxaper left
guifa lizmat youlinked to the P6C version of DateTime::TImezones for my module, should be 15:12
15:39 ab5tract joined 15:45 guifa_ joined 15:51 ab5tract left 15:52 ab5tract joined 16:11 ab5tract left 16:33 ab5tract joined 16:46 jgaz joined 17:37 jgaz left
lizmat guifa_: thanks, fixed 17:40
17:52 Kaiepi left 18:36 Kaiepi joined 21:10 Kaiepi left 21:38 NemokoschKiwi joined 21:48 Kaiepi joined, jaguart left 22:02 jgaz joined 22:06 jgaz left 22:10 jaguart joined