🦋 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:43 Manifest0 left
antononcube Anyone still around? 🙂 I have an advent post question. 02:14
I am not sure where to make the blog post: to my blog or to "Raku Advent Calendar". 02:17
@lizmat Here is the Markdown file I mentioned / promised: github.com/antononcube/RakuForPred...in-Raku.md . 02:19
@lizmat I know I should make a gist, but I can also make an HTML file instead, right? 02:20
02:23 gdown joined 02:31 kylese left 02:32 kylese joined 03:15 kylese left, kylese joined 04:40 MasterDuke joined
gdown Sets and hashes don't handle lists/classes as keys at all, is there a good way do it that I'm missing? Stringifying objects works, but feels absolutely horrible 05:17
05:45 hythm joined
hythm I'm trying to understand the purpose of `RUN-MAIN`, the docs says: "It gets a Callable that is the MAIN that should be executed". however, if I provided a new main, I see the default MAIN run as well: 05:53
tellable6 2023-11-26T09:48:45Z #raku <melezhik> hythm: I got you 😉
hythm m: sub new-main () { say "new main"}; RUN-MAIN(&new-main, Nil); sub MAIN() {say "main"} 05:54
camelia new main
main
hythm So my question is what is the purpose of RUN-MAIN, because it looks like I misunderstand its purpose 05:56
06:00 teatime left
japhb m: my $h := :{ set(3,4) => 12, <a b c> => 42 }; dd $h 06:09
camelia :{Set.new(4,3) => 12, ("a", "b", "c") => 42}
japhb gdown: You just have to specify an object-keyed hash ^^
06:24 teatime joined 06:30 izel joined
izel japhb: try retrieving <a b c>'s value please 06:31
how are we supposed to do that
06:37 hythm left 06:42 Xliff_ left
gdown m: my @a = 1,2,3; my $b = %{@a => 5} ; say $b{$(1,2,3)} 06:43
camelia 5
gdown izel: I could've sworn I tested it and it didn't work, but it apparently does
06:43 goblin left, goblin joined 06:44 izel left, izel joined
izel why isn't this working then though 06:47
m: my %h{List} = (0, 0) => 3; say %h{$(0, 0)}.raku
camelia Any
izel confusing
i guess i can't write the type List there it makes it bad
gdown That is weird 06:49
06:53 Xliff_ joined
gdown japhb: It also seems that if you set a class as a key, it only can be indexed by the original instance of the class, which doesn't work for what I'm trying to use it for 06:57
:m class T { has $.a }; my $a = T.new(a => 1); my $b = T.new(a => 1); my $c = :{$a => 5}; say $c{$a}; say $c{$b}; dd $c 06:58
err
m: class T { has $.a }; my $a = T.new(a => 1); my $b = T.new(a => 1); my $c = :{$a => 5}; say $c{$a}; say $c{$b}; dd $c
camelia 5
Hash[Mu,Any] $c = $(:{T.new(a => 1) => 5})
(Mu)
gdown stderr got jumbled into the middle of stdout there, but I hope the point is still clear 06:59
07:00 MasterDuke left 07:13 izel left 07:15 gdown left 07:34 constxqt_ left 07:49 constxqt_ joined 07:54 sena_kun joined 07:55 constxqt_ left 08:08 constxqt_ joined 08:12 jpn joined 08:13 constxqt_ left 08:22 jpn left 08:27 jpn joined 08:29 Sgeo left 08:32 jpn left 08:37 dbonnafo3 left 08:38 dbonnafo2 joined, Manifest0 joined 08:39 jpn joined 08:40 epony left, constxqt_ joined 08:43 jpn left 08:45 constxqt_ left
ab5tract grown: it uses WHICH inside, so only the object used as a key to store can be used as a key to retrieve 08:47
I haven’t had coffee yet so ymmv ;) 08:48
08:51 dbonnafo2 left 08:56 dakkar joined 09:02 jpn joined 09:25 derpydoo left 09:59 constxqt_ joined 10:04 constxqt_ left
ab5tract gd 10:12
*gdown
You can always use stringification of the object as the key 10:14
Or you can make a custom hash-like class that uses smartmatch. You will need to override ACCEPTS on the key classes because 10:20
The default object smartmatch won’t return true in the example you shared 10:21
lizmat in that light, raku.land/zef:lizmat/Hash::Agnostic might be interesting 10:22
10:25 constxqt_ joined 10:31 constxqt_ left 10:49 constxqt_ joined
ab5tract Oh nice! I was going to say, it’s sort of annoying to fully implement a hash “equivalent” class. Looks like lizmat++ already provides all that scaffolding 10:54
10:54 constxqt_ left 11:02 constxqt_ joined 11:07 constxqt_ left
nemokosch It honestly shouldn't come as a surprise that you need a hashable data type to use something as a hash key 11:15
There is nothing Raku-specific about this
11:34 constxqt_ joined 11:39 constxqt_ left
ab5tract I wouldn’t call it unreasonable to expect object hashes to use ACCEPTS instead of WHICH. It’s also not beyond imagination to expect default ACCEPTS to DWIM with objects that have the same attribute values. 11:49
In both cases Raku goes a different way but my own personal assumption on the matter is that these options would have been debated at implementation time. 11:51
11:53 constxqt_ joined
ab5tract Regardless of whether that’s true, Raku’s actually decently tunable around this, enough that the desired behavior is a role and three methods away. 11:56
11:57 constxqt_ left
lizmat when using ACCEPTS, how would one select the proper "key" without needing to check all keys to see whether ACCEPTed ? 12:08
ab5tract You’d have to do that indeed 12:12
Quite costly, but it might be an appropriate trade off
If you know your objects will be simple, for instance. Or limited in attribute count. 12:13
With a limited set of keys 12:14
I’d probably still go with a deterministic stringification, to be honest. 12:15
12:18 constxqt_ joined
lizmat and that is what .WHICH is supposed to be 12:25
ab5tract Right, but depending on the use case you could use .Str to make a looser but deterministic-for-the-context matching 12:30
Overriding .WHICH to not always resolve to a single object would probably cause problems, right? 12:31
lizmat yes 12:37
12:38 jpn left
nemokosch I would call it unreasonable to expect object hashes to use ACCEPTS 😛 12:39
I don't think they could be called "hashes" at that point 12:40
12:44 jpn joined
lizmat associative arrays then ? 12:44
12:52 jpn left
nemokosch maybe buckets 12:56
smartmatch is very very far from an identity relation, it's only sufficient for superficial grouping 12:57
ab5tract It’s clear that an identity relation is not what he is looking for, otherwise the default object behavior would work. 13:11
My point regarding “unreasonable” is that Raku uses ACCEPTS more or less seamlessly in a number of places. So it’s not unfounded. Maybe that would have been a better word choice 13:13
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2023/12/18/2023-...ore-magic/ 13:39
antononcube @lizmat Is the link to the Markdwon file of my post sufficient? Should I make gist of it? 13:57
@lizmat Here is the link: github.com/antononcube/RakuForPred...in-Raku.md
lizmat yeah, that'll work, thanks! 13:58
[Coke] (associative arrays) Shades of TCL! 14:00
14:04 epony joined
antononcube Great! 14:04
14:08 derpydoo joined 14:25 jpn joined 14:28 edr joined
nemokosch it probably is an identity relation what he's looking for, just not the one described by === 15:06
lizmat antononcube am a bit confused about the rendering of "basename => raccoons-with-snowballs.png" that feels incorrect ? 15:07
antononcube @lizmat This is a "default output" of the DALL-E magic cell when an export of an image is made. It uses .IO.parts.tail (or something similar.) 15:08
The function image-export is used by the DALL-E meta magic cells in "Jupyter::Chatbook". So, image-export instead of giving a True/False value gives the file path of the exported image, if the export was successful. That is helpful in bigger workflows. 15:11
@lizmat Do you think I should add more explanations in that document? Or it is "too late" now? 15:12
lizmat it's not too late... but please wait until I've done the initial version of the post :-)
antononcube 🙂 Ok. I am not sure what the overall procedure is... 15:13
lizmat antononcube you have a WP login it seems, so I will be able to give you a link with the draft version
antononcube Ok, good. 15:14
The advent instructions say to make a WordPress post -- where that post should have been: 1) my blog or 2) Raku Advent Calendar ?
lizmat Raku Advent Calendar.... and it's ready for your perusal: rakuadventcalendar.wordpress.com/?...eview=true 15:17
antononcube @lizmat Thanks! 15:18
@lizmat Should I make edits in the WordPress document? (The link you provided.) Or just GitHub in my GitHub file? 15:42
lizmat please in the WordPress document :-)
antononcube Ok. 15:44
16:25 sena_kun left, sena_kun joined 16:32 izel joined, izel left 16:34 sena_kun left, sena_kun joined 16:47 nine left, nine joined 17:03 sena_kun left, sena_kun joined 17:26 jpn left 17:38 jpn joined 17:46 dakkar left 17:47 jpn left 18:01 jpn joined 18:12 jpn left 18:43 jpn joined 20:04 jpn left 20:07 jpn joined
Geth advent/main: 1141a0a237 | (Elizabeth Mattijsen)++ (committed using GitHub Web editor) | raku-advent-2023/authors.md
Add Anton Antonov's post
20:25
lizmat only 2 slots left! 20:26
20:26 jpn left 20:29 jpn joined 20:36 jpn left 20:38 jpn joined
antononcube @lizmat I can volunteer for another post. When is the next slot / date? 20:51
lizmat 23/24
antononcube Ok, I am volunteering then -- a post titled "Streamlining AI vision workflows" (with Raku). Or something like that. 20:53
lizmat for the 24th then? 20:55
20:56 kylese left, kylese joined
Geth advent/main: 1c0e8f3f74 | (Elizabeth Mattijsen)++ (committed using GitHub Web editor) | raku-advent-2023/authors.md
Schedule another Anton Antonov for the 24th!
20:57
21:02 jpn left
antononcube @lizmat Yes, 24th is fine. 21:18
lizmat so scheduled :-) 21:19
21:20 Guest6036 joined 21:29 Guest6036 left 21:55 Guest6821 joined 22:05 Guest6821 left 22:06 epony left 22:08 Guest5572 joined 22:12 epony joined 22:20 epony left 22:21 Guest5572 left 22:25 epony joined 22:39 sena_kun left 22:47 Sgeo joined