This channel is intended for people just starting with the Raku Programming Language ( Logs are available at
Set by lizmat on 8 June 2022.
00:05 MasterDuke left 00:06 Kaipei is now known as Kaiepi
SmokeMachine stevied: you could have that as Red models on a SQLite file stored o resources dir. I’ve never tried this, but I don’t see why that wouldn’t work… 00:31
stevied Red models? 00:50
this? 00:51
SmokeMachine stevied: you don’t really need Red for that, but yes: 00:52
stevied interesting, I'll make note 00:53
ok, still a little fuzzy on building attributes. got this: 00:54
class Resource {
class Lesson is Resource {
has IO $.file;
has Str $.name;
submethod BUILD(IO:D :$file) {
$!name = $file.basename;
$!file = $file;
how do I move `$.name` up to `Resource` class and still populate it in the BUILD?
I've got to do a new() method and bless the object first, is that it? 00:55
SmokeMachine Why are you using BUILD in that case? 00:57
stevied hmm, I don't know but I clearly don't know what I''m doing. I was just trying to avoid doing the whole self/bless thing 01:00
but your question has me thinking
SmokeMachine m: class Resource { has $.name = self.?file.?basename }; class Leason is Resource { has IO() $.file }; dd :file</bla/ble/bli> 01:01
camelia => Any)
SmokeMachine class Leason { has IO() $.file; has Str $.name = $!file.basename}; dd :file</bla/ble/bli> 01:02
m: class Leason { has IO() $.file; has Str $.name = $!file.basename}; dd :file</bla/ble/bli> 01:03
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared name:
Resource used at line 1
stevied huh, didn't know you could do that. but $.name is not always based on a file. for other children it's based on a directory 01:04
SmokeMachine m: class Lesson { has IO() $.file; has Str $.name = $!file.basename}; dd :file</bla/ble/bli>
camelia Lesson bli = =>"/bla/ble/bli", :SPEC(IO::Spec::Unix), :CWD("/home/camelia")), name => "bli")
SmokeMachine m: class Resource { has $.name = self.?file.?basename }; class Lesson is Resource { has IO() $.file }; dd :file</bla/ble/bli> 01:05
camelia =>"/bla/ble/bli", :SPEC(IO::Spec::Unix), :CWD("/home/camelia")), name => Any)
SmokeMachine m: role Resource { method name(—> Str) {…} }; class Lesson does Resource { has IO() $.file; has Str $.name = $!file.basename }; dd :file</bla/ble/bli> 01:08
camelia ===SORRY!=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> role Resource { method name(⏏—> Str) {…} }; class Lesson does Resourc
SmokeMachine (Sorry, that’s hard on phone…) 01:09
m: role Resource { method name(--> Str) {…} }; class Lesson does Resource { has IO() $.file; has Str $.name = $!file.basename }; dd :file</bla/ble/bli> 01:10
camelia Lesson bli = =>"/bla/ble/bli", :SPEC(IO::Spec::Unix), :CWD("/home/camelia")), name => "bli")
SmokeMachine stevied: wouldn’t that make more sense in that case then?
m: class Resource { has $.name }; class Lesson is Resource { has IO() $.file; method TWEAK(|) { $!name = $!file.basename }; dd :file</bla/ble/bli> 01:14
camelia ===SORRY!=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> me }; dd :file</bla/ble/bli>⏏<EOL>
expecting any of:
statement end
statement modifier
SmokeMachine m: class Resource { has Str $.name }; class Lesson is Resource { has IO() $.file; method TWEAK(|) { $!name = $!file.basename } }; dd :file</bla/ble/bli> 01:15
camelia ===SORRY!=== Error while compiling <tmp>
Attribute $!name not declared in class Lesson
at <tmp>:1
------> TWEAK(|) { $!name = $!file.basename } }⏏; dd :file</bla/ble/bli>
expecting any of:
horizontal w…
stevied ok, I just changed the BUILD method to a new() method 01:32
that worked
everything seems to work now 01:35
guifa stevied: when I meant not supposed to provide, I mean that AIUI the files provided from hashy access to $?DISTRIBUTION and %?RESOURCES are supposed to just provide access to the files (e.g. no .add or .parent or .dir methods) 01:37
s/the files/Resources 01:38
installation of a module will normally name mangle those file names, and put them in a flat directory structure, regardless the organization originally layed out by the developer 01:41
stevied here's my code: 01:46
seems to work well. i'm not sure what any downsides would be
see lines 44 and 21
ok, so the dir calls in 44 and 21 will probably not work then after the module is installed? 01:55
02:58 Util left 03:26 frost joined
guifa correct. They may work even, but — this is the key thing — there is no guarantee of them functioning long term 04:16
05:08 frost left
gfldex <@319829168395124737> gather/take is still pretty slow. 05:10
05:23 frost joined
Nemokosch Well then that's something to consider improving, I'd say 07:07
Even gather/take is rather low-level, let alone implementing a custom Iterator... 07:08
07:11 frost left 07:14 frost joined
lizmat Making iterator classes is really easy thoough: 07:16
m: class A does Iterator { has int $!count; method pull-one() { $!count++ } }; say
camelia (0 1 2 3 4 5 6 7 8 9)
Nemokosch because you didn't have manage state 07:17
if you compare the codes for this "smart branching", the ones with gather/take are at least fundamentally readable 07:18
the iterator based is ridiculously difficult to follow even that I know what it has to do
lizmat Nemokosch: that may be so, but the mechanics of creating an iterator itself, are pretty easy 07:37
Nemokosch Well I'm not talking about the mechanism 07:38
From what I understood, making a custom Iterator is like the last bastion of feasibility 07:39
so if it can be meaningfully done with gather/take, that should be preferred - especially given the structure of the problem
if gather/take is pretty slow, that should be improved rather than taking it at face value tbh
lizmat well, fwiw, I *have* looked at speeding up gather / take 07:40
Nemokosch mind you, I'm not "making calls", just saying what I believe aligns with the use (and usefulness) of the language 07:42
lizmat the problem is that use of continuations (exceptions) under the hood
wrt performance 07:43
08:05 discord-raku-bot left, discord-raku-bot joined 08:10 dakkar joined 08:23 MasterDuke joined 09:58 frost left 10:24 frost joined 11:26 frost left
lizmat and yet another Rakudo Weekly News hits the Net: 12:20
12:52 Util joined 13:16 jgaz joined 13:29 jgaz left
guifa lizmat: re the Did You Know? Reminds me that one of my next Intl:: modules is one for emoji names 14:03
CLDR has a great little database of common names — that's what Android/iOS use when you search for them 14:04
gfldex <@297037173541175296> indeed. It took me a while to realise that I can stash a value away that needs to go into the next bash. 15:09
15:33 dakkar left 18:18 lizmat left, thowe left 18:21 thowe joined, lizmat joined 18:23 thowe left 18:29 thowe joined 18:53 n1to joined 19:16 samebchase3 joined 19:19 destroycomputer- joined, sivoais joined, zmoment_ joined 19:24 discord-raku-bot left, zmoment left, sivoais_ left, gfldex left, samebchase left, destroycomputers left, samebchase3 is now known as samebchase 19:25 gfldex joined, discord-raku-bot joined 20:06 Util left 20:23 Kaipei joined 20:27 Kaiepi left 20:50 Util joined 21:59 n1to left
m:``` 22:00
sub batch2(*@a, :&predicate) {
my @r;
lazy gather for @a »,» @a[1..*] -> [$v, $next] {
if predicate($v) eqv predicate($next) {
} else {
take @r;
@r = [];
That is actually wrong. >>,>> wraps around. 22:06
m:``` 22:27
sub batch2(*@a, :&predicate) {
my @r;
lazy gather for @a.rotor(2=>-1, :partial) -> [$v, $next? = Nil] {
if predicate($v) eqv ($next === Nil ?? Nil !! predicate($next)) {
} else {
take @r;
@r = [];
That's the nilhilistic solution. :-> 22:29