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:03 CodeTortoise left
newuserofraku p6steve okay thank you, i don't have/use docker on this system, but will try the other solution 00:44
01:21 CodeTortoise joined 01:50 CodeTortoise left
jaguart can't get the role mixin syntax for two roles with initialiser :( 02:15
m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but R("Aha"); say $i, " is ", $i.ahr;
camelia 5 is Aha
jaguart m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but (R("Aha"),S); say $i, " is ", $i.ahr;
camelia Impossible coercion from 'Str' into 'R': no acceptable coercion method found
in block <unit> at <tmp> line 1
jaguart m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but (R,S); say $i, " is ", $i.ahr; 02:16
camelia 5 is (Any)
jaguart m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but (R("Aha"),S("Shh")); say $i, " is ", $i.ahr; 02:17
camelia Impossible coercion from 'Str' into 'R': no acceptable coercion method found
in block <unit> at <tmp> line 1
Nemokosch Why did R("Aha") work in the first place?
jaguart role with single value can be initialised using parens
docs.raku.org/language/objects#Mixins_of_roles
says: If the role supplies exactly one attribute, an initializer can be passed in parentheses: 02:18
Nemokosch What if you add spaces inside the parens?
Btw this whole feature sounds kinda like an unfeature imo 02:19
jaguart spaces don't help...
what does this mean: Impossible coercion from 'Str' into 'R 02:20
it's trying to turn the arg into the role??
Nemokosch This is probably a syntax barrier
Something like that 02:21
Or worst case, a weird type constraint
Ngl I'd rather see this one-argument hack removed altogether. It's "strangely inconsistent" which is the worst of the 4 possibilities 02:22
jaguart I can do it in two assignments :( 02:24
which is a bit naff
m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but R( "aha" ); $i = $i but S("shh"); say $i, " is ", $i.ahr, " and ", $i.ess;
camelia 5 is aha and shh
jaguart m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but R( "aha" ); $i = $i but S("shh"); say $i, " is ", $i.ahr, " and ", $i.ess; say $i.WHAT 02:25
camelia 5 is aha and shh
(Int+{R}+{S})
Nemokosch What if you wrap the role in a one- element list? 02:26
My hypothesis is that if would break
jaguart one element list is ok 02:28
but needs parens though otherwise you get a warning about the last role being in sink 02:29
Nemokosch m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but (R( "aha" ),); $i = $i but (S("shh"),); say $i, " is ", $i.ahr, " and ", $i.ess; say $i.WHAT
jaguart it feels naff - but I can live with chaining assignments
Nemokosch It did fail 02:30
jaguart m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but (R( "aha" ),); $i = $i but (S("shh"),); say $i, " is ", $i.ahr, " and ", $i.ess; say $i.WHAT
camelia Impossible coercion from 'Str' into 'R': no acceptable coercion method found
in block <unit> at <tmp> line 1
jaguart m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but (R( "aha" ),); $i = $i but S("shh"),; say $i, " is ", $i.ahr, " and ", $i.ess; say $i.WHAT
camelia Impossible coercion from 'Str' into 'R': no acceptable coercion method found
in block <unit> at <tmp> line 1
jaguart m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but R( "aha" ), ; say $i.WHAT 02:31
camelia (Int+{R})
jaguart m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but (R( "aha" ),) ; say $i.WHAT
camelia Impossible coercion from 'Str' into 'R': no acceptable coercion method found
in block <unit> at <tmp> line 1
jaguart m: role R { has $.ahr }; role S { has $.ess }; my $i = 5 but (R( "aha" )) ; say $i.WHAT
camelia Impossible coercion from 'Str' into 'R': no acceptable coercion method found
in block <unit> at <tmp> line 1
jaguart so looks like parens kicks but 02:32
I didnt think parens created list?
on a sep note - how to you initialise a role if if has more than one field? 02:34
Nemokosch Good question. Have you tried the same way as default constructors? 02:38
jaguart you can assign defaults - but what if you want non-default values 02:40
Nemokosch I meant default constructors of classes though 02:41
By the way, in this case "you just don't" also seems acceptable for an answer. After all, it's a far stretch to mix in *non*-commonalities with a mixin 02:43
jaguart ah - parameterised roles using [] 02:45
m: role R[$a] { has $.ahr = $a }; role S[$s] { has $.ess=$s }; my $i = 5 but (R["a"],S["b"]); say $i, " ", $i.ahr, " ",$i.ess, " is ", $i.WHAT; 02:46
camelia 5 a b is (Int+{R[Str],S[Str]})
jaguart and this works with the butt list
to summarise: parens kick but unless you're square --> but (R[1],S[2]) 02:47
and you can use capture args: nice :) 02:53
m: role R[|c] { has $.a = c<a>; has $.b=c<b>; }; my $i = 5 but (R[:a("x"),:b("y")]); say $i.WHAT; say ($i,$i.a,$i.b).map(*.gist).join(" ") 02:54
camelia (Int+{R})
5 x y
jaguart is there a nice way to separate say elements? like Perl $, ? 02:59
actually I mean $" 03:00
no - I do mean $, doh 03:01
oh :( docs.raku.org/language/5to6-perlva...,_$OFS,_$, 03:02
Currently no obvious equivalent.
03:23 Kaiepi left 05:25 CodeTortoise joined 05:37 CodeTortoise left
jaguart this suprised me 05:48
m: class C { method x ( :$all ) { my @m; |@m; } }; for C.new.x() -> $y { say "got: ", $y } 05:49
camelia ( no output )
jaguart m: class C { method x ( :$all ) { my @m; return |@m; } }; for C.new.x() -> $y { say "got: ", $y }
camelia got: Nil
jaguart return statement vs last expression - argh
Nemokosch re $,: yeah, tbh it's more or less intentional probably. Lots of magic variables were eliminated 09:43
and that really seems like such a minimal sugar when you can do join on any sort of list 09:44
10:34 Kaiepi joined 14:49 jgaz joined 15:16 rf joined
rf Where can I find more information on generics in Raku, I thought they'd be with the class stuff in the docs but I can't seem to find much 15:17
Nemokosch I think it runs under a term like "type parameters" somewhere 15:22
having said that... hm, well, how do I put it. There should be some disclaimer that the type system is overrated 15:23
rf That's fair! I'm writing a Result monad right now and I think keeping it dynamic is fine, but just wanted to dabble a little bit with Generics 15:24
Nemokosch granted, it *is* a real type system, not just some linter sugar. But you will hit yourself a lot of times probably. Simply saying this because of the kind of discussions that have happened e.g here 15:25
rf I come from Haskell and OCaml, so it's probably my past holding me back trying to type everything :P 15:26
Nemokosch Some questions seem desperately legitimate, for example: why can't List, of all types, take parameters
Array can, for example
rf Yeah, I was wondering about that
Nemokosch oh right, and then obviously literals of compound types usually won't be typed the way you wished them to 15:27
rf Is there any reason that Lists can't be typed? I feel like that should be relatively simple. But I'm no compiler hacker 15:30
Nemokosch I also don't know. Don't @ me at this but this seems like a situation where there probably is a reason and if we learned it, we would probably say it's an invalid reason 😅 15:31
rf Are there many other languages on Moar/NQP? Maybe some of them have managed it lol 15:34
Nemokosch absolutely not. I think, even if it's theoretically possible to build a language on top of MoarVM, it was created exactly for Raku (Perl6 at that time) 15:37
Nahita "not quite python" <github.com/arnsholt/snake> 15:40
it's interesting i think, rf 15:42
rf Cool 15:46
One more quick question, what's the difference between f(x) and f: x if any?
Nemokosch does f: x work for bare functions as well? 15:58
for functions, I have only seen f x
I'm pretty sure all the differences are solely related to syntax implications 15:59
like precedence
Nahita rf: `:` allows less parantheses in method calls 16:00
`$obj.meth($a, $b);` can be written as `$obj.meth: $a, $b;` 16:01
or `meth $obj: $a, $b`
if not a method, "f" in `f: x` is interpreted as a label 16:02
rf What about a block, does the same apply for &f: ?
Nahita & is not only for blocks, also usable to refer to functions 16:03
and &f: seems to be not interpreted as a label but a syntax error 16:04
rf Cool, thanks for this :D 16:05
Nahita np 16:06
16:25 jgaz left
rf How can I get around the lexical scoping of modules? I have a sub `ok` in my Module, and I want to test it. Since Test::ok is a thing I get errors. Can I alias somehow? 16:28
Nemokosch perhaps it's better to make your sub our-scoped 16:29
so that you can access it with ::
rf That did the trick thank you! 16:39
Nemokosch 🍬
17:03 jgaz joined 17:31 jgaz left 18:11 newuserofraku left 18:53 Kaipei joined 18:57 Kaiepi left 19:03 Kaipei left 19:04 Kaipei joined 19:28 Kaipii joined 19:32 Kaipei left 20:12 CodeTortoise joined
CodeTortoise Quick dumb question. You know how Rust programmers are called rustaceans... are we Rakoons? 20:13
Nemokosch Seems like that became the de-facto term 🙂 20:14
CodeTortoise Neat. I knew it would be something obvious like that. 20:16
Or like, Rakunteurs.
20:41 CodeTortoise left 22:37 CodeTortoise joined 23:15 jgaz joined 23:29 CodeTortoise left