This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
00:53 teatwo left 00:54 teatwo joined 01:47 teatwo left, teatwo joined 05:38 discord-raku-bot left 05:39 discord-raku-bot joined 08:07 dakkar joined 10:17 Chanakan left 13:05 Chanakan joined
librasteve @pelevesque - sorry for jacking up the detail level ... next time we should find somewhere more suitable for this kind of discussion 13:53
and thanks for a thought provoking question!
14:12 lizmat left 14:15 lizmat joined
@gfldex I really like 2 of your last 3 answers (I think finding a Whatever in the wild would be a head scratcher tho') ... based on the fair point that @pelevesque made, I will raise a document issue to include one of these examples. 14:40
here goes ... github.com/Raku/doc/issues/4493 ... feel free to improve 14:41
16:34 dakkar left
pelevesque @pelevesque Thanks all. 17:23
@librasteve: I don't get: constant NaA = Array.new; # Not an Array 17:31
librasteve Yes - that's right. The constant declarator binds a name to an object. So, in the first case, we get a new Array and bind it to NaA. The key to the mystery is that NaA is a particular Array (ie. it's the Array stored at a particular memory location) which can be checked by going NaA.WHICH... 17:55
m: constant NaA = Array.new; say NaA.WHICH;
Raku eval Array|5299052779024
librasteve So, now when we test with =:= (the 'Container Identity Comparison Operator)' docs.raku.org/language/operators#infix_=:=, we are checking if the thing inside the sub body is the identical same Array as the default Array which we have named NaA and not any other Array - even an Empty one - that was passed in as an argument. [That's why I loke to hang out with the folks in the raku community ... they 18:00
are soooo smart!]
oh, and using an Array.new (or List.new) for this means that it is the right type if a check is done later 18:17
scullucs Cool solution. Maybe the name "NaA" is a bit misleading, I'd go for something like "DfltA", YMMV. 19:33
pelevesque Ah, ya, really nice. I agree with @lucs that NaA and NaH as names are a big misleading. Not sure what DfltA is though. 19:40
Maybe? constant refA = Array.new # reference Array constant refH = Hash.new # reference Hash 19:41
librasteve @pelevesque happy to ping pong ideas here on Discord - don't forget to add your thoughts to the docs issue I opened also 19:42
scullucs (Maybe I should have spelled out "DefaultA".) 19:43
pelevesque Ok, I'll think about it more and might add a comment in the docs on github if I come up with a stronger idea.
librasteve btw I was thinking: constant NaA = []; # Not an Array constant NaH = {}; # Not an Hash 19:45
pelevesque maybe dummyA?
The problem I have with NaA is that you are assigning an array to it... It makes my tiny brain go ouch. Like constant NaN = 42; I see what you want to do though. 19:46
librasteve good point
pelevesque Your solution is uber elegant though. I really like it. 19:51
Crips and clean. No fluff.
librasteve (kudos to @gfldex , not me)
pelevesque Electronic spiritual karma point dispatched to @gfldex. Thanks! 19:52
librasteve how about: constant ArrayAt = []; # a specific Array constant HashAt = {}; # a specific Hash 20:08
docs.raku.org/type/ObjAt
pelevesque Much better. Formally correct. 21:01
librasteve I have edited my docs issue accordingly
pelevesque Thanks for doing all this great work. 21:02
22:44 teatwo left, teatwo joined 23:58 tea3po joined