🦋 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.
elcaro .tell Ben93 $str.match(/ '"' <-["]>* '"' | \S+ /, :g).map(~*); 00:02
tellable6 elcaro, I'll pass your message to Ben93
elcaro who knows if they'll ever return to get that message
moritz: you were indeed thinking of «...» quoting. « this 'but also' that ».elems == 3 00:04
guifa2 summerisle: I'm not really sure of one where it'd be awkward. I've actually as a general rule for anything that's documented split things up with the sub declarator on one line, each parameter on a line under that, and then ) is … { on its own line under that. It's quite clean actually and visually stuff jumps out nicely 00:20
summerisle yes, I do prefer that as well guifa2, but was just curious as to whether such a thing existed. 00:53
notagoodidea Stupid question, when using quoting constructs with interpolation like qq, when does the interpolation kicks in? at assignement? 08:39
sortiz notagoodidea: At literal evaluation time. I.e. just before the Str is constructed. 08:48
notagoodidea sortiz: hum, okay. When I slurp a file with text inside "foo bar $bar" without the quotes, interpolation does not happen because slurp construct a Str without interpolation, right? 08:54
sortiz Yes.
Discipulus hello folks! 10:59
I read on perlmonks an interesting question about raku on windows 11:00
it seems that raku expand * passed in the command line as glob fo surdir filenames
*as glob of curdir filenames 11:01
cmd.exe was always unable to expand * so it must be raku
details: www.perlmonks.org/index.pl?node_id=11128174 11:02
El_Che don't people use a capable terminal on Windows nowadays? I hear there is even one created by MS 11:06
github.com/microsoft/terminal 11:07
Discipulus eh eh.. evidently not 11:10
but the question is valid: must be something on raku side to the glob and I cant find it documented
El_Che it looks to me that raku does what's expected 11:12
and the poster should quote correctly
(for instance perl works on the same way on Linux als raku) 11:15
Discipulus mmhh.. 11:16
args are not processed by the 'shell' ? 11:17
El_Che this is the entry point: github.com/rakudo/rakudo/blob/mast...in.nqp#L57 11:22
Discipulus for the little I understand nothing is done there. So where the expansion of * happens? 11:25
Scimon Is the raku command on windows a batch file wrapping a call to the VM? Might it be in there? (I'm on Linux ATM so can't check). 11:40
wbiker Hi all!
I am looking for some kind of destructors methods for class instances. I want to clean up object created during the lifetime of a class. These objects are stored as array and a method exist to delete them. However. calling a method is cumbersome and I want to avoid that. My first thought was to use the END phaser, which did not work, because I do
not have access to the self. Is there a way to call a class method at destruct time?
patrickb shouldn't be anymore...
wbiker: submethod DESTROY 11:41
wbiker AH, thanks a lot! 11:42
lizmat note that this method will only be called when the object is actually removed from memory during a GC run
patrickb but it's only called on gc cleanup of the object.
lizmat right :-)
wbiker: modules.raku.org/dist/FINALIZER may also be of interest 11:43
wbiker Hmm. Thats bad because I need a database connection during cleaning. 11:44
Hmm, FINALIZER looks like it is what I am looking for. Thanks Liz! 11:45
patrickb .tell finanalyst I just noticed all the work you have done in the area of pod rendering. Do you think it makes sense / is possible to integrate into one of our module webpages? 12:07
tellable6 patrickb, I'll pass your message to finanalyst
Sir_Ragna When matching on a grammer, is there a way to know why the grammar doesn't match? Is it possible to get some kind of error such as "no semi-collon at the end of this line" ? 15:04
MasterDuke  there's a Grammar::Debugger that can help
db48x and there are several for helping you create error messages 15:11
but Grammar::Debugger is a bit dissappointing. it can only tell you what your named regexes are doing; it just skips over all the unnamed parts of the regex 15:12
and when a regex failed it can't tell you why it failed
still, it's better than nothing 15:13
moritz well, it's a grammar debugger, not a regex debugger :-) 15:15
db48x right, but grammars are composed of regexes
moritz that they are
db48x so if you have something like rule foo { <bar> '::' <baz=zed> } in your grammar, then Grammar::Debugger might show bar matching followed by foo failing, leaving you to deduce that the '::' must not have seen a :: 15:17
db48x and if you want to know what characters the '::' tried to match against, you must follow along all the previous matches by hand, which is tedious and error-prone 15:21
Sir_Ragna Does Grammar::Tracer suffer from the same limitations? 15:22
db48x Sir_Ragna: they're the same thing, but Grammar::Debugger gives you a prompt and lets you single-step
Grammar::Tracer just single-steps through everything and prints it all out 15:23
Sir_Ragna I don't want that. I want to parse some grammar and tell the user where he messed up if the input is invalid.
moritz then you need to extend your grammar 15:25
and raise errors where an expected token doesn't show up
db48x Sir_Ragna: right, Grammer::Tracer and Grammar::Debugger are tools for the you, not your users
there are packages that help you add error messages
another good strategy is to extend your AST with incomplete or broken items
moritz perlgeek.de/blog-en/perl-6/2017-00...rrors.html
that's the precursor to the chapter on error reporting in my regexes & grammars book 15:26
maybe github.com/moritz/Grammar-ErrorReporting is of help as well 15:27
db48x moritz: that's a good overview, but I would say that there is a third level of error reporting beyond the "quite good" level 15:30
instead of throwing an exception for a key without a value, the grammar should successfully recognize it as a key without a value, and insert that fact into the generated AST 15:31
the grammar can then keep going and match the rest of the content 15:32
the caller can decide whether to fail with an error, or to print a warning and keep going
dakkar db48x: that's great when you can do that! it's not always possible to recover from bad input, so both techniques can (should?) be used together 15:33
moritz db48x: there are use cases where such things are desirable, and others where they are not
db48x that's true enough. and maybe you go into it in detail in your book; I've not yet read it 15:34
I think that it's always desirable in user-facing situations 15:35
even when you can't handle every possible error that way
raydiak seems like that may not work in situations where backtracking is necessary for a successful parse...???...
db48x raydiak: I'm not well-versed in Raku grammars specifically, so perhaps it isn't 15:37
in the general case, if an AST node indicating an error, then you backtrack and produce one that doesn't represent an error, you can keep the successful one 15:38
if both branches produce an error, that's information you should keep around to show to the user 15:40
raydiak depending on what you're parsing and how you wrote it, if something doesn't match, that's not necessarily an error. it goes on to try to match other rules, which may match successfully at the same point in the input you marked an error. which is why you want to specifically indicate these obvious error points manually in your grammar yourself. how would you know purely automatically *which* failed match should 15:41
get the error when the whole parse finally fails?
db48x right, your error messages should include both errors 15:45
raydiak that could potentially be far more confusing to end users. again, depending on the complexity of the grammar. if we're talking about an INI file or something, probably not terrible to do something like that. if we're talking about something more sophisticated, maybe quite a mess 15:48
I have some grammars that try 5-10 different rules or maybe more at different points. You should see the grammar::tracer output for math::symbolic. it's a bit hectic :) and I'm not the most sophistocated author if we're being honest 15:50
db48x sure, there's always a point where the ambiguity becomes too much 15:55
and math notation is very ambiguous
I wish I could go back in time a few hundred years and teach some mathematicians Scheme
raydiak no doubt. that was a project full of compromises and assumptions
dakkar "full of compromises and assumptions" describes any software that has to care about the real world ☺ 15:56
raydiak heh true enough, you'll get little argument from me 15:57
db48x and you always have to cut features to get things done in your time budget 15:58
you could spend an infinite amount of time making better and better error messages
it's probably best to improve them gradually without neglecting other aspects of your product 15:59
personally I've been rather dissapointed with Raku's error messages 16:00
take this one as a simple example: Unable to parse expression in metachar:sym<( )>; couldn't find final ')' (corresponding starter was at line 17) 16:02
metachar:sym<( )> is an internal name, probably not mentioned in the documentation
at /home/db48x/projects/reposurgeon/help-index.raku:18 16:03
------> ⏏}
raydiak it had been a focus of great effort in the past. truth is I've been mostly out of the game for several years and don't know what the current state of rakudo and its errors are
db48x line 18 is a terrible line to pick to show me the error, because it's not unique
and it does know the starting line
expecting any of: infix stopper
more internal names for grammar elements 16:04
although there's a decent chance that this one is documented
raydiak ah, yes. I did notice that the separation between internal and external errors seems a bit flimsy. that's what you get when you write your language in your language, I suppose
db48x here's the message I get when I make the same type of mistake in a Rust program: pastebin.com/raw/r9Ypm0ug 16:06
raydiak that is helpful. we aim for something like that, but it's not always right. last I knew, LTA errors were welcome to be reported as issues 16:08
db48x if I make the same error in a more complex situation, I get more complex errors: pastebin.com/raw/eCGV4p65 16:10
but you can see that although it recognizes that the syntax isn't right, it went ahead and typechecked it as well as it could
raydiak which, again, to me that makes the whole thing less legible. though that could also because I have never played with rust 16:14
db48x raydiak: possibly. the point is that the type errors arise from assuming the wrong location for the missing ) 16:15
foo.entry(…).or_default() would typecheck, while foo.entry(….or_default() does not 16:16
the fourth level of error reporting would be to try all valid places to put a ), and see which generates the fewest errors :)
the first error message could then point to that as the most likely place where it should have gone 16:17
but my point is primarily that getting to level three means that you have to produce a valid AST from invalid inputs, even though you know that you won't be able to complete the task with the AST you produce 16:18
rustc will never produce an executable if you have a syntax error, even if the error message does correctly diagnose the problem 16:19
but stopping immediately at the error would be stopping too soon
raydiak this could be very logically complex and computationally intensive quickly it seems like. what about longer inputs? what if I forgot a "." in a method call or a "," in a list? do you try to insert one between every adjacent pair of word characters in a symbol name? what if the input is massive? what if the error was actually earlier, but it was able to parse correctly at the error and only failed later in a 16:22
sub-rule?
db48x yea, there's a reason I've never seen anyone attempt the fourth level very seriously 16:23
although javascript does have automatic semicolon insertion 16:24
raydiak not to discourage you, just things to think about. you'd probably also want to talk to someone more expert in the whole "can't parse raku without executing raku" thing, meta-trickery might be part of why our errors are not so great in some places
db48x raydiak: of course, I don't mean to imply that this quality of error message is easy to reach, or that every language can even reach it 16:25
raydiak: at some point getting better error messages requires rethinking the language 16:26
raydiak maybe it could be written to analyze as much as it could in a couple of seconds or something, and give you the best answers it came up with in the alotted time, as one point of compromise
dakkar please don't let the compiler auto-guess-correct ☺ js semicolon insertion creates more problems than it "solves"
db48x dakkar: exactly. there's no type-checker in javascript, so it can't even tell if it's caused more problems than it's solving 16:26
dakkar 😁 16:27
db48x dakkar: I just meant that javascript is the only language I've seen that have any formal notion of correcting errors, however misguided it may be
I think I recall hearing of some early languages that would try to fix typos as well
dakkar oh yes, I was mostly writing for the rest of the "audience", lest they get ideas! 16:28
db48x :)
dakkar it's like when you type `git pust` and it tells you "did you mean `git push`?", and people ask "yes of course I did, if you can guess why don't you jfdi?" 16:29
db48x and going back to what I said about improvements to error messages requiring changes to the language, that's also not a suggestion that Raku needs to change
dakkar and the answer is "because one day you meant something else, and you've just pushed a commit you really didn't mean to" 16:30
db48x dakkar: exactly
it can be frustrating in both cases
dakkar I like my machines helpful, but not proactive
db48x I think the Rust developers did take into account error messages fairly early on in the development of the language. I'm guessing the Raku developers didn't, but all that says is that the Rust developers and the Raku developers had differing values, which is practically tautological 16:31
dakkar: well, it's ok for my machines to proactively cache things 16:32
or to proactively evict things from the cache when there's memory pressure 16:33
but if I want the experience of having someone else correcting syntax errors for me, I can just go wrangle a herd of junior developers 16:34
dakkar and we're back to compromises and assumptions 😜
(I've been asking for a junior/minion at $work for a while…) 16:35
raydiak there was definitely an excess of attention on error messages well before that first Christmas release. It is possible that some of that progress may have regressed as other things have been revised, though. last time I was working with it, I did notice core stuff leaking out more than necessary, and my own errors sometimes not being traced all the way down into without --ll-exception
db48x raydiak: right before the first release is not ver early in development :D 16:37
raydiak I didn't say "right" before, I said "well" before :) 16:38
Discipulus_ hello folks 16:41
raydiak LTA errors were something Larry Wall himself put attention and pressures on frequently in the years before, as I recall. Him being a linguist, that side of the communication in no way took a back seat in his mind. Where we're at now...idk
hello o/
db48x raydiak: ah
Discipulus_ this morning, some hours ago, I've asked about how raku treats args on commandline on windows cmd.exe
I've not the log if someone added something 16:42
Discipulus_ it seems that * is expanded as a glob of filenames, and cmd.exe is historically unable to do it 16:43
it is Raku doing this? It is documented?
I was kindly pointed to github.com/rakudo/rakudo/blob/mast...in.nqp#L57 16:44
db48x Discipulus_: it doesn't look like anyone added anything
Discipulus_ but I dont understand it and dunno where 'command_line' calll comes from
db48x: thanks, so we can continue :) 16:45
db48x Discipulus_: well, $comp is defined here: github.com/rakudo/rakudo/blob/mast...in.nqp#L15
so you could probably look for the source of the Perl6::Compiler package
Discipulus_ where? very raku ignorant here :) 16:46
db48x well, I'm as ignorant as you
but there's a Perl6 directory right next to that file
db48x and it has a Compiler.nqp file in it, so… 16:47
Discipulus_ this one? github.com/Raku/nqp/blob/master/sr...r.nqp#L257 16:49
db48x possible. I've just found the same thing
Discipulus_ ah ah I understand nothing of this :) 16:50
...but it seems to lead to process_args -> HLL::CommandLine::Parser -> follow the white rabbit 16:52
Discipulus_ someone can help me to understand github.com/Raku/nqp/blob/master/sr...ndLine.nqp ? 16:58
i tried to read it but I cant find something similar to a globbing function 17:04
db48x yea, a quick scan doesn't turn up anything like that 17:05
it just checks is-option($cur), which will be false
then it either slurps the rest of the arguments into a string or it pushes $cur to the list of arguments 17:06
and returns the lot
Discipulus_ yes I understood this way.. but the stupid cmd.exe is unable to glob so the mystery deepens 17:07
db48x what I would do if I were in your shoes is learn how to build Rakudo myself 17:09
then I would modify main.nqp and make it print out @ARGS in MAIN, before it does anything else
Discipulus_ db48x: thanks! 17:16
Discipulus_ if in the meanwhile someone can point me to some relevant doc or tell me why it happens.. even better :) 17:33
sortiz Discipulus_: In my Windows install if I pass a single * to a rakudo program nothing is expanded, the program got the asterisk as a string. 17:53
sortiz But if I invoke rakudo inside PowerShell then yes, the program got it expanded. So nothing rakudo specific. 18:00
Discipulus_ sortiz: ha! thanks.. see this if interested perlmonks.org/index.pl?node_id=11128174 18:02
PowerHell does not expand.. PS C:\Users\io> perl -E "say for @ARGV" a * b 18:05
krako[m] Hi everyone ! Today I've about the `newline` pragma. I tried on a Windows machine but the newlines are still `\r\n`. 18:07
I played also with `:translate-nl(False)` or `:nl-out("\n)` in `open(IO::Special.new('<STDOUT>'), :nl-out("\n"), :translate-nl(False));`
but nothing work, I still have the `\r\n` at the end. 18:08
Here is what I've tried and the output : pastebin.com/WC9kwmvL
Any idea or suggestions, please ?!
the script output was piped to `cat -A` 18:11
sortiz Discipulus_: Mystery solved. I my case the expansion is produced by rakudobrew's shims. I suppose the OP wasn't aware of them. 18:43
Discipulus_ sortiz: what is "rakudobrew's shims"? 19:22
mark[m]4 sent a long message: < matrix.org/_matrix/media/r0/downlo...essage.txt > 19:24
rakubrew.org/
`rakubrew mode shim`
Discipulus_ mark[m]4: thanks I'm reading 19:27
the shim mode can then expand * into a glob?
mark[m]4 Discipulus_: no pb
Discipulus_ the mistery is still unresolved: who does that glob? cmd.exe is too stupid to do it 19:55
and might be a way to escape the * 19:56
mark[m]4 Discipulus_: oh sorry I have no experience at all using rakubrew on windows :/ 20:00
(I actually just learned it is even available for the platform…) 20:01
Discipulus_ I'm interested in the principle: args are left to be processed by the shell or not? 20:08
sortiz Discipulus_: Indeed the mystery deepens. My moar-blead expands the arguments, moar-2020.12 does not.
Discipulus_ the perlmonks post quote: Raku: Rakudo version 2020.05.1 built on MoarVM version 2020.05 implementing Raku 6.d 20:10
Discipulus_ and it expands :( 20:10
sortiz The former was compiled with gcc (From strawberry perl), the last with Microsoft tools. 20:11
Discipulus_ ah! this is something 20:12
sortiz If time permits, I will dig in MoarVM's guts. 20:14
krako[m] excuse me but did I asked for something dumb in my previous question ? 20:15
sortiz krako[m]. No, but it seems that today there is no one with experience in that field. 20:16
krako[m] ok ! I didn't want to be annoying but in some chat, you got no response for dumb questions so I prefered to ask. 20:17
Discipulus_ soritz: very much appreciated. Can you post your findings at perlmonks? even anonymously? 20:20
sortiz krako[m]: There are no dumb questions here. But I don't know of any experts on everything. Raku is very big. 20:21
krako[m] big as there is a lot to learn ? 20:22
Discipulus_ krako[m]: do as I do, just ask :)
sortiz Yes, a lot. And a lot to forget ;-) 20:23
sortiz But you don't need to learn everything for it to be useful to you. 20:23
El_Che new rakudo-pkg infra around github actions is almost ready. With alpine repos 20:27
+ a workflow to allow devs to test releases and commit combinations of the rakudo components 20:28
sortiz El_Che++
krako[m] congrats El_Che ! 20:36
gfldex .seen [Coke] 23:25
tellable6 gfldex, I saw [Coke] 2021-02-05T20:35:20Z in #raku: <[Coke]> Might help if you had a small example that didn't work.
gfldex .tell [Coke] I found the most surprising cause for my troubles with adding a meta-method via MOP. The method added with .^add_meta_method must not be anonymous but have the same method name then the key in the meta method table. 23:27
tellable6 gfldex, I'll pass your message to [Coke]
gfldex Luckily .^add_meta_method is not documented so nobody will ever notice. :-> 23:28