🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
Doc_Holliwood wasn't there a shortcut to define a sub that is just a single expression? 00:36
codesections m: sub f(--> 42) {}; say f; 00:42
camelia 42
codesections like that? ^^^^
moon-child I mean, you can just do sub f { 42 }. Seems short enough to me 00:50
japhb Or if it doesn't have to be a Sub, then just { 42 }. 00:53
moon-child m: class Foo { has Int:D ($.x = 1, $.y = 2); }; print Foo.new.x; 01:44
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <tmp> line 1
moon-child ^^ bug?
codesections pretty sure that's intentional, though surprising behavior. Defaults aren't applied until after BUILD 01:54
docs.raku.org/language/objects#Obj...nstruction
moon-child yes but 01:56
m: class Foo { has Int:D $.x = 1; }; print Foo.new.x;
camelia 1
moon-child it only happens when declaring multiple members at once
codesections oh, hmm
moon-child m: class Foo { has Int:D ($.x = 1); }; print Foo.new.x; 01:57
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <tmp> line 1
codesections ~m: class Foo { has (Int:D $.x = 1, $.y = 2); }; print Foo.new.x;
m: class Foo { has (Int:D $.x = 1, $.y = 2); }; print Foo.new.x;
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <tmp> line 1
codesections m: class Foo { has (Int:D $.x = 1, Int:D $.y = 2); }; print Foo.new.x; 01:58
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <tmp> line 1
codesections m: class Foo { has (Int:D() $.x = 1, Int:D $.y = 2); }; print Foo.new.x;
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <tmp> line 1
codesections m: class Foo { has (Int:D() $.x = 1, Int:D $.y = 2); }; dd Foo.new; 01:59
camelia Foo.new(x => Int, y => Int)
codesections well, that's odd...
summerisle i need a good grammar tutorial/reference for grammars that deal with newlines 06:47
SmokeMachine japhb: Hi! sorry for not answering, but yes, that was a place to talk about Red! 08:16
notagoodidea So after talking with Ben Hoyt, Raku would not been included in the `countdown` comparison due to being to slow :'( github.com/benhoyt/countwords/pull/74 09:15
From profiling the "optimized" version, my findings tends to be : 09:18
(1) Using the default trait on the Hash and `==` comparaison with .AT-KEY method seems faster than .EXISTS-KEY 09:19
(2) Calling .AT-KEY was the most costly call based on the profiler 09:20
notagoodidea (3) pull-one method seems to a bit costly too. In the first `for` loop, the IO::Handle version is at 99% inlined. Most suprising, is that the for $_.lc.words loops call the pull-one method from Str (and it is not inlined). 09:27
But words output a Seq? 09:28
Okay, no it is words that call pull-one on the string passing by .lc. 09:31
notagoodidea And (1) need to be more tested -_- 09:54
ab5tract wrote a small blog post of appreciation fro rakudo-pkg : 5ab5traction5.bearblog.dev/overdue...akudo-pkg/ 11:33
summerisle can anyone provide some insight as to why the `block` token only matches one member-mapping token for the example on L61 of this gist? gist.github.com/RomanHargrave/4f2b...0a470ecbfc 16:52
i'm also somewhat confused as to why this works with an explicit definition of newlines, but not \v 16:53
guifa2 summerisle: it's because you have member-mapping as a rule 17:15
rules expect whitespace after *each* inner token 17:16
so rule { a b c } is equal to token { a <.ws> b <.ws> c <.ws> }
guifa2 It's that finally <ws> that's throwing things off, because <ws> includes (by default) vertical white space. So it consumes the new line and all of the space on the next line. Then it tries to handle <eol> which requires a linebreak, which no longer exists 17:18
final*
jmerelo geth no longer works, right? 17:34
.seen Geth
tellable6 jmerelo, I saw Geth 2021-03-17T19:34:05Z in #raku-dev: <Geth> ¦ rakudo/fix_continuation_race_condition_in_tps: ␂review: github.com/rakudo/rakudo/commit/2eb249cae8
jmerelo Well, it does not work on Raku/doc, apparently...
summerisle .tell guifa2 that did it. no clue why that didn't occur to me. this week has been cursed. 20:53
tellable6 summerisle, I'll pass your message to guifa2
dag29 Hello 22:07
I've got a newbish raku coding question if/when someone would like to help. 22:11
codesections hi and welcome :)
vrurg .tell tyil I have sent you request. Not sure if it was delivered, though. 22:31
tellable6 vrurg, I'll pass your message to tyil
tyil what kind of request?
summerisle another grammar question. i have a token 'package' defined as `<name>+ % '.'` and a token 'fqdn' defined as `<package> '.' <name>`. I'm expecting <package> to match everything up to the last <name> in a sequence such as 'a.b.c.d.e' such that `<package>` captures <a b c d> and `<name>` captures 'e'. 22:32
unfortunately, this will not match
i should probably go read the regex docs again
moon-child summerisle: I guess you need to make it a regex, because tokens are ratcheting 22:33
summerisle i suppose 22:34
moon-child summerisle: but easier is probably to ditch <name> and grab that later in postprocessing
summerisle i had initially intended to do this in postprocessing but I suppose that I was hoping I could take care of all decomposition in the grammar
i guess it would make the grammar more efficient if i made fewer assumptions as well 22:35
or made more, i mean to say
yep, making <package> a regex does it 22:36
dag29 I'm trying to pull multiple lines from a file at once for $file.IO.lines -> $line1, $line2, $line3 but I don't know before hand how many lines the file has.  How can I avoid an error when it gets to the end of the file and doesn't find all 3 lines and still get however lines there are left? 22:41
moon-child for $file.IO.lines -> $line1, $line2 = Any, $line3 = Any { ... } 22:45
lizmat $file.IO.lines -> $line1, $line2?, $line3?
or what moon-child said :-)
dag29 ty, I'll try those out :) 22:46
tyil $file.IO.lines.rotor(3) -> @lines { } # should give you up to 3 lines every iteration
tyil oh, .rotor() needs :partial 22:47
vrurg tyil: There is bug in Configure which makes it impossible to inherit from 22:48
tyil vrurg: ah, your mail
I saw it, but didn't have time yet to look at it
vrurg tyil: Ok, just wanted to make sure because the email address format is rather unsual. :) 22:49
*unusual
tyil it's not common, but very RFC compliant :D 22:50
if I understand the issue correctly, this patch should solve it p.tyil.nl/k3bz 22:51
and `prove6 -lv` says it doesn't break anything 22:52
vrurg tyil: Looks like it should.
dag29 ty all for the help.  works great now :) 22:57
tyil vrurg: Uploaded Config-3.0.4.tar.gz to CPAN 22:58
vrurg: you can also install it from dist.tyil.nl/raku/modules/Config/C...0.4.tar.gz
vrurg tyil: thanks! 22:59
vrurg is trying hard not to implement bind config format parser... 23:00
tyil vrurg: could be a fun project for a weekend :> 23:01
vrurg tyil: not in my vision. I want it to be extendable, free-form. So that it'd be possible to add, say, roles implementing own data formats; to pre-declare block types and their properties. 23:04
tyil would be cool to see use of roles for different data formats 23:09
right now I'm using Config::Parser::$name as a means to an end
(but note that Config is my first module, so it's probably full of things that could be done prettier in Raku)
codesections wonders whether Encoding::Registry could be used to read config files 23:12
ugexe i would assume it gets used every time you read a non-binary config file 23:14
codesections well, most of those presumably use the utf_ encoders that are built in to the VM 23:15
codesections I was wondering about registering a custom encoder to extract data from a file before/without reading it in as a Str 23:16
ugexe i still dont follow 23:24
why would you want to not using the e.g. utf_ / latin1 encoders from the VM?
codesections I mean, it's a kind of off-the-wall idea (and I'm not _super_ serious for config file formats), but in theory if you have a structured config format, you should be able to skip processing some parts as strings, and encode them to whatever datatype you want. (E.g., the normal flow would be ConfigFile ==> Str ==> MyConfigObj, but this would let you do ConfigFile ==> MyConfigObj, which might be faster) 23:28
But reading config files is not an area where performance is super critical most of the time, and it'd make error reporting for invalid configs _much_ harder. Which is why I'm not really serious. I just think the fact that we have access to that low a level feature of the runtime pretty neat 23:30
moon-child m: say <1 2 3>[0 .. *-1]; say <1 2 3>[0 .. *]; say <1 2 3>[0 .. *+1] 23:35
camelia (1 2 3)
(1 2 3)
(1 2 3 Nil Nil)
moon-child ^^ why isn't <1 2 3>[0 .. *] (1, 2, 3, Nil)? 23:36
codesections moon-child: that's pretty magical. In both a good and a bad way
codesections Well, my question was, "why isn't <1 2 3>[0 .. *] <1 2>?" 23:38
moon-child not thinking of ..^ * ? 23:39
codesections (since * means "whatever default makes sense in context", I would have thought that 0..* means the whole thing. But you clearly thought it meant 'the length of the list'. And Raku makes us both right, by magic) 23:40
moon-child ah hmmm 23:41
moon-child I thought * was a whatevercode to which was passed the length of the list 23:42
moon-child m: print -6 .abs 23:58
camelia 6
moon-child m: print -6 .WHAT
camelia ===SORRY!===
Method call must either supply a name or have a child node that evaluates to the name
moon-child m: print (-6).WHAT
camelia Use of uninitialized value of type Int in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <tmp> line 1
moon-child er
m: print: (-6).WHAT
camelia ( no output )