This channel is intended for people just starting with the Raku Programming Language ( Logs are available at
Set by lizmat on 8 June 2022.
Nemokosch 💎 00:02
:(**@rest, *%rest) yeah ruby is pretty perl-ish 00:37
stevied The guy who created ruby did in fact model a lot of it after Perl. 00:45
01:09 raschipi joined
ok, reviewing to find basic stuff to re/learn. See this: =for comment Use the same syntax for multiline comments to embed comments. for #`(each element in) @array { put #`(or print element) $_ #`(with newline); } 01:33
what is =for comment exactly?
:(**@rest, *%rest) a pod directive 01:35
01:35 Heptite left
stevied is the "for" significant? 01:36
raschipi "Paragraph blocks begin by a =for marker and end by the next Pod6 directive or the first blank line."
stevied how is =for comment different from =comment? 01:37
raschipi =comment is single line 01:38
stevied hmm, afaict, they work the same way 01:39
raschipi Well, that's what the docs say, I see lernXinYminutes says differently. You should test
stevied yeah, that's what brought me here, I can't tell the difference 01:40
raschipi I think it could be what it does with configuration, or the relationship to other blocks when rakudoc is called on it. I'm not sure. 01:42
stevied yeah, looks like =for is for a paragraph block: 01:49
only think I could find in official docs is this: 01:55
raschipi talks about =for and =comment 01:58
stevied yeah, seems like docs might be wrong then 01:59
because =comment behaves just like =for comment afaict
raschipi m:=for comment 02:04
Can't put anything after =for comment, needs to start at the next line 02:06
stevied seems like a weird distinction between the two 02:07
raschipi Well, it shows they aren't exactly the same
stevied why would you use =for comment when you can just use =comment?
raschipi Reading the docs again, =for comment is a configuration block for a =comment block 02:11
When there's a newline, the =comment block begins, but there could be multiple lines starting with = with configuration for the =comment block. 02:12
Of course, =comment blocks will be ignored by the pod parser, so I don't think there's much to be done in a =for comment block... 02:14
But a =for head1 block, for example, will configure a =head1 block. 02:15
=for head1 :a-first-line-key<firstvalue> :another-first-line-key<xyz> ␤=     :a-second-line-key(42)␤= :a-third-line-key<third>␤Content for the header block 02:18
stevied Weird 02:24
It sure what a config is good for
:(**@rest, *%rest) oh i found tkinter on raku 02:26
m: say 02:50
why is bare say unsupported
raschipi Do you know Perl? 02:52
:(**@rest, *%rest) whats with perl?
raschipi Bare print in Perl meant 'print $_' 02:53
:(**@rest, *%rest) :cameliathink: 02:54
raschipi In Raku '.say' is the equivalent.
:(**@rest, *%rest) by say i mean say()
but yeah is say special-cased to give this warning 02:55
or any functions at the top level will do
raschipi Perl is inconsistent about this, bare functions sometimes meant calling them on empty arguments, sometimes calling them on the topic... 02:56
:(**@rest, *%rest) perl bad 😭 02:57
raschipi So in Raku ones has to specify what they want. 02:59
:(**@rest, *%rest) m: say given 123 03:00
m: .say given 123
raschipi And yes, the language does detect the most common pitfalls from people comming from Perl. It was meant to be a successor at first.
:(**@rest, *%rest) m: say($_) given 123
m: 1 ~~ 1 03:01
m: say 1 ~~ 1
is ~~ the smart match operator does it pattern match? 03:02
03:03 Heptite joined
raschipi Technically, the samart match operator calls .ACCEPTS on the left argument with the right argument as an argument. 03:06
But yes, it does work kind like a set operator and pattern match. 03:07
:(**@rest, *%rest) > <raschipi> Technically, the samart match operator calls .ACCEPTS on the left argument with the right argument as an argument. the opposite? 03:08
raschipi Right, the opposite, sorry.
Calls .ACCEPTS on the left argument with the right side as an argument. 03:09
:(**@rest, *%rest) m: say ‘RAKU’ ~~ /raku/i
m: say ‘RAKU’ ~~ /raku/:i 03:10
m: say ‘RAKU’ ~~ :i/raku/
m: say ‘RAKU’ ~~ rx:i/raku/ 03:11
perl and javascript users be like
raschipi The character ‘ kills my Raku REPL 🥲 03:12
I'm having a lot of REPL problems lately 03:15
03:44 Heptite left
:(**@rest, *%rest) say: 1 / 0 03:55
m: say 1 / 0
raschipi m: $a = 1/0; say '' 03:56
camelia ===SORRY!=== Error while compiling <tmp>
Variable '$a' is not declared. Perhaps you forgot a 'sub' if this was
intended to be part of a signature?
at <tmp>:1
------> <BOL>⏏$a = 1/0; say ''
raschipi m: my $a = 1/0; say '' 03:57
:(**@rest, *%rest) m: try { 1 / 0 } catch (Exception $e) { say 'hi' }
raschipi m: try { say  1 / 0;  CATCH {   say 'hi' }} 04:01
camelia hi
Attempt to divide by zero when coercing Rational to Str
in block <unit> at <tmp> line 1
raschipi m: try {1 / 0;  CATCH {   say 'hi' }} 04:02
camelia ( no output )
:(**@rest, *%rest) m: try { 1 / 0 }; if $! { say 'hi': } 04:03
m: try { 1 / 0 }; if $! { say 'hi'; }
m: try { say 1 / 0 }; if $! { say 'hi'; }
m: try { say 1 / 0 }; if $! { dd $!; } 04:04
raschipi 1/0 isn't an Exception, it's a Failure
try catches exceptions, not failures
:(**@rest, *%rest) :cameliathink: 04:05
raschipi But a Failure will throw an Exception if you try to use it as a normal value
:(**@rest, *%rest) 2 ways to handle failures hmm
raschipi Yep 04:06
:(**@rest, *%rest) m: dd 1/0
m: dd 1.0/0 04:22
m: say 1.0/0
m: say float(1)/0 04:23
m: 1.Num/0
how do i get the float behavior
raschipi m: 1e0/0e0 04:24
camelia Attempt to divide 1 by zero using /
in block <unit> at <tmp> line 1
raschipi Use scientific notation.
e0 at the end
m: dd 1e0/0e0 04:25
camelia => => "/", details => Any, numerator => 1e0), backtrace =>
04:27 Heptite joined
:(**@rest, *%rest) float division also returns an error hmm 04:32
m: dd Inf.WHAG
m: Inf.WHAT
m: dd Inf.WHAT 04:33
raschipi g'night, have a good one 04:45
04:45 raschipi left 05:02 MasterDuke left
:(**@rest, *%rest) is there a discussion on the rationale behind raku's weird unconventional jargon 06:02
07:23 snonux joined 07:38 Heptite left 07:52 rantanplan joined 08:52 Heptite joined
Nemokosch Idk, I bumped into a github discussion a couple of months ago 09:12
With the monkey pragmas
And there I said that some names are horribly unfriendly, like the whole HOW jargon 09:13
nice 09:32
gfldex Your question doesn't make sense. All jargons are conventional. 09:57
Nemokosch oh man the apologetics... 10:07
Nahita moments ago, in another language, i felt a need for inline comments :y 10:33
instead, i put spaces so i can notice later 10:37
gfldex @:(**@rest, *%rest) In case you are actually interested in the discussions about Perl 6 (your tone towards anything Raku strikes me as very dismissive), you can find them there: 10:38
11:19 rantanplan left, snonux left 11:24 ab5tract joined 12:11 rantanplan joined, rantanplan left 12:12 snonux joined 12:17 snonux left
:(**@rest, *%rest) python? 12:54
Nahita it is
somewhere in method chaining i needed it
:(**@rest, *%rest) im not being dismissive of raku 😭 raku is a cool language 12:55
what is your example exactly 12:56
gfldex I would use "weird" as a praise. 12:58
:(**@rest, *%rest) no i mean unconventional wrt terminology from other languages something like variadic rest arguments being called “slurps” 13:05
gfldex There are 2 reasons for that. Fistly, Larry is a bloddy hippie. But mostly, because they don't quite work like variadic args in other languages. 13:09
Nemokosch It's a bit overboard to call out somebody for using the word "weird" about something that is unusual and not necessarily in a positive way 13:10
I rather find this gatekeeping dismissive regarding improvements 13:11
Rather than saying "because it made sense 20 years ago in a completely different historical context", we could think what value it provides now, and how to make it better in any regard 13:14
13:17 ab5tract left
:(**@rest, *%rest) raku is a decent language imo but there are some things im not exactly comfortable with such as the pervasiveness of coercion in built in raku operators (there is even a base class dedicated to coercive methods) 13:19
Nemokosch You mean Cool? 🤣 13:22
:(**@rest, *%rest) or the implicit *%_ in function signatures
lizmat fwiw, I agree with the latter :-) 13:23
:(**@rest, *%rest) yeah pretty sure it stands for coerceable objects lmao /half-joke
Nemokosch XD
"Convenient OO Loop" 13:24
I don't like the name but I do like the principle
:(**@rest, *%rest) how is it a loop
Nemokosch I have no idea, quoting the docs
In my experience, the principle itself is more convenient, WHILE being at least as solid, than the Pythonic "cast everything only to get the generic call right" approach 13:26
:(**@rest, *%rest) granted there are different operators for different types and it isn’t as bad as javascript 13:29
gfldex *%_ is only present in Method, not in Sub and very useful as such, or callsame would become dependent on stable interfaces in parent classes. 13:30
lizmat true, but I don't think that compares to the woes of misspelling named arguments that go into oblivion without any sound 13:31
Nemokosch For what it's worth, I like Javascript as well xD
lizmat+=1 13:32
Tbh the only language (family) I wouldn't use is POSIX Shell, add Batch obviously 13:33
But for those, I feel strongly that nobody ever should use them, it's damage to the whole industry 13:34
:(**@rest, *%rest) tbh js can be a good lang if not for its typing mess especially since es6
Nemokosch At the moment you create the first variable or add the first control structure, you should delete it and rewrite it in a programming language 13:35
:(**@rest, *%rest) +1 13:37
Nemokosch Not sure how the bridge works - that was a +1 to lizmat again 13:38
:(**@rest, *%rest) m: sub f { %_ } f a => 1, b => 2; 13:40
Nemokosch Implicit *%_ could maybe go in 6.f? 6.e is already getting very complex
:(**@rest, *%rest) m: sub f { } f a => 1, b => 2;
i noticed that i can make unnamed arguments basically just thrown away by the function 13:41
gfldex lizmat: getting dynvars wrong can also have *interesting* results. A pragma and/or compiler switch that would warn on used arguments would not hurt, tho. 13:42
:(**@rest, *%rest) m: sub f($a, $) { say $a; } f(‘hi’, ‘bye’);
lizmat gfldex: yeah, that's pretty high on my list :-)
Nahita Normal flow was sth like this py metric(trues.mul(scale), preds.mul(scale).clip(lower=0, upper=UPPER_LIMITS[place]) Then preds already came scaled, so it became py metric(trues.mul(scale), preds .clip(lower=0, upper=UPPER_LIMITS[place]) I wished to write plain metric(trues.mul(scale), preds#`(already-scaled).clip(lower=0, upper=UPPER_LIMITS[place]) 13:43
Nemokosch Oh, this reminds me of another funny issue... 13:44
:(**@rest, *%rest) metric(trues.mul(scale), preds # already scaled \ .clip(lower=0, upper=UPPER_LIMITS[place]), ...)
not sure if that would work
Nahita you don't need \ 13:45
Nemokosch You may know that .& calls cannot be detached, unlike . calls
This in itself is debatable... but
If you do foo .bar.&baz, that will also fail! 13:46
:(**@rest, *%rest) :cameliathink:
Nemokosch The detachment escalates
Nahita this reads worse IMO 13:47
:(**@rest, *%rest) are there any more sigils other than $@%& 13:50
does raku grammar facility have tree-shaping capabilites 13:52
13:54 raschip joined
raschip . 13:59
:(**@rest, *%rest) raschip: what
Nemokosch IRC message update? 14:01
raschip I wanted to see if the logs were in local time or other time zone, so I sent a message to see what time it would have in the logs. 14:02
Nemokosch Maybe UTC? 14:03
raschip Yes, it's UTC, but I didn't know that until I tested it. 14:04
Nemokosch This always gets me confused as well
:(**@rest, *%rest) as in the ability to discard terminals and inline branches 15:07
Nemokosch 🤔 15:08
:(**@rest, *%rest) 15:18
smth like that 15:19
Nemokosch I've never seen anything like that 15:20
have you checked grammar action classes? 15:23
eventually you're building Raku objects so there's quite a lot you are naturally allowed to do 15:24
:(**@rest, *%rest) essentially i want to create a parse tree that is close to the ast and to do that i need to weed out tokens and branches irrelevant to ast generation and lark let me do it declaratively 15:31
Nemokosch it's done with action classes 15:38
stevied Why is the “but” operator called “but?” For the longest time I though it was some kind of control flow mechanism. 15:40
Had no idea it was for mixins
raschip From Perl, they can return "0 but True" to have a True with numeric value of 0 15:41
In Raku that's spelled 0 but True instead.
That's where the word comes from.
Nemokosch but is a great idea of way too obscure names... 15:42
:(**@rest, *%rest) its not "declaratively" but whatever why are actions separate from rules themselves
stevied Huh. Thanks. Must have been introduced in later versions of Perl I’m not familiar with.
:(**@rest, *%rest) can't it be token something { 'foo' | 'bar' } action { # do something with $/ } 15:43
stevied I find if I read it as “but also” it kind of makes sense.
Nemokosch yep, that helps
I don't know, I'm not knowledgeable with grammars tbh 15:44
one grammar could have multiple AST buildups 15:45
usually an action class doesn't just keep some theoretic AST but rather builds up an actually useful data structure
:(**@rest, *%rest) hmm ok will make an json parser with grammars lol 15:47
raschip They end up separate because Grammars and Action Classes are Classes. And tokens and actions are it's respective methods.
Nemokosch another gotcha with this 15:49
I think this is a really bad gotcha, even...
I'm absolutely clueless why tokens/regexes are installed with RAW method names 15:50
raschip Yep, but it's also very nice to be able to use the object system to extend a grammar
Nemokosch why aren't they turned into something like match:<name> 15:51
even if only "internally"
raschip No idea.
16:03 snonux_ joined 16:04 snonux joined
:(**@rest, *%rest) are raku grammars parsed by recursive descent? how do they accomodate left recursion? 16:16
16:17 snonux left
Nemokosch it's PEG parsing from what I know 16:17
and you can probably transform the grammar if left recursion is a problem
16:19 snonux joined
raschip Not exactly PEG, because in PEG there's no concept of 'longest token match'. 16:20
Nemokosch I doubt anybody knows what Raku's grammar parsing "exactly" is 16:24
it's highly accidental I heard of PEG at all
raschip Yeah, Raku design takes Computer Science theories into account, but doesn't try to match them. PEG was being developed at the same time as Raku's Grammars and the theory was taken into account. 16:31
Nemokosch anyway, if somebody tries to actually use it, it would be good to know how it works exactly 16:34
16:38 snonux left, snonux_ left 17:18 snonux joined, snonux_ joined 17:35 jgaz joined
stevied in "class Box {}", doe Box work as an identifier and follow the same naming conventions as a variable? 18:27
raschip m: class Bob's-Burguers {} 18:29
camelia ( no output )
raschip yep
stevied ok, reason I ask is I'm looking at and it doesn't mention anything about classes being identifiers 18:30
raschip Well, not directly, but it's in there: use ThatModule:auth<Somebody>:ver<> 18:33
"In the example above, MyModule::var"
stevied well, that's what I was kind of wondering. could I give a class the name "MyClass:auth<me>:ver<2.3>"? 18:34
let's see
m: class Box:auth<me>:ver<2.3> { } 18:35
raschip It's ignored 18:36
stevied yup, that works
oh, is it?
raschip Although these are valid identifiers, it's use is reserved
TIMTOADY has the colon 18:37
stevied ok, yeah, if I create two different versions, I get an error
Redeclaration of symbol 'Box'. 18:38
interesting: class { }; throws no error 18:41
that's an anonymous class, basically?
Nemokosch I'd think so... but I can't tell you when they are used 18:43
stevied this doesn't work: my $class = class { has $color; } $ => 'black'); say $class.color; 18:44
Nemokosch well, what happens 18:45
stevied No such method 'color' for invocant of type '<anon|2>'
oh, wait, forgot the .
nope, still doesn't work
m: my $class = class { has $.color; } $ => 'black'); say $class.color;
Nemokosch m: my $class = class { has $color; } dd $class; 18:46
the output itself is a bit broken
dd could use some sprucing up, as we speak 18:47
I think the error was okay, though
don't forget that $class was a type object, and type objects don't have attributes
m: my $class = class { has $.color; } say $ => 'black').color; 18:48
stevied huh
so you could theoretically pass around these classes. not sure how that's useful but it's interesting 18:50
this guy writes about "anonymous classes": 18:51
go down to "the future" section
above my paygrade 18:52
raschip In Java that's a very common idiom. Instead of instantiating a Class directly, you call into MyClassFactory and it gives you an instance. 18:53
stevied is it accurate to say there is no Class class? But there is the Metamodel::ClassHOW that lies behind a class object. Is that the right way to think about it? 19:08 19:12
"Warning: this class is part of the Rakudo implementation, and is not a part of the language specification."
so I guess another implementation could choose to have a parent Class object if it wanted 19:15
but rakudo uses this metamodel::ClassHOW doohickey 19:16
Nemokosch simply because metamodel stuff is poorly standardized 19:21
stevied how long have you been working with raku @Nemokosch ? 19:25
Nemokosch I started learning it around july-august 2021 19:47
stevied what did you code in before that? 19:48
what am I getting wrong here: m: package MyClasses { package LetterClasses { my class C {}; my $class =; } } my $class =; 19:51
p6steve possibly need 'is export' (maybe twice) - IIRC class is export by default unless you apply package/module keywords 19:53
stevied hmmm, tried but couldn't get it to work. where would "is export" go? 19:55
oh, doh. I had "my class" 19:56
now it works
p6steve lol is what I had in mind 20:01
stevied yeah, that's something that's still not clear in my mind 20:03
not sure what the distinction between a package and a module is. 20:04
it's nothing I could put in words. just vague ideas 20:05
should go back and study that. i've been doing a lot of that lately. going back and reading what I barely understood/remember 6 months ago when I read it the first time. helps. 20:06
p6steve yeah - takes me several takes too 20:11
20:14 Heptite left
my guess fwiw is that 'package' is a generic term for a raku namespace and that class, grammar, module are specific kinds of packages. So therefore 'MyClass::<$foo>' can be used to access foo within 'class MyClass { has $.foo }' 20:23
(in other words it actually quite easy when you know what you are doing (and I don't))
stevied yeah, sounds about right. I just think of packages as kind of arbitrary namespaces that you can create wherever. 20:24
not sure if that's correct
I wrote this a few years back: 20:41
I want to do the same for Raku OO 20:42
just take like a small vertical slice of OO in Raku but go into painstaking detail on that one slice and use it as a jumping off point for learning the big picture. 20:43
Nemokosch well, whatever that came up at university + JS and Pascal basically :DD
stevied have you coded professionally? 20:47
Nemokosch Now I do
stevied_test my kid is a sophmore at UMass taking comp sci 20:48
Nemokosch what is UMass?
stevied_test University of Massachusetts
Nemokosch the big MIT? 20:49
stevied_test naw. MIT is private
UMass is a public university
Nemokosch oh right, everything good in the US is private, lol
stevied_test huh, MIT was actually a government land grant college, but it's privately run. didn't know that 20:51
so there would be no MIT if it weren't for government money. go figure. 20:53
raschip I'm a grad student, doing statistics. In a public University. When I progress enough down the course, I'm gonna do a Raku stats package. 21:03
21:07 snonux left, snonux_ left
stevied nice 21:07
raku seems to attract computer science types, afaict. 21:08
21:10 jgaz left
Nemokosch good fit for Anton ^^ 21:23
stevied heh, yeah, he was one of the guys I had in mind
23:01 Heptite joined