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:50 kjp left 02:25 teatwo joined 02:27 teatwo left 03:26 kjp joined
dano How are optional values handled in Raku? Let's say I have a class which has a field of type "Animal", which may or may not be present 07:31
Many languages might implement this by either having either a value or null
Can I just declare such a field as "has Animal $.animal;"? 07:32
And create it with a missing value as: => Nil); 07:33
lakmatiol There is Animal:D and Animal:U, Animal covers both. the :D stands for defiend, :U for undefined. You could get the undefined value via referring to the actual type Animal 07:34
> Str ~~ Str:U True > "A" ~~ Str:U False > Str ~~ Str:D False > "A" ~~ Str:D True 07:35
08:58 dakkar joined 10:59 Manifest0 joined 11:16 wafflus joined
dano Right, so I can assign Nil to Str or Str:U, but not Str:D? 11:17
wafflus how would i convert a sub to a method for example something like this? 11:23
sub minus($a,$b,*@a) {[-] $a,$b,@a}
nemokosch what would "convert to a method" mean here? 11:58
wafflus how to i write a method on an array 12:00
nemokosch dano: for assignment you are right but argument passing works on the principles of binding so Nil cannot stand for a missing e.g Str there
wafflus: do you want to alter the existing class or something? 12:01
wafflus i want to know the syntax of how add a new method on an array for example 12:03
lizmat if it's just one method: 12:25
m: my @a := but role { method foo { say "foo"}}; 12:26
camelia foo
lizmat note the use of := instead of =
alternately, if you need more of these arrays 12:27
m: class A is Array { method foo { say "foo"}}; my @a is A;
camelia foo
wafflus k thankyou will try it out now 12:35
k ths can't get it to work on my example i want to be able to do [1..5].minus 12:45
nemokosch That's a bit different: altering an existing type. It's possible via augmenting but it would be better for you to just not want it 😛 12:47
wafflus :) i' generally prefer using the build in methods it would be nice to have methods everywhere and not have to mix the two or be forced to use subs 12:53
lizmat m: sub minus(@a) { @a.min }; say [1..5].&minus
camelia 1
lizmat you can use subs as methods with the .& syntax 12:54
wafflus k i've been messing around with that a little i guess that will have to do 12:58
can i use the colon with the & syntax?
appears i can 12:59
m: (for 'a'...'c' { $_}).grep("b").say 13:25
camelia (b)
lizmat wafflus: for is just map under the hood :-) 14:44
And yet another Rakudo Weekly News hits the Net: 14:55
wafflus nice i was going to ask a questions about phasers but the repl was the problem 15:30
m: <pies cats>.uc.say 15:31
camelia PIES CATS
wafflus m: <pies cats>.WHAT
camelia ( no output )
wafflus m: <pies cats>.WHAT.say
camelia (List)
wafflus why does .uc work with hyper operators but i need to do .&WHAT do get it to work on all valuies? 15:32
m: <pies cats>>>.WHAT.say 15:33
camelia (List)
wafflus m: <pies cats>>>.&WHAT.say
camelia ((Str) (Str))
lizmat .uc stringifies its invocant
m: dd <pies cats>.Str
camelia "pies cats"
lizmat m: dd <pies cats>.Str.uc 15:34
camelia "PIES CATS"
lizmat m: dd <pies cats>.join(" ").uc
camelia "PIES CATS"
wafflus with hyper operators
lizmat is in fact what happens 15:35
wafflus feels a bit quirky maybe hard to predict if something will work on the whole thing or on each value 15:39
m:  <pies cats>».uc[0].say
camelia PIES
wafflus m:  <pies cats>».WHAT[1].say 15:40
camelia Index out of range. Is: 1, should be in 0..0
in block <unit> at <tmp> line 1
wafflus m:  <pies cats>».&WHAT[1].say
camelia (Str)
lizmat methods always work on the whole thing
<pies cats> is a single thing, a List
wafflus m: <pies cats>.uc[1].say 15:41
camelia Index out of range. Is: 1, should be in 0..0
in block <unit> at <tmp> line 1
wafflus m: <pies cats>».uc[1].say
camelia CATS
lizmat <pies cats>.uc is a single thing, a Str
.uc stringifies its invocant 15:42
wafflus yes but the hyper operator
lizmat but the hyper operator what? :-) 15:44
wafflus why doesnt .WHAT work the  same?
why doesn't it work on each element ?
.^name does not work either i need to but that in a script block 15:45
lizmat hmmm ... good question :-) 15:46
wafflus :P
lizmat I think this is worthy of an issue :-) 15:48
wafflus cool 15:49
i think maybe i did read something about certain things being nodal (no idea what that means) and certain things behaved differently but am not sure 15:51
but it all seems hard to predict what works and what will not
lizmat well, my feeling is that >>.WHAT and >>.^name should just DWIM 15:52
wafflus cool maybe you could edit the raku source code in your break. It's ok i won't tell Larry 15:54
lizmat well, I won't try to fix this in the legacy grammar, but I will be tempted to fix it in the new Raku grammar
also, something tells me you're not really a "beginner" :) 15:55
wafflus maybe just stupid then :)
me that is
i'm really jus messing around with someof the weird/cool things about raku 15:57
lizmat well beginners generally don't start with mentioning Larry
wafflus i watched some videos i;ve heard him mettioned :) 15:58
wears nice shirts
lizmat indeed they're so colourful! 15:59
sadly, Larry hasn't really been involved with Raku for the past 5 years or so
wafflus :(  does he work on the old perl?
retired 16:00
lizmat yeah, basically retired afaik
I don't think Larry has done anything on Perl 5 for the past 20 years
wafflus ah ok i guess he was working on raku before retring? 16:01
retiring 16:02
lizmat yes, he was, for 15+ years, I'd say
as health would allow
wafflus ah did not know he was sick:(  i wish him all the best 16:03
i liked your article on quote words btw 16:09
lizmat wafflus: Larry has had some serious health issues in the past, but he's ok now afaik 16:42
thank you :-)
wafflus cool great 16:43
are adverbs like :exists, pairs :a and [2,4,7].grep: and related to each ohter in anyway? 16:44
lizmat perhaps you find enlighting 16:45
wafflus ha:) 16:46
do you have a preference on your you write your subs and methods? 16:48
lizmat well, there are plenty of examples in my modules in the ecosystem: 16:52
wafflus nice 17:02
i was looking at the article and i was trying to do grep object: arg and it wouldn't work i was wondering is there something that makes it not work it says it should work on methods it works on split "apple pie": " " 17:05
i noticed when i did a .WHAT it said it was a label
but the manual says it a method 17:06
lizmat what was the exact code ? 17:10
wafflus on the link it says method $object: $arg so i tried 17:11
m: (grep [2,7,9]: {$_ > 2}).say
camelia ===SORRY!=== Error while compiling <tmp>
at <tmp>:1
------> (grep [2,7,9]:⏏ {$_ > 2}).say
expecting any of:
colon pair
lizmat m: say uc "foo": 17:12
camelia FOO
lizmat is what that is about
there the colon is the invocant marker
wafflus inovcant is that like the object itself? 17:14
m: say  split "apple pie": " " 17:15
camelia (apple pie)
wafflus m: say  grep  [2,4,7]: * > 2 17:16
camelia Cannot resolve caller print(Seq:D: BOOTStr); none of these signatures matches:
(Mu: *%_)
in block <unit> at <tmp> line 1
wafflus m: say  grep [2,4,7]: * > 2
camelia Cannot resolve caller print(Seq:D: BOOTStr); none of these signatures matches:
(Mu: *%_)
in block <unit> at <tmp> line 1
lizmat m: dd grep [2,4,7]: * > 2 17:17
camelia No such method 'dd' for invocant of type 'Seq'
in block <unit> at <tmp> line 1
lizmat hmmm fwiw, I have proposed deprecating the invocant marker for these oddities 17:18
confusion on what is the actual invocant as the reason, as see in the grep example 17:27
wafflus i'm just trying to understand all method and sub calling syntax. can be confusing when something works for one "method" and not another ( maybe things like grep and map or exception because they are labels 17:29
lizmat no, that's not the problem I think 17:30
m: say (foo:).^name
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
foo used at line 1
lizmat m: foo: say (foo:).^name 17:31
camelia ===SORRY!=== Error while compiling <tmp>
Variable '&infix:<:>' is not declared. Perhaps you forgot a 'sub' if
this was intended to be part of a signature?
at <tmp>:1
------> foo: say (foo⏏:).^name
lizmat m: foo: say WHAT foo:
camelia (Label)
lizmat m: say WHAT foo:
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
foo used at line 1
lizmat m: foo: say WHAT foo:
camelia (Label)
lizmat yeah, you need to have it as a label first
m: foo: for ^10 { .say; last foo if $_ == 5 } 17:32
camelia 0
wafflus so that means it not the actual grep but a label called grep? 17:37
lizmat well, probably: also, the whatevercode magic might be interfering there 17:38
wafflus ah ok thank for clearing it up 17:39
17:40 dakkar left 18:15 wafflus left
dano Why was perl6 renamed to Raku? Why Raku? 20:11
antononcube To many people hate Perl. So, it was decided to have a friendlier name that means "harmony" or something. 20:13
Should not be confused with the Japanese pottery style with the same name.
dano Thanks 20:46
21:55 festerdam joined 22:32 discord-raku-bot left 22:33 discord-raku-bot joined 22:41 deadmarshal_ left 22:48 teatwo joined 22:52 teatime left 23:00 discord-raku-bot left, discord-raku-bot joined 23:03 kjp left, elcaro left 23:04 kjp joined, elcaro joined 23:05 deadmarshal_ joined 23:18 discord-raku-bot left 23:19 discord-raku-bot joined 23:38 Manifest0 left 23:45 Manifest0 joined