🦋 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:00 reportable6 left, reportable6 joined 00:07 jgaz joined
Tirifto Is the usual syntax for default attribute values not supposed to work in declarations of custom subclasses of List? 00:26
m: class Gold is Array { has Int $.carats = 0 }; say Gold.new.carats; 00:27
camelia (Int)
Tirifto class Gold is List { has Int $.carats = 0 }; say Gold.new.carats;
evalable6 (Int)
Tirifto Oh wow, I had no idea camelia had competition. :o But anyway, is that intentional? Should that have been obvious from reading some part of the docs? 00:28
00:34 derpydoo joined 00:44 kjp left 00:57 kjp joined
guifa_ Tirifto: it should probably be mentioned. I believe the issue is that List and Array have special .new() 01:13
rather than default to Any/Mu's .new 01:14
Tirifto Ah, so attribute defaults are dependent on .new. That makes sense, thank you, guifa_. 01:16
guifa_ either on .new or on one of the methods that get called by default by it (e.g. BUILD TWEAK etc)
for instance, if you call
Gold.new( carats => 1 ), how does it distinguish you wanting that from being the first item, or an attribute? 01:17
(technically, Pair.new('carats', 1) makes it a positional, and :1carats, carats => 1, :carats(1) make it named argument, but YMMV if relying on that is desirable) 01:18
Tirifto Yeah, it’s fairly apparent when passing values to »new«. Less so with the defaults we put in class definitions, though, since however Raku makes those happen is not that obvious to the naked eye, or at least not to that of mine. 01:20
01:21 jpn joined
Tirifto One could suppose it’s just a way of setting default values for the .new method (or some such), but my first assumption was that it was more direct than that. 01:23
Though I haven’t attentively read through classtut recently. x)
01:26 jpn left
guifa_ could probably do this a bit more elegantly with a trait but 01:27
m: class Gold is Array { has Int $.carot; method new(|c) { callsame!defaults(|c) }; method !defaults(|c) { $!carot = c<carot> // 1; self } }; Gold.new(1,2,3).carot.say; Gold.new(1,2,3).say; Gold.new(1,2,3,:4carot).carot.say
camelia 1
[1 2 3]
4
guifa_ so first one you can see the default value of one is set, the next one shows an actual array is produced, and the last one shows the :4carot being interpreted as a default value 01:28
err as an attribuet value
okay 01:42
so I can't find a way to get the default value of an attribute
but this will probably be much cleaner for you
m: role Subarray[*%defaults] is Array { method new(|c) { callsame!defaults: |c }; submethod !defaults(|c) { .set_value(self, c.hash{.name.substr(2)} // %defaults{.name.substr(2)}) for (self.^attributes (-) Array.^attributes).keys; self } }; class Gold does Subarray[:0carot] { has Int $.carot }; Gold.new(1,2,3, :4carot).carot.say; Gold.new(1,2,3).carot.say, Gold.new(1,2,3).say 01:44
camelia 4
0
[1 2 3]
guifa_ now all you have to do is include that role, and you can just say `does Subarray[ attribute => default-value, attribute => default ]`. You have to repeat the attribute name in the Subarray parameterization and in the attributes, but otherwise fairly clean 01:46
hope that helps a bit :-) 02:05
02:16 razetime joined 02:24 teatwo joined 02:25 teatwo left 02:26 teatwo joined 02:27 tea3po left 03:00 lichtkind_ left 04:00 quotable6 left, bisectable6 left, bloatable6 left, unicodable6 left, statisfiable6 left, nativecallable6 left, linkable6 left, sourceable6 left, squashable6 left, tellable6 left, evalable6 left, releasable6 left, committable6 left, notable6 left, coverable6 left, greppable6 left, benchable6 left, shareable6 left 04:01 evalable6 joined, releasable6 joined, greppable6 joined, committable6 joined, statisfiable6 joined, quotable6 joined, linkable6 joined 04:02 bisectable6 joined, bloatable6 joined, nativecallable6 joined, shareable6 joined, sourceable6 joined, squashable6 joined, unicodable6 joined 04:03 benchable6 joined, notable6 joined, tellable6 joined, coverable6 joined 04:05 razetime left 04:20 razetime joined 04:55 jpn joined 05:00 jpn left 05:10 derpydoo left 05:45 Util left, Util joined 06:00 reportable6 left 06:02 reportable6 joined 06:03 jpn joined 07:03 statisfiable6 left, notable6 left, bloatable6 left, committable6 left, squashable6 left, quotable6 left, evalable6 left, benchable6 left, unicodable6 left, bisectable6 left, greppable6 left, sourceable6 left, reportable6 left, releasable6 left, tellable6 left, coverable6 left, nativecallable6 left, shareable6 left, linkable6 left, quotable6 joined, tellable6 joined 07:04 statisfiable6 joined, committable6 joined, nativecallable6 joined, sourceable6 joined, reportable6 joined 07:05 evalable6 joined, benchable6 joined, releasable6 joined, squashable6 joined, greppable6 joined, coverable6 joined, shareable6 joined 07:06 bisectable6 joined, notable6 joined, unicodable6 joined, linkable6 joined, bloatable6 joined 07:07 euandreh left 07:08 euandreh joined 07:09 jpn left 07:22 abraxxa joined 07:34 mark22k left, mark22k joined 08:00 Sgeo left 08:06 abraxxa left 08:08 abraxxa-home joined 08:24 jpn joined 08:29 abraxxa-home left 08:30 jpn left 08:32 jpn joined 08:33 razetime left 08:41 sarna left 08:49 razetime joined 09:13 razetime left 09:27 razetime joined 09:46 razetime left 10:46 linkable6 left, evalable6 left 10:49 evalable6 joined 10:50 linkable6 joined 11:09 xelxebar left 11:10 xelxebar joined 12:00 reportable6 left 12:01 reportable6 joined 12:22 jgaz left 13:22 evalable6 left, linkable6 left 13:23 evalable6 joined, linkable6 joined
[Coke] lizmat: did you happen to ever get raku-land running locally on your mac? 13:42
lizmat must admit I never tried
[Coke] ok. I hope to be able to spend some cycles later today trying to sort out my remaining issues.
If I get it working, will make sure we have a paragraph in the README 13:43
lizmat ++[Coke]
tonyo what are you doing in RL ? 13:55
14:23 tea3po joined 14:25 teatwo left 14:26 teatwo left 15:25 candlestick joined, candlestick left 15:35 Sgeo joined 15:40 amenonsen left 15:41 amenonsen joined 16:09 jgaz joined 16:39 Guest2884 joined 17:06 [Coke] left 17:07 [Coke] joined 17:22 euandreh left 17:38 Guest2884 left
[Coke] what is gmark? 17:55
gitlab.com/raku-land/raku-land/-/b.../bin/gmark 17:56
ah, github.com/gbagan/gmark maybe 17:57
18:00 reportable6 left 18:03 reportable6 joined 18:14 jpn left 18:15 jpn joined
[Coke] gitlab.com/jjatria/lorea/-/issues/4 - anyone else able to dupe this issue? 19:06
this seems to be the blocker for me. 19:10
(getting raku-land working locally)
19:15 evalable6 left, linkable6 left, destroycomputers left 19:16 Vyrus left, destroycomputers joined 19:17 evalable6 joined, linkable6 joined 19:27 derpydoo joined
[Coke] ok, have a broken version of raku-land in the firefox browser locally, that's progress. 19:53
20:04 Vyrus joined 20:06 Guest2884 joined
[Coke] the css isn't being included for some reason. 20:24
missing the <link> to include it entirely.
can someone point me at what this is doing? gitlab.com/raku-land/raku-land/-/b...crotmp#L33 20:30
aha! 20:41
now have a nice looking local raku.land (with almost no dists because i only did one of each)
20:55 jpn left 21:00 MasterDuke joined 21:06 jgaz left 21:08 jgaz joined
[Coke] is there a version of $*ARGS that doesn't include the options? 21:10
I mean @*ARGS
is there a whateverable that would let me test a distro with various versions? 21:13
gitlab.com/jjatria/lorea/-/issues/4 might fix it 21:23
21:28 TieUpYourCamel left, TieUpYourCamel joined
[Coke] (gmark is github.com/yuin/goldmark btw) 21:42
22:04 goblin left 22:05 goblin joined 22:20 cm left 22:26 cm joined
[Coke] \o/ 22:27
Tirifto guifa_, thank you for those examples! For my current use case, a class with an array as an attribute will probably work fine, but your last example shows magic I wouldn’t have though of, and it’s very interesting to read. :-) 22:30
[Coke] raku.land/build has a few errors that could maybe be tickets on distros. 22:31
e.g. github: Could not resolve to a Repository with the name 'tony-o/p6-db-xoos-mysql'. 22:32
(wonder if that's from an old published version since latest m6 seems fine) 22:33
22:34 Guest2884 left 22:47 candlestick joined 22:50 candlestick left 23:26 derpydoo left
tonyo [Coke]: what're you hooking up in raku land? 23:55