🦋 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.
pingu i dont think its cause the function has the same name as the file 00:07
ive done that before and it had no problems
Nemokosch are you exporting that function in the ValidTokenChk module of yours? 00:10
pingu nope 00:11
when do I need to export it 00:12
Nemokosch well, always 😄 or what do you mean 00:13
in order to get it pulled into your lexical scope when useing the module, you need to export your stuff 00:14
pingu k now it works 00:15
hmm but replace.rakumod doesnt need is export
ah crap it is export 00:16
ok my bad
trying to renember a ocean of stuff here :|
Nemokosch 🍬
[Coke] (cold) HOLY CRAP is it. 01:53
pingu bbl 02:02
[Coke] I have installed cro without test errors on an ubuntu box in azure, yes. 02:29
rf Hmm, can I generate a class at runtime? 02:30
Nemokosch interesting, for me it "broke" on WSL iirc
sure you can, that's what the compiler itself does 😛 02:31
I think there is even a code example in the docs. It's MOP stuff
rf Awesome i'll look
Was wondering how deep into Meta programming I could go lol
I found that declaring types as JSON for this project makes the most sense so hopefully I can pull it off
Nemokosch this is actually the first example basically 02:32
hope it's up-to-date
rf @Nemokosch can you pass a link 02:38
[Coke] guessing docs.raku.org/language/mop 02:40
rf [Coke]++ Nemokosch++
Geth ¦ doc: coke unassigned from JJ Issue 1-file HTML does not yet exist github.com/Raku/doc/issues/3632 02:44
¦ doc: coke unassigned from JJ Issue Change templates and the rest of the code to point to the new repo github.com/Raku/doc/issues/3101
¦ doc: coke unassigned from JJ Issue `is equiv`/`is tighter`/`is looser` underdocumented github.com/Raku/doc/issues/1730
¦ doc: coke unassigned from JJ Issue Create a new page with info about OS portability github.com/Raku/doc/issues/670 02:45
¦ doc: coke unassigned from JJ Issue Test internal modules github.com/Raku/doc/issues/1751
¦ doc: coke unassigned from JJ Issue Intent, not syntax github.com/Raku/doc/issues/1748 02:46
rf Hmm how can I add a field to a MetaModel? 02:49
m: my T := MetaModel::ClassHOW.new_type(name => T); T.^add_attr('abc'); 02:50
camelia ===SORRY!=== Error while compiling <tmp>
Malformed my (did you mean to declare a sigilless \T or $T?)
at <tmp>:1
------> my T⏏ := MetaModel::ClassHOW.new_type(name =>
rf m: constant T := MetaModel::ClassHOW.new_type(name => T); T.^add_attr('abc');
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared name:
T used at line 1
rf m: my constant T := MetaModel::ClassHOW.new_type(name => T); T.^add_attr('abc');
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared name:
T used at line 1
Nemokosch m: my \T = MetaModel::ClassHOW.new_type(name => T); T.^add_attr('abc'); 02:51
Raku eval Exit code: 1 Could not find symbol '&ClassHOW' in 'GLOBAL::MetaModel' in block <unit> at main.raku line 1
Nemokosch m: my \T = Metamodel::ClassHOW.new_type(name => T); T.^add_attr('abc');
Raku eval Exit code: 1 No such method 'add_attr' for invocant of type 'Perl6::Metamodel::ClassHOW' in block <unit> at main.raku line 1
Nemokosch getting there 02:52
rf To the source code I go
Nemokosch m: my \T = Metamodel::ClassHOW.new_type(name => T); T.^add_attribute('abc', Attribute.new);
Raku eval Exit code: 1 Required named parameter 'name' not passed in block <unit> at main.raku line 1
Nemokosch well yeah, something like this 02:53
docs.raku.org/type/Metamodel::Clas..._attribute
rf Looks like I need ot use AttributeContainer
Nemokosch ClassHOW implements that 😉 02:54
rf Ah
Nice
m: my \T = Metamodel::ClassHOW.new_type(name => 'T'); T.^add_attribute('abc', Attribute.new); 02:55
camelia Required named parameter 'name' not passed
in block <unit> at <tmp> line 1
rf m: my \T = Metamodel::ClassHOW.new_type(name => 'T'); T.^add_attribute('abc', Attribute.new(name => 'abc'));
camelia Required named parameter 'type' not passed
in block <unit> at <tmp> line 1
02:56
rf m: my \T = Metamodel::ClassHOW.new_type(name => 'T'); T.^add_attribute('abc', Attribute.new(name => 'abc', type => 'string'));
camelia Required named parameter 'package' not passed
in block <unit> at <tmp> line 1
rf m: my \T = Metamodel::ClassHOW.new_type(name => 'T'); T.^add_attribute('abc', Attribute.new(name => 'abc', type => 'string', package => ACME::Types));
camelia Could not find symbol '&Types' in 'GLOBAL::ACME'
in block <unit> at <tmp> line 1
rf m: my \T = Metamodel::ClassHOW.new_type(name => 'T'); T.^add_attribute('abc', Attribute.new(name => 'abc', type => 'string', package => ACME));
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared name:
ACME used at line 1
rf m: my \T = Metamodel::ClassHOW.new_type(name => 'T'); T.^add_attribute('abc', Attribute.new(name => 'abc', type => 'string', package => NativeCall));
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared name:
NativeCall used at line 1
rf m: use NativeCall; my \T = Metamodel::ClassHOW.new_type(name => 'T'); T.^add_attribute('abc', Attribute.new(name => 'abc', type => 'string', package => NativeCall));
camelia Too many positionals passed; expected 3 arguments but got 4
in block <unit> at <tmp> line 1
rf Meh lol
Nemokosch What if it really wanted :: ? 02:59
As in, .WHO? 03:00
Geth ¦ doc: coke assigned to dontlaugh Issue We need to speed up tests or otherwise reduce dependence on Travis github.com/Raku/doc/issues/3777 03:05
Geth ¦ doc: coke self-assigned Take care of CI and all repo-related tooling github.com/Raku/doc/issues/3102 03:14
¦ doc: coke assigned to dontlaugh Issue Take care of CI and all repo-related tooling github.com/Raku/doc/issues/3102
¦ doc: coke self-unassigned Take care of CI and all repo-related tooling github.com/Raku/doc/issues/3102
¦ doc: coke assigned to dontlaugh Issue Run extended/author tests regularly/automatically github.com/Raku/doc/issues/3036 03:20
¦ doc: coke self-assigned Time to delete stale branches... again github.com/Raku/doc/issues/3003
¦ doc: coke self-assigned Version 2.0 Roadmap github.com/Raku/doc/issues/2983 03:21
¦ doc: coke self-assigned Parameterization vs. parametrization github.com/Raku/doc/issues/2967
doc/main: ddf8c69abd | (Will Coleda)++ | xt/word-variants.t
Parameterization vs. parametrization
03:29
doc/main: 520c466f4c | (Will Coleda)++ | app.pl
Remove perl5 app runner
Geth ¦ doc: coke self-assigned Intent, not syntax github.com/Raku/doc/issues/1748 03:41
[Coke] m: say 3.print-nl 03:42
camelia Cannot resolve caller print(Int:D: Str:D); none of these signatures matches:
(Mu: *%_)
in block <unit> at <tmp> line 1
Geth doc/main: a639587650 | (Will Coleda)++ | util/test-links.sh
Remove link checker

  github.com/Raku/doc-website/issues/72
03:52
Nemokosch The day has come: I'm adopting the Data::MessagePack module under raku-community-modules 11:01
and if there are no objections, soon I will remove the original version from p6c 11:03
lizmat Nemokosch++ 11:08
Nemokosch do you know about something like "bring PR to fork as well" ? 13:09
lizmat nope, the only way is to transfer the whole repo to raku-community-modules 13:15
which would need the cooperation of the owner
and I think lack of cooperation is the reason to fork, right ? 13:16
Nemokosch yes 13:17
Actually, in this case, it's easier to just replicate the idea of the PR since it couldn't be directly applied anyway and it's a one liner
but there might be other cases where this would have been useful 13:18
lizmat indeed...
similar to wikis
I had to copy Ben Davies' wikis of some repos manually 13:19
Nemokosch :\ 13:19
lizmat in the end only 4 files, but still... 13:20
fortunately you could clone the wiki
hmmm.. now I think about it, maybe I could have cloned and then pushed again ....
ah well, next time
Nemokosch yes, in theory, this could get infinitely complex, if something big needs to be moved for whatever reason 13:22
one'd hope that in that case transferring would be an option 13:23
lizmat It *is* an option, but requires cooperation 13:24
and that's a good thing :-)
Nemokosch Unfortunately, someone's passing does not only leave the sorrow and missing behind, but also administrative complications.
Eventually it would be good to get to process Ben's legacy, as in, unfinished work for example. But I can't even imagine when there will be a sufficient occasion for that... 13:25
off topic: the overall CLI design of git is horrible regarding consistency 13:30
as if the person designing git branch and the one designing git remote had no knowledge of each other's work
el just use github desktop 😎 13:35
Voldenet lazygit is pretty nice 13:42
Nemokosch oh? never heard of it? 13:42
Voldenet it was sold to me when I didn't have to use the stash before the pull, it's such a pointless chore 13:45
Nemokosch you mean the "you have uncommitted changes" stuff? 13:46
Voldenet Yeah, it gets really annoying if you see that for 800th time
Nemokosch fair enough haha 13:47
I don't often work on repos where this would be prevalent but it happened to me as well a couple of days ago, on my own Raku-ideas repo that I tend to edit all over the place
rf Morning folks 14:36
Nahita hi what is "<.kok>" seen in the grammar? 14:40
Voldenet it's a `token kok` probably 14:41
Nahita maybe, what couldn't find definition
*but
Voldenet github.com/rakudo/rakudo/blob/37f5....nqp#L2752
Nahita thank you sorry 14:42
Voldenet np, it's a strange name nonetheless
[Coke] blogs.perl.org/users/damian_conway...ratch.html - "Keyword that's OK" 14:45
Nemokosch lmao xD
rf I have a new project on the go, I think it's going to be very interesting to see how it plays out :D 14:53
Trying to apply Raku to cloud-infra and containers stuff 14:54
Geth doc/main: 7a30bae1b2 | (Will Coleda)++ | util/issue-with-all-pod6.raku
Update repo reference

Closes #3101
14:55
Voldenet I appreciate the explanation of `kok` and `tok` 15:00
[Coke] might be worth a glossary entry 15:58
el is there a “truncate with scale” function 16:13
as in, i want to round a number to a multiple of 100 (for instance) towards zero 16:14
Voldenet round? 16:32
m: my $x = "1234.5678"; say $x.round(100); say $x.round(0.01);
camelia 1200
1234.57
Voldenet if you need truncate to accept scale, you'd need to write your subroutine :/ 16:34
m: sub trunc(Num() $num, Num() $scale) { truncate($num / $scale) * $scale }; say $x.trunc(100); say $x.trunc(0.01); 16:36
camelia ===SORRY!=== Error while compiling <tmp>
Variable '$x' is not declared. Perhaps you forgot a 'sub' if this was
intended to be part of a signature?
at <tmp>:1
------> truncate($num / $scale) * $scale }; say ⏏$x.trunc(100); say $x…
Nemokosch ohh, as opposed to "round with scale"?
Voldenet m: sub trunc(Num() $num, Num() $scale) { truncate($num / $scale) * $scale }; my $x = "1234.5678"; say $x.trunc(100); say $x.trunc(0.01);
camelia No such method 'trunc' for invocant of type 'Str'. Did you mean
'trans'?
in block <unit> at <tmp> line 1
Nemokosch That sounds like yet another thing that could be added to core eventually
Voldenet m: sub trunc(Num() $num, Num() $scale) { truncate($num / $scale) * $scale }; my $x = "1234.5678"; say $x.&trunc(100); say $x.&trunc(0.01);
camelia 1200
1234.56
Voldenet well, 'truncate' could accept scale parameter 16:37
mst something like $str.truncate($str.length.round(100)) ?
Voldenet something like that 16:38
hah, `round` pretty much does the same thing 16:41
multi method round(Real:D: Real() $scale) { (self / $scale + 1/2).floor * $scale; }
mst hrm, the +1/2 means it's going to round to nearest, not down 16:45
I think there's a version that takes a direction but I don't remember clearly so you probably want to poke at the docs/code a bit if you want to find out whether I'm right and if so what it's called ;) 16:46
Voldenet well, it's rounding not truncating 16:49
truncate itself does floor/ceiling depending on the sign 16:50
mst yes but at that point it's -already- rounded so truncate is potentially going to get the higher number 16:51
I suspect what you actually want is 'div' though I also don't remember if raku calls it that 16:52
Voldenet div only works on (Rat, Rat) sadly 16:59
mst isn't string.length an Int and therefore trivially upgradable? 17:01
m: my $str = "foobarbaz"; say string.length div 4
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
string used at line 1
mst m: my $str = "foobarbaz"; say $str.length div 4 17:02
camelia No such method 'length' for invocant of type 'Str'. Did you mean any
of these: 'chars', 'codes'?
in block <unit> at <tmp> line 1
mst m: my $str = "foobarbaz"; say $str.chars div 4
camelia 2
mst Voldenet: see, works fine
m: my $str = "foobarbaz"; say $str.truncate(($str.chars div 4) * 4)
camelia Too many positionals passed; expected 1 argument but got 2
in block <unit> at <tmp> line 1
mst ok, I clearly did something stupid there 17:03
m: my $str = "foobarbaz"; say $str.truncate($str.chars div 4 * 4)
camelia Too many positionals passed; expected 1 argument but got 2
in block <unit> at <tmp> line 1
mst I think I am failing at raku syntax and somebody else should likely take over now
Voldenet: but div definitely works, it's just a question of putting the rest together
Voldenet whoa whoa, that truncate expects Str, the original question was about the Numeri 17:04
Numeric*
I think
mst: truncate is not doing what you think it does, it's for numbers 17:05
mst oh, I must've misunderstood something you said earlier 17:06
though if you have an int to start with, div 100, * 100, should work fine 17:07
and if you have a Rat to start with, just int() it first
gah
Real
mst grumbles
m: my $x = 2.345; say $x.Int
camelia 2
mst m: my $x = 9.345; say $x.Int div 4 * 4
camelia 8
mst Voldenet: that closer to what you had in mind? 17:08
Voldenet the problem given was `truncate the number given the scale, so (0.01) or (100)`
mst which is what that does, no? 17:09
oh, except 0.01 is going to ... sigh
Voldenet that's why I've used truncate and / 17:10
Nemokosch div reminds me
mst m: my $x = 9.345; say $x.Rat div 0.01 * 0.01
camelia Cannot resolve caller infix:<div>(Rat:D, Rat:D); none of these signatures matches:
(Int:D $a, Int:D $b --> Int:D)
(int $a, int $b --> int)
(uint $a, uint $b --> uint)
in block <unit> at <tmp> line 1
Nemokosch we haven't had an upgrade on the issue I opened about ^^^^ this
mst m: my $x = 9.345; say $x.Rat div 0.01.Rat * 0.01.Rat
camelia Cannot resolve caller infix:<div>(Rat:D, Rat:D); none of these signatures matches:
(Int:D $a, Int:D $b --> Int:D)
(int $a, int $b --> int)
(uint $a, uint $b --> uint)
in block <unit> at <tmp> line 1
Nemokosch like, why does [&div] bizarrely not coerce?
Voldenet yeah, div is not Cool 17:11
Nemokosch when even [&gcd] does
I think MasterDuke adapted the tests to the coercing behavior back in the day, then the discussion kinda rallied off
mst it just gets annoyed about reals, which ... personally I like things that are picky about floats because of the number of times I've seen people shoot themselves in the foot with floats when there was no actual need to be using them
however inconsistency between functions is suboptimal 17:12
Nemokosch Reals are not the same as floats - the latter would be Num
Reals are really the abstract, mathematically sane category
mst sorry
li'l bit rusty here 17:13
Nemokosch lately there've been work on adding more support for Complex operations to the core
like the logarithm of -1 and the sign of complex numbers
the "sign" is the normalized direction iirc 17:14
I'm pro sqrt -1 as well, although that would definitely be a new language version for safety 17:15
mst I'm ambivalent because that would make sqrt return different types in different situations unless you made it always return Complex and that probably has its own Interesting Times attached as a choice 17:16
el sqrt(-1) eh most people don’t know complex numbers and its better to throw errors rather than giving something strange to them 17:17
Nemokosch I mean, use types if you aren't happy with a complex number 17:19
it's really not a huge risk
if you cast to Real, you get the error
mst expresses no opinion about that part because he's a pure maths grad without sufficient theory of mind to model how the general user would see it
Nemokosch yeah I'd say always complex tbh, there is .narrow to help out 17:20
mst gut feeling is that most users would be better served by an exception, and having either a csqrt or a 'DWIMs for mathemamticans sqrt' that can be imported might be a wiser idea 17:22
Nemokosch I think that genuinely goes against the decision of division returning rational numbers 17:23
this was a marketing topic, even, "it does the right thing, it knows math by default"
why disregard it immediately with powers
el but then is it a math oriented language? 17:25
does people use it for that purpose 17:26
mst the question, basically, is whether the feature will be more useful to people intending to do complex math than it will be confusing to everybody who isn't 17:27
and I'm unsure how one would answer that 17:28
el id imagine the people using complex math to be a small subset of people using sqrt
mst m: say -1.Complex 17:29
camelia -1-0i
mst wonder if taking a complex number as input as a hint would work 17:30
so you have Real -> Real and Complex -> Complex signatures
Nemokosch I think if you are doing that call at all, you do want it to work
mst or you're doing sqrt($x) and you -thought- $x wasn't negative and were mistaken 17:31
Nemokosch getting an error for that is NOT that valuable, and if you want that to happen, it's really a very welcome solution to use types
el m: say -1.Complex.sqrt
Raku eval -1-0i
el the sqrt of -1 is -1 17:32
real
mst uh
that ... uh
el m: say (-1).Complex.sqrt
Raku eval 0+1i
el ok
mst I think I'm just gonna hide under my desk and rock for a bit now. 17:33
Nemokosch xD
el why do i always forget that unary is less precedent than dot
mst oh, of course, so we ended up with -(1.Complex.sqrt) 17:34
el either that or -1 should be a number literal
Nemokosch -1 is not a number literal 17:36
buuut
whitespace helps xD
-1 .Complex.sqrt
el ik 17:49
p6steve m: (-1).sqrt 18:14
camelia ( no output )
p6steve m: (-1).sqrt.say
camelia NaN
p6steve sqrt coerces arg to Num (since it will return an irrational result by definition and uses the FPU sqrt for performance and IEEE P754 type error behaviour) 18:17
I just saw the above discussion ... made me smile 18:18
pingu if (Str($tok) == False) is not working if I assign a non string value to $tok 19:03
Nemokosch it shouldn't be working so that's correct 19:05
pingu it is meant to check if the value is a string 19:07
pastebin.com/SQrVhWxp 19:08
doing my $x = 4; prints 4
Nemokosch meant by whom, though 😛 because it's clearly not a Raku thing 19:11
pingu are you saying that raku cant differentiate between 4 and '4' 19:12
lizmat m: say "4".^name; say 4.^name 19:12
camelia Str
Int
pingu I wish there was more help online for raku 19:13
derek banas has a video tut but its not very good and well,, I checked rakus website for how to do it and I dont know 19:14
lizmat m: say "is a string" if "42" ~~ Str 19:15
camelia is a string
lizmat m: say "is a string" if 42 ~~ Str
camelia ( no output )
pingu if I make $x 'a' now, doing if if ($x.^name) fails 19:17
but it works if its 4 or 4.4
pingu ok ill try ~~ 19:17
it does the same 19:18
lizmat if you want to see if something is numeric, use Numeric
m: say "numeric" if 42.2 ~~ Numeric
camelia numeric
lizmat m: say "numeric" if 42e4 ~~ Numeric
camelia numeric
lizmat m: say "numeric" if 42i ~~ Numeric
camelia numeric
lizmat m: say "numeric" if "42" ~~ Numeric
camelia ( no output )
pingu in reality the string can contain numbers puncuation and alphanumerics 19:19
for now im adding ' ' around it but when its in a file that will be another problem
because you cant have ' ' in ldraw format
lizmat ok, lemme get this straight what you want
you want to create a lexical variable that may only contain strings? 19:20
pingu if it is " " or ' ' it should print the value else it should print ("must be a string value"); 19:21
< > is probably ok too but I will be using ' ' or " " only
maybe if I try what you said and what I did in one if condition using && 19:23
lizmat ' ' and " " *create* a string. Or do you want a string that contains ' or "
pingu if ($x ~~ Str && Str($x) == False)
lizmat in normal words: if $x is a string and $x is not a string ??? 19:24
pingu if its of type Str then yes print its contents
if $is a not a string print an error else print the value of $x 19:25
lizmat I think what you need is:
my Str $x
if what you try to assign is not a string, then you will get an error 19:26
m: my Str $x = 42
camelia Type check failed in assignment to $x; expected Str but got Int (42)
in block <unit> at <tmp> line 1
lizmat so you want a better error message ?
pingu ah wait I need !~~ 19:27
I was putting ~~ in the false part of the if statement 19:28
yeah my bad !~~ works thx
so when it doubt try smart match 19:29
lizmat I guess
Nemokosch is "source-url" used for anything in META6.json these days? 20:02
ugexe yes, its more of an ecosystem level thing though 20:04
as in - ecosystems can set this value or override the existing one if they wish 20:05
Nemokosch okay, then I will fix the value rather than delete it 20:06
in this MessagePack bundle
One more thing: can Perl6-Data-MessagePack be removed from p6c? I'm about to release the Rakufied, community module version to zef's ecosystem 20:12
ugexe yeah, but you don't have to hurry either since the version of fez will be preferred regardless of i its higher or lower version 20:14
Nemokosch fair enough, it's more the urge to leave a "clean sheet" that pushes me to this direction 20:15
ugexe it should be fine since the zef ecosystem has been integrated for awhile now 20:16
fine to just remove it that is 20:17
Geth ecosystem: 2colours++ created pull request #613:
Remove Data::MessagePack
20:22
Geth ecosystem/main: 808476955b | (Márton Polgár)++ (committed using GitHub Web editor) | META.list
Remove Data::MessagePack (#613)
20:33
lizmat fg 20:34
Nemokosch abraxxa: the msgpack.org/ site has a sort of weird flow: if you put a certain text into your repo description, it will be generated into the site, and this is updated hourly. This means, the Raku version would soon show up, however the Perl 6 version would also stay there 20:37