🦋 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.
00:25 jpn left 00:26 jpn joined 00:29 guifa left
SmokeMachine I'd like to make it a compile-time thing... to break if the value-class is mutating it's attributes and /or it have mutable attributes... I think the first part may be possible with RakuAST... but the 2nd part not even with that, I think... An attribute can be of type Any and be populated with a List or an Array, for example... we only know when an object is instanciated, right? 00:40
Another thing is that I'm using `Proxy`s to be sure the attribute is not changed... That might be slow, right? but I can't find an different was for doing that... any suggestion? 00:41
00:44 jpn left
SmokeMachine even modifying `set_value()` would not help (as I learned on Red, and tried again now) 00:45
00:45 jpn joined
SmokeMachine m: class Bla { has $.a; method b { $!a = 42 } }; (my $attr = Bla.^attributes.head) does role :: { method set_value(|) { say "here" } }; my $bla = Bla.new; say "1st try: "; $bla.b; say "2nd try: "; $attr.set_value: $bla, 1 00:47
camelia 1st try:
2nd try:
here
01:04 jpn left 01:37 hulk joined 01:38 kylese left 02:15 hulk left, kylese joined
SmokeMachine is there a way to find out from the class type if its objects will be value objects? 02:26
m: for Array, List, Hash, Map { say .^name; say .WHICH.^name; say .new.WHICH.^name } 02:28
camelia Array
ValueObjAt
ObjAt
List
ValueObjAt
ObjAt
Hash
ValueObjAt
ObjAt
Map
ValueObjAt
ObjAt
SmokeMachine m: for Array, List, Hash, Map, Bag, BagHash, Set, SetHash { say .^name; say .WHICH.^name; say .new.WHICH.^name } 02:29
camelia Array
ValueObjAt
ObjAt
List
ValueObjAt
ObjAt
Hash
ValueObjAt
ObjAt
Map
ValueObjAt
ObjAt
Bag
ValueObjAt
ValueObjAt
BagHash
ValueObjAt
ObjAt
Set
ValueObjAt
ValueObjAt
SetHash
ValueObjAt
ObjAt
03:20 tirnanog left 03:23 tirnanog joined, tirnanog left 03:40 guifa joined 04:06 vrurg left 04:57 vrurg joined 05:30 Sgeo left 06:02 guifa left
Voldenet SmokeMachine: every class that returns value objects has `WHICH(–> ValueObjAt:D)` as one of multi dispatch candidates 06:32
m: sub is-valueobj($t) { $t.^methods.grep({.name ~~ "WHICH"}).flatmap(*.candidates).map(*.signature).grep({ .params[0].type eqv $t && .returns eqv ValueObjAt:D }).so }; for Array, List, Hash, Map, Bag, BagHash, Set, SetHash { say [.^name, is-valueobj($_), .WHICH.^name, .new.WHICH.^name] } 06:34
camelia [Array False ValueObjAt ObjAt]
[List False ValueObjAt ObjAt]
[Hash False ValueObjAt ObjAt]
[Map False ValueObjAt ObjAt]
[Bag True ValueObjAt ValueObjAt]
[BagHash False ValueObjAt ObjAt]
[Set True ValueObjAt ValueObjAt]
[SetHash False Val…
Voldenet hm, `.params[0].type eqv $t` doesn't consider inheritance 06:40
I'm suspecting it's possible to create a Signature object to match against WHICH directly 06:48
`$t.^can("WHICH") ~~ :($t –> ValueObjAt:D)` or something similar 06:49
07:02 thaewrapt left 07:10 thaewrapt joined 07:15 thaewrapt left 07:25 fluca1978 joined, fluca1978 left 07:26 thaewrapt joined 07:31 thaewrapt left 07:42 thaewrapt joined 07:52 thaewrapt left 07:54 wayland76 joined 08:02 beastieboo__ joined 08:04 beastieboo_ left 08:05 thaewrapt joined, beastieboo_ joined 08:08 beastieboo__ left
El_Che releasable6: status 08:18
tellable6 2024-06-27T19:22:44Z #raku-dev <jdv> El_Che 2024.06 release happened
releasable6 El_Che, Next release in ≈27 days and ≈10 hours. There are no known blockers. Changelog for this release was not started yet
El_Che, Details: gist.github.com/b82e54a21c385aabb8...b964ed7da4
El_Che ok 08:19
08:25 thaewrapt left 08:33 avuserow_ left, avuserow_ joined 08:36 thaewrapt joined 08:41 thaewrapt left 08:42 jpn joined 08:52 thaewrapt joined 08:58 thaewrapt left 09:09 thaewrapt joined 09:14 soverysour joined 09:15 thaewrapt left 09:18 soverysour left 09:26 thaewrapt joined 09:31 thaewrapt left 09:42 thaewrapt joined 09:49 thaewrapt left 09:55 thaewrapt joined 10:02 thaewrapt left 10:14 thaewrapt joined 10:19 thaewrapt left 10:30 thaewrapt joined 10:34 thaewrapt left
librasteve SmokeMachine: I like the concept of ValueClass … took a look at the strawman … is the idea that I go class MyClass Is ValueClass {…}? 10:45
10:46 thaewrapt joined
I guess you saw the grant proposal from codesections a while back … that was more a low level how to apply TRIEs or similar to making objects immutable at the low level iirc 10:47
also, I would say that for serious OO we should be relaxed about always wanting $! attributes and just making consumers go obj.attr: 42 rather than obj.attr=42 for setter methods 10:49
imo that’s the best use of the : 10:50
10:57 dpk left 10:58 dpk joined 11:02 thaewrapt left 11:13 thaewrapt joined 11:20 thaewrapt left 11:30 thaewrapt joined 11:36 thaewrapt left
El_Che still rerunning for failing t/09-moar/00-misc.t 11:44
that's the new biggest flipper test
11:46 thaewrapt joined 11:53 thaewrapt left 11:57 thaewrapt joined
El_Che cloudsmith push deb nxadm-pkgs/rakudo-pkg/ubuntu/oracular rakudo-pkg-Ubuntudevel_2024.06-01_amd64.deb 12:03
Checking deb package upload parameters ... ERROR
Failed to validate upload parameters! (status: 422 - Unprocessable Entity)
12:03 thaewrapt left
El_Che like with every release, I need to tell cloudsmith to add a repo 12:03
I am their canary
12:12 thaewrapt joined 12:18 hudo_ left 12:19 hudo_ joined 12:20 hudo_ left 12:21 hudo_ joined 12:44 sftp left 12:45 wayland joined 12:47 wayland76 left
lizmat El_Che: re t/09-moar/00-misc.t I've run that in a loop for 40 minutes on an Intel box, and didn't crash once :-( 12:58
13:20 jpn left
El_Che the github containers have less resources, that may be a factor 13:31
packages uploaded to repos 13:36
13:48 jpn joined 14:03 Sgeo joined 14:09 jpn left 14:13 jpn joined 14:54 soverysour joined 15:09 soverysour left
SmokeMachine Voldenet: thanks! I’ll see if I can improve the module with that… but now I’m thinking that I’ll need to wait to test it on instantiation any way… 15:11
librasteve: no, at least currently you would replace the keyboard class with the keyboard value-class 15:13
I was searching a way to not need to use Proxy on that for performance reasons… but couldn’t find a way… it just uses nqp::getattr(), right? If I override it… it will impact everything, right (and I’m not even sure if that’s possible…) 15:16
Does anyone have any idea on how I could replace Proxy on ValueClass with something to get a better performance? 15:17
(I haven’t test the performance… I just believe Proxy is slow… I could be wrong) 15:18
lizmat looks 15:19
m: my $a := 42; $a = 666 15:23
camelia Cannot assign to an immutable value
in block <unit> at <tmp> line 1
lizmat isn't that error message good enough for you?
because that appears to be the only reason for using a Proxy, right? 15:24
SmokeMachine Yes, but I need that on attributes…
lizmat: I just saw your ValueType (raku.land/zef:lizmat/ValueType)… 15:25
lizmat m: class A { has $.b; method TWEAK() { $!b := 42 } }; A.new.b = 666
camelia Cannot modify an immutable Int (42)
in block <unit> at <tmp> line 1
SmokeMachine Oh!!! That’s a great one!! 15:26
I’ll try that! Do you do that on ValueType? 15:27
If you do… I’ll probably delete mine…
It seem you only add a WHICH… 15:28
lizmat yeah, if you as an author decide to make make the attributes settable, then it cannot be a ValueType by definitionn 15:29
so I feel it's a case of DIHWIDT 15:30
I mean, even in your code it would be possible to circumvent the test
SmokeMachine Yes… it will be always possible, right? But you would need to try harder… 15:31
lizmat I guess it could also check the accessor methods
15:31 jpn left
SmokeMachine If it is rw?! I do it on attributes and on the whole class 15:32
lizmat m: class A { has $.a }; dd A.^find_method("a").signature 15:33
camelia :(A:D $:: *%_)
lizmat m: class A { has $.a is rw }; dd A.^find_method("a").signature
camelia :(A:D $:: *%_)
lizmat sadly, no difference in signature
SmokeMachine github.com/FCO/ValueClass/blob/mai...rakumod#L5 15:34
I changed the attribute’s compose() to die if it is rw 15:35
And the classes set_rw() to always die
(Metaclass’ I mean)
lizmat yeah, I saw 15:37
SmokeMachine Make sense? 15:38
I think I’ll do something your ValueType do, I’ll also cache the WHICH return…
lizmat yeah... but lemme see if it's easily added to ValueType
15:38 jpn joined
SmokeMachine If you add that (and the binds for each attribute) to your ValueType, I’ll probably make my ValueClass become just a keyword that applies your ValueType… 15:40
lizmat I was thinking of adding: 15:49
if @attributes.grep(*.rw) -> @mutables {
die "These attributes are mutable: "
~ @mutables.map(*.name).join(', ');
}
but I'm not sure it should go beyond that, really 15:52
SmokeMachine I think that’s ok… I can continue with CalueClass than… :) 15:56
And about the binding… I think I’ll need to continue with the proxies with Positionals and Associatives, right? glot.io/snippets/gxjkszeuxv 15:57
lizmat why not: "method a { $!a := 42 }" ? 15:58
also: you can specify on attributes is built(:bind) 15:59
SmokeMachine Sorry, I didn’t get it…
lizmat m: class A { has $.a is built(:bind) }
camelia ( no output )
lizmat m: class A { has $.a is built(:bind) = 30 } 16:00
camelia ( no output )
lizmat then you don't need the TWEAK
SmokeMachine I tested that and it was still not breaking and changeable (I may have done something wrong, of course)
lizmat m: class A { has $.a is built(:bind) = 30 }; A.new.a = 42
camelia Cannot modify an immutable Int (30)
in block <unit> at <tmp> line 1
SmokeMachine Oh! :bind?! I haven’t used that!
lizmat I guess you could add that to your metaclass., executing that trait_mod on it 16:02
SmokeMachine Yes… that’s my plan now… 16:03
There is a problem…
m: class C { has $.a is built(:bind) }; C.new.a = 13 16:05
camelia Cannot modify an immutable 'Any' type object
in block <unit> at <tmp> line 1
lizmat isn't that what you want?
SmokeMachine m: class C { has $.a is built(:bind); method a { $!a = 13 } }; C.new.a
camelia ( no output )
lizmat I mean value types are supposed to be immutable 16:06
SmokeMachine If there is no value it allows editin it from inside the class…
lizmat well, *that* I would consider a case of DIHWIDT
SmokeMachine m: class C { has $.a is built(:bind) = Any; method a { $!a = 13 } }; C.new.a 16:07
camelia assign requires a concrete object (got a Any type object instead)
in method a at <tmp> line 1
in block <unit> at <tmp> line 1
SmokeMachine Maybe I’ll need to always set something…
lizmat still I'm not clear of what you want *exactly* :-) 16:08
SmokeMachine I don’t want to give to the developer the chance to forget that shouldn’t be mutated…
lizmat but what if you would allow * to be specified for a value, but want to use Inf inside? 16:09
then being able to do: $!a := Inf if $!a ~~ Whatever inside TWEAK would be very helpful
SmokeMachine If the developer choose to use value-class instead of class… they shouldn’t be “allowed” to mutate…
Using Proxy I could just make my TWEAK run after the custom one and that would work… 16:11
It would be exame “mutable until TWEAK and immutable after TWEAK” 16:12
lizmat feels like a heck of a lot of complexity to guard against stupid developers :-)
SmokeMachine I don’t know the other developers… but I am stupid enough to need that… 16:13
I can also do the binding on TWEAK… 16:14
lizmat then by all means! :-)
going to have to go afk
laters&
SmokeMachine Thanks for your help!
16:15 soverysour joined 16:16 soverysour left 16:18 soverysour joined, soverysour left, soverysour joined, soverysour left, soverysour joined 16:40 soverysour left 16:55 soverysour joined 17:09 beastieboo__ joined 17:12 beastieboo_ left 17:52 sftp joined 18:11 JRaspass left, jjatria left, JRaspass joined, jjatria joined
SmokeMachine do we have something like Tuple (raku.land/zef:lizmat/Tuple) for Associative? My ValueClass is going to use Tuple by default when a Positional attribute is defined... I'd like to have something like that for Associative... 19:04
I think I found it... ValueMap (raku.land/zef:lizmat/ValueMap) 19:05
lizmat heh :) 19:06
SmokeMachine usercontent.irccloud-cdn.com/file/.../image.png 19:07
lizmat :-) 19:15
19:16 jpn left
SmokeMachine that makes sense, right? If I'm creating a class that can't have non value attributes, it makes sense to change the default class for @ and % attributes from non-values to values ones, right? 19:25
lizmat yes, it does :-) 19:27
SmokeMachine :) 19:30
lizmat: is this expected? I mean is that () around the values correct? usercontent.irccloud-cdn.com/file/.../image.png 19:41
19:41 soverysour left
lizmat yes, otherwise Map.new will interprete the pairs as named args 19:42
SmokeMachine :+1
👍
19:59 beastieboo_ joined 20:02 beastieboo__ left
SmokeMachine lizmat: should an empty Tuple be false? 20:20
m: say ?[]
camelia False
20:26 beastieboo__ joined 20:29 beastieboo_ left 20:38 xinming left 20:39 xinming joined
librasteve m: ().so.say 21:09
evalable6 Cannot test 7190eae29b8e7a1be56789a221ba14ded934c52a (Broken archive)
linkable6 (2024-06-27) github.com/rakudo/rakudo/commit/7190eae29b Merge pull request #5600 from rakudo/release-2024.06
Raku eval False
librasteve just reflecting that empty List is False 21:10
21:11 beastieboo_ joined 21:14 beastieboo__ left
SmokeMachine www.irccloud.com/pastebin/nwYc14ej/ 21:21
github.com/lizmat/ValueMap/issues/1
github.com/lizmat/Tuple/issues/4
21:32 beastieboo__ joined 21:34 beastieboo_ left
[Coke] What's the expectation YOU have on those tickets? Are they false and you don't know why? True and you expect false? 22:09
22:16 sena_kun joined
lizmat they should be False: Tuple fixed now, ValueMap I'll do tomorrow 22:38
sleep&
22:53 sena_kun left
SmokeMachine [Coke]: I would expect them to be false if empty… 23:31
23:32 guifa joined
SmokeMachine Hi guifa ! Did you see that? github.com/FCO/ValueClass 23:34
guifa SmokeMachine++ 23:35
SmokeMachine guifa: it has many improvements from that first version
guifa Perfect example by the way of why goign to conferences is so awesome
an idea was sparked during hallway track
and it got implemented within a day and a half
SmokeMachine Totally agree
antononcube @SmokeMachine and @guifa -- I assumed you still in Vegas gambling away the good karma you got from presenting TPRC. 23:36
guifa I left last night unfortunately $day-job wrecked my plans to be there the whole week
antononcube Not making new Raku values...
Agh -- I see.
SmokeMachine I’m just lm just going to my last walk (my wife wants me to buy some stuff for here) and I’m going back to UK tomorrow 23:38
guifa I'm hoping to make the london one 23:39
SmokeMachine If you do, I’ll see you there
_grenzo The London one is only 1 day...correct?
antononcube Las Vegas, London -- to far me.
guifa Yeah just a single day for London 23:40
SmokeMachine Yes, 1 day
antononcube Ah, yeah -- and just for one day!
SmokeMachine Is ValueClass the first Raku module changing the default types for @ and % attributes inside a class? 23:42
antononcube Well, I am currently making graphs (with Raku) -- so, a certain Raku conference would have been good place to discuss the corresponding packages. 23:43
cdn.discordapp.com/attachments/633...3e6ab&
Damn, the Petersen graph got "disfigured" again! 23:44