wayland76 Hi all. I have a .new method, and it has called "callwith" to create the object. In the code that comes after the "callwith", it's still telling me that I can't do things on a partially-constructed object. How do I let raku know that this object should be considered fully-constructed? 00:24
00:28 derpydoo joined
wayland76 (I'm trying to make something that acts like TWEAK, but after the object construction has been completed) 00:37
01:08 derpydoo left
timo i think if you use what's returned from one of the "new" methods you should be able to do normal stuff with it, can you share some code? 01:32
m: class Yours { has $.foo is rw; method frob { $.foo = 99 }; }; class Mine is Yours { method new { my $res = callwith(:foo(99)); $res.frob; say $res } }; say Mine.new(); 01:34
camelia Mine.new(foo => 99)
True
timo wayland76: is your code anything like this? 01:35
01:52 hulk joined 01:53 kylese left 02:15 hulk left, kylese joined 02:16 Aedil joined 02:30 kylese left 02:34 kylese joined 03:40 silug left 03:42 silug joined 04:34 Aedil left
wayland76 timo: gist.github.com/wayland/7899d75548...63961e59fc 04:40
Line 38 is where the problem is. 04:42
If there's already a module that does something like this, I'd be happy to know about it :) 04:43
05:25 kjp left 05:26 kjp joined 05:29 kjp left 05:30 kjp joined 05:31 kjp left 05:32 kjp joined
ab5tract You are still inside the new method though.. 08:39
08:42 Aedil joined
ab5tract That might be enough to trigger the partially constructed error 08:42
lizmat wayland76: looks like you forgot to add "self" on line 17 > 08:44
?
my $this = callwith(self, |@positional, |%named); 08:45
methods always expect the first argument to be the invocant, even if it is a type object 08:46
08:50 Sgeo left 09:11 sena_kun joined
wayland76 lizmat: Thanks! Even with that fixed, though, I get the same error. 09:32
ab5tract: Yes, I suspected that was the problem. I'm asking if there's a way to turn it off at a certain point. I'd like to turn it off before the POST-TWEAK methods get called. 09:34
lizmat with RakuAST I get: Cannot look up attributes in a A type object. Did you forget a '.new'? 09:35
on line 36
shouldn't line 22 be: $this.POST-TWEAK(); 09:37
??
also: what are you trying to achieve in lines 31/32 ? 09:39
if you do't want accessors (from the comment: "not public"), define with: has Str $!object-name ? 09:40
also if $!object-slug is supposed to be "not public", how are you expect $.object-slug to be working? 09:41
wayland76 Line 36 should be a submethod. Regarding line 22, I'd like to call all the POST-TWEAK methods, which is why I'm using $type, but I'm concerned it might not call it with the object as the invocant. 09:46
Please ignore the "not public" comments. They're left over from when I copy-pasted the code. I was drawing a distinction between "public" and "protected", which is I think not a distinction supported by Raku. 09:48
Also, the line numbers you're using are not the same as the ones I'm seeing for some reason. It took me a while, but everything you said makes a lot more sense if I add 2 to each line number you mentioned. Weird :) . 09:50
lizmat ah, I removed the hash bang oops 09:51
wayland76 Right. Well, I just updated the gist :) 09:52
lizmat line 23: for $type.can('POST-TWEAK') -> &method {
method($this);
}
appears to make it do what you want in RakUASR 09:53
T 09:54
actually, I don't think you need to run the ^mro
the .can already gives you a list of candidates
perhaps a for $type.can('POST-TWEAK').reverse to get the order you want ? 09:55
changing line 52 to: say self.object-slug; also fixes it on the legacy grammar 09:56
wayland76 I've upgraded last week -- I'm now on January's raku
OK, that's better. When was/will RakuAST be released? 09:57
lizmat as soon as it's ready
wayland76 OK, but are we thinking months or years, or partway in between? 09:58
(won't hold you to it :) )
lizmat I'm hoping for a push the coming months, for a late 2024 / early 2025 release 09:59
wayland76 OK, that's the kind of info I was looking for. Thanks! :) 10:00
lizmat I think this is more or less what you wanted: gist.github.com/lizmat/c123c39edf1...5fae45cb3f 10:06
10:13 MoC joined
wayland76 you left out the "self" on the callwith that you recommended. 10:16
...correctly, it seems. 10:18
lizmat yeah... callwith is smart enough it's being called from a method 10:23
*to know
wayland76 That looks good though -- thanks for the improvements :) 10:25
lizmat you're welcome :-)
12:19 xinming left 12:21 xinming joined 13:24 MoC left 13:48 oodani left, oodani joined
antononcube It seems to me that a new answer here has to be posted: stackoverflow.com/q/47941500/14163984 13:59
... And probably rename the question as "Using a hash with object keys in Raku". 14:00
14:34 BooK2 joined 14:36 PotatoGim__ joined, Geth__ joined 14:37 destroycomputer- joined, esh joined 14:38 japhb_ joined, ky1 joined 14:41 PotatoGim_ left, Geth left, Altreus left, esh_ left, japhb left, BooK left, destroycomputers left, rjbs left, ky left, BooK2 is now known as BooK 14:42 PotatoGim__ left 14:43 PotatoGim joined 14:49 Altreus joined 14:50 rjbs joined 14:52 [Coke] left
tbrowder note not too early for Raku Advent 2024. i’m gonna take 1 dec when i get home. title: “Santa’s Print Shop” 16:40
16:49 [Coke] joined 17:39 derpydoo joined 17:42 maylay left 17:50 maylay joined 17:58 Aedil left 18:09 maylay left 18:11 maylay joined 18:18 Sgeo joined 18:35 derpydoo left
ab5tract tbrowder++ 18:43
Geth__ advent: tbrowder++ created pull request #112:
Add new directory for year 2024
18:58
advent/main: 8afbf0c1cd | (Tom Browder)++ | 2 files
Add new directory for year 2024

Also add my name and article title
18:59
advent/main: 3f6d73df61 | (Tom Browder)++ (committed using GitHub Web editor) | 2 files
Merge pull request #112 from tbrowder/main

Add new directory for year 2024
19:09 wayland76 left, wayland joined 19:54 xinming_ left 19:55 xinming left 19:56 xinming joined 19:57 xinming_ joined
ab5tract Well this took a bit of time: github.com/ab5tract/comma-plugin/c...4e0a781454 19:57
antononcube: next time you have any slowdown, this will let you disable any or all of the inspections (formerly annotations) 19:58
22:48 sena_kun left