00:13 qorg11 left 00:14 qorg11 joined 07:05 dakkar joined 08:31 destroycomputers left 08:32 destroycomputers joined 09:49 neither joined 09:54 discord-raku-bot left, discord-raku-bot joined 10:21 wingfold joined 10:56 razetime joined 12:20 neither left 13:10 razetime left 13:25 razetime joined 14:13 qorg11 left 14:26 qorg11 joined 15:06 razetime left 15:20 neither joined, razetime joined 15:41 dakkar left 16:00 razetime left 17:21 zacts joined 17:40 zacts left 18:03 zacts joined 18:11 zacts left 19:12 wingfold left
neither hi how can I make a public attribute of an object Nil in the class definition? 20:01
aim is to signal null-ness of that attribute 20:02
`has $.attr = Nil` triggers `Any` to be assigned
and `has $.attr := Nil` isn't supposed to work I guess
or should I do this some other way? 20:03
21:24 jgaz joined 21:30 jgaz left
MasterDuke it has to be typed as `Mu`. e.g., `has Mu $.attr = Nil` 21:31
otherwise assigning Nil sets something to its default value. and the default default is `Any` 21:32
Nemokosch isn't checking .defined a legitimate option, rather than checking for Nil? 21:44
gfldex <@297037173541175296> definedness and Nil are different answers to different questions. 21:58
neither ty MasterDuke but `$obj.attr` is now `Mu` not Nil; it's as if `has $.attr = Mu;` I think 22:04
gfldex m:``` 22:06
class C {
has Mu $.attr = Nil;
submethod TWEAK { $!attr := Nil }
}
dd C.new.attr;
```
m:```
class C {
has Nil $.attr;
}
dd C.new.attr;
```
gfldex neither: You you really want to stick Nil into an attribute, you can. But you are most likely got Nil wrong. 22:07
We got Nil because we want Failure. Since, we now got Nil we have to deal with assignment of Nil to containers. By definition, Nil reverts a container to it's default value. 22:09
What does it mean to have Nil as a default value in that regime?
neither let me ask this way 22:10
if you have a linked list, every node but the head has a parent
how would you code the `$head.parent`'s value? 22:11
i'm not insisting on Nil, I thought it was conventional way to signal None-ness
gfldex I would use a singleton that is an undefined value.
MasterDuke `Empty` perhaps
gfldex m: class Node { has Node $.parent; has Node $.next; } dd Node.new.parent.defined; 22:24
camelia ===SORRY!=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> { has Node $.parent; has Node $.next; }⏏ dd Node.new.parent.defined;
expecting any of:
infix
gfldex m: class Node { has Node $.parent; has Node $.next; }; dd Node.new.parent.defined;
camelia Bool::False
Nemokosch guess what, defined it is 😄 22:28