🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel! Set by lizmat on 25 August 2021. |
|||
00:00
Doc_Holliwood left,
TempIRCLogger joined,
Doc_Holliwood joined,
discord-raku-bot joined,
Summer joined,
Maylay joined,
timo joined,
unixcat64 joined
00:02
reportable6 left
00:03
reportable6 joined
00:11
jmcgnh joined
00:27
Doc_Holliwood left
|
|||
tbrowder | tonyo: thank you very much! | 00:41 | |
tellable6 | 2021-09-03T15:45:56Z #raku <tonyo> tbrowder a PR would be great - i like the idea of using env vars to override defaults and leaving the defaults as is | ||
tbrowder | .tell tonyo thanks, i'll work on the PR | 00:42 | |
tellable6 | tbrowder, I'll pass your message to tonyo | ||
01:03
quotable6 joined
01:04
melezhik left
01:15
keutoi joined
01:22
melezhik joined
|
|||
melezhik | how can I catch exceptions withing cro routers? | 01:23 | |
looks like things like CATCH do not work for me | |||
or try {} ... - github.com/melezhik/sparky/blob/cr...#L291-L298 | 01:24 | ||
an error is not cached and propagated to cro itslef | 01:25 | ||
01:27
justsomeguy joined
|
|||
melezhik | for example - gist.github.com/melezhik/73a4bc541...a3b78b6d65 , when broken yaml is rendered - github.com/melezhik/sparky/blob/cr....raku#L291 | 01:27 | |
01:30
melezhik left
01:42
justsomeguy left
|
|||
ugexe | what does your catch example look like? | 01:44 | |
raku -MCro::HTTP::Router -MCro::HTTP::Server -MYAMLish -e 'my $application = route { get -> { my %y; my $err; try { %y = load-yaml("asdf"); CATCH { default { $err = $_.Str; say "error:$err"; } } }; content "text/plain", $err } }; my Cro::Service $s = Cro::HTTP::Server.new: :host<localhost>, :port<10000>, :$application; $s.start; react whenever signal(SIGINT) { $s.stop; exit; }' | 01:48 | ||
it wasnt showing the error to the connecting client until i changed `$err = $_` to `$err = $_.Str` | 01:49 | ||
might try $!.Str | 01:50 | ||
well i guess you already do that with "$!" | 01:51 | ||
raku -MCro::HTTP::Router -MCro::HTTP::Server -MYAMLish -e 'my $application = route { get -> { my %y; try { %y = load-yaml("!") }; content "text/plain", "$!" } }; my Cro::Service $s = Cro::HTTP::Server.new: :host<localhost>, :port<10000>, :$application; $s.start; react whenever signal(SIGINT) { $s.stop; exit; }' | 01:56 | ||
that works as expected for me | |||
02:02
skaji left,
skaji joined
02:17
rakuUser left
02:51
melezhik joined
|
|||
melezhik | . | 02:51 | |
moon-child | .. | 02:52 | |
melezhik | ugexe thanks, could you try add cro template to your example? | 02:53 | |
03:03
melezhik left
04:03
quotable6 left,
notable6 left,
nativecallable6 left,
evalable6 left,
statisfiable6 left,
tellable6 left,
squashable6 left,
bloatable6 left,
greppable6 left,
unicodable6 left,
linkable6 left,
coverable6 left,
committable6 left,
benchable6 left,
sourceable6 left,
reportable6 left,
bisectable6 left,
releasable6 left,
shareable6 left
04:04
evalable6 joined,
benchable6 joined
04:05
committable6 joined,
coverable6 joined,
statisfiable6 joined,
linkable6 joined
04:06
bloatable6 joined,
unicodable6 joined,
nativecallable6 joined,
tellable6 joined,
greppable6 joined,
releasable6 joined
04:30
Doc_Holliwood joined
05:00
keutoi left
05:04
shareable6 joined
05:07
reportable6 joined
05:45
yjh joined
05:50
yjh left
06:02
reportable6 left
06:03
reportable6 joined
06:04
notable6 joined
06:05
bisectable6 joined
06:06
squashable6 joined
06:09
squashable6 left
06:11
squashable6 joined
06:32
Doc_Holliwood left
07:14
keutoi joined
07:27
holyghost joined
07:31
frost joined
|
|||
xinming | When I use $obj.raku to dump the object, What is the right way to load the data again? | 07:42 | |
trying to find data format which can exchange data which is like json, but also supports Capture in raku, failed, So sticking with the raku itself. :-) | 07:43 | ||
08:06
sourceable6 joined
08:27
Sgeo left
|
|||
keutoi | I'm not sure of any idomatic way to do it but, EVALFILE gives the result of the last expression in a file, so that might work. | 08:42 | |
xinming | well, I know the EVAL function, But I wish we can have some better way to handle it | 08:47 | |
08:55
ufobat joined
|
|||
keutoi | I think EVAL might be the only option. Most docs for the `raku` method just state: Returns an implementation-specific string that produces an equivalent object when given to EVAL. | 09:06 | |
holyghost | PHP has a vardump function | 09:11 | |
which is non-meta info | 09:12 | ||
so vardump($v) in PHP ---> '2' | 09:13 | ||
in your browser to debug | 09:14 | ||
so mbe have a $obj.dump, #obj.dump-meta | |||
sorry let me rephrase that : $obj.dump, $obj.dump-meta | |||
meta info can be used as in a C++ exception (or other such languages) | 09:15 | ||
just given as an example | 09:16 | ||
exceptions are stack based, so can be th meta info. I don't know about raku exceptions though | 09:18 | ||
print, dump, eval | 09:20 | ||
or say | |||
intelligent stack-based meta info | 09:23 | ||
so your compiler fetches more information from its runtime | 09:24 | ||
It's just a C++ thing | 09:27 | ||
and maybe scheme/LISP for the eval functionality | 09:29 | ||
09:55
evalable6 left,
linkable6 left
09:56
linkable6 joined
|
|||
keutoi | Is rakudocs.github.io still being used? | 10:10 | |
raydiak | PHP doesn't have the concept of a Capture, so serializing it is a non-issue for them. that said, I'm personally not aware of any serialization formats which support Captures. though rolling your own might not be so bad, just an array and a hash would be a good start. several serialization formats in the ecosystem support arrays and hashes ofc. if you're looking for something in core, then yes you're left with | 10:21 | |
only EVAL. .raku and .EVAL are meant to round-trip with each other | |||
though personally if I found myself tring to serialize Captures, in most cases I'd first stop and ask myself if my design ought to be rethought | 10:22 | ||
holyghost | np, just feeding the features | 10:23 | |
tbrowder | .tell tonyo i'm confused. it looks like you have already implemented the env var, thank you very much! | 10:24 | |
tellable6 | tbrowder, I'll pass your message to tonyo | ||
tbrowder | ok, i see, you called my issue a feature request and completed it. thanks again! | 10:27 | |
raydiak | though it does bring up the idea of raku-centric serialization. a format which can round-trip all/most raku data structures without EVAL would be a pretty cool thing | 10:28 | |
10:28
frost left
|
|||
raydiak | though apparently "though" is my word of the day though :) | 10:30 | |
10:38
jjido joined
10:42
linkable6 left
10:44
linkable6 joined
10:55
evalable6 joined
11:06
quotable6 joined
11:08
lichtkind joined
|
|||
lizmat | raydiak: a Raku version of Sereal maybe :-) | 11:10 | |
11:32
ufobat left
|
|||
xinming | raydiak: Because it's cool to serialize Capture. :-) | 11:33 | |
jsonrpc has some forms of args passing, but it's not as powerful as Capture | |||
If we can serialize capture, We can be more "specific" about what we want for the RPC. | 11:34 | ||
11:40
jjido left
11:49
jjido joined
12:02
reportable6 left
12:36
Doc_Holliwood joined
12:48
eseyman left
13:05
reportable6 joined
14:17
b2gills left
14:18
b2gills joined
|
|||
raydiak | lizmat: I haven't used Sereal, only have a vague recollection of some work with Storable close to 20 years ago...but from what I'm reading about Sereal, yes, some approximation of that | 14:45 | |
xinming: I'm certainly not against such a thing existing and don't want to dissuade you, but imo an external API should usually be simple and language-agnostic...seems like this wouldn't be either of those things if I understand correctly? | 14:47 | ||
if Capture is specifically what you want, perhaps you could rip some relevant parts of the grammar straight out of the rakudo parser... | 14:51 | ||
14:58
eseyman joined
15:01
monkey_ joined
15:17
Doc_Holliwood left,
holyghost left
15:45
jjido left
15:50
jjido joined
15:51
monkey_ left
15:56
keutoi left
16:04
xkr47 left,
xkr47 joined
16:09
whatnext joined
16:12
jrjsmrtn left
16:14
jrjsmrtn joined
|
|||
spacekookie | I'd be curious if people here have favourite programs written in Raku I could try first to see if my packaging tools work :) | 16:36 | |
It's gonna be more challenging (and useful) than my tiny scripts | |||
16:58
whatnext left
|
|||
Anton Antonov | I want like to write a Raku package that provides a grammar / parser for Mathematica aka Wolfram Language (WL). I am considering several package names: 1) `Grammar::Mathematica` 2) `Mathematica::Grammar` 3) `WL::Grammar` 4) `Grammar::WolframLanguage` 5) `FoxyGoat`. Which one do you think it is bests? | 17:03 | |
Looking at modules.raku.org/search/?q=Grammar I see both `Grammar::<name>` and `<name>::Grammar` to be equally represented. | 17:04 | ||
17:04
jjido left
|
|||
raydiak | spacekookie: Not sure about "favorite" but you could try App::Pray. Still works last time I checked. Not popular or useful or anything, but it's fairly extensive and also has a few dependencies, so might be a decent test of packaging tools | 17:05 | |
I haven't done serious work on it in years, so there's some anachronisms especially in the META6.json, but you're going to see that all over the ecosystem anyway. main thing off the top of my head that it wouldn't test is %?RESOURCES (they didn't exist when I wrote it) | 17:07 | ||
spacekookie | Thanks! I'll have a look at it | 17:10 | |
I'm not very experienced with raku anyway, so it'll be a good thing to learn these things too. I'm currently mostly trying to improve the tooling in NixOS so I have a nicer time playing with the language down the road ;P | 17:11 | ||
raydiak | that's a cool way to go about it, not just learning by doing but also paving the way at the same time | 17:13 | |
Anton: my vote would be for Grammar:: instead of ::Grammar, unless you plan to develop a collection of related things which would be grouped together under Mathematica:: | 17:16 | ||
Anton Antonov | @raydiak Thanks! And good point -- I have to decide do I want to implement "other things" under `Mathematica::`. I am undertaking this because I want to convert a bunch of unit tests from Mathematica to Raku. Hence, I might have additional `Mathematica::*` packages / modules. | 17:20 | |
17:22
neither joined
|
|||
neither | hi, if I want to alias a method of a class, should I write another method and directly call the other one? e.g., `$obj.very-long-name` and `$obj.vln` where `method vln() { self.very-long-name}`? Or is this better done another way? | 17:27 | |
17:27
Sgeo joined
|
|||
moritz_ | there are other methods, like installing it with a new name through the metaclass. Is that "better"? depends on what you optimize for | 17:28 | |
m: class A { method x { say 42 } }; A.^add_method("y", A.^find_method("x")); A.y | |||
camelia | 42 | ||
moritz_ | ah, you should also throw in A.^compose(); after you are done introducing new methods (it works without it in this specifici case, but it's more robust to include it) | 17:29 | |
raydiak | Anton: sounds like a fun project. and you're welcome, of course | 17:39 | |
neither | Thank you moritz_, by better I meant conventional|idiomatic because I'm new to the language | 17:44 | |
sorry for not being clear in the first place | 17:45 | ||
17:54
neither left
|
|||
moritz_ | neither: nothing easier to read than a method that calls another method | 17:54 | |
tellable6 | moritz_, I'll pass your message to neither | ||
17:56
neither joined
|
|||
raydiak | imma paste this because your connection flaked out for a minute and you missed it: | 18:00 | |
17:54:15 moritz_ | neither: nothing easier to read than a method that calls another method | |||
18:02
reportable6 left
18:24
Doc_Holliwood joined
|
|||
neither | Thanks | 18:25 | |
tellable6 | 2021-09-04T17:54:16Z #raku <moritz_> neither: nothing easier to read than a method that calls another method | ||
MasterDuke | neither: there's also raku.land/cpan:ELIZABETH/Method::Also | 18:36 | |
18:46
monkey_ joined
18:59
jjido joined
19:04
reportable6 joined
|
|||
neither | thank you MasterDuke, that's very readable | 19:19 | |
19:36
Doc_Holliwood left
19:40
monkey_ left
20:18
monkey_ joined
|
|||
klebs | hi folks! am wondering about whether there is a way to (within a grammar rule) match a token and some suffix, without having the suffix appear when expanding the rule itself | 20:20 | |
specifically, I have some rule for "numeric" values | |||
actually, it is a token | 20:21 | ||
```raku | |||
token numeric-value { | |||
[ '+' | '-' | '~' ]? <[ 0..9 ]>+ [ '.' <[ 0..9 ]>+ ]? [ 'e' <.numeric> ]? | |||
} | |||
token numeric-suffix { | |||
20:21
discord-raku-bot left
|
|||
perryprog | pfft | 20:22 | |
20:22
discord-raku-bot joined
|
|||
klebs | but then, as can be seen in "array-dimension" and "expression", my grammar currently uses <.numeric> to gobble numerics without regard for what is inside them | 20:22 | |
moon-child | @klebs, part of your message got cut off here, but I expect you want lookahead | ||
klebs | thanks @moon-child -- i think I *almost* want lookahead, but I want the parsing to gobble the lookahead somehow so it goes away later in the parsing | 20:23 | |
20:24
xinming left
|
|||
moon-child | oh. In that case, just nest the token in another, and only look at the inner token | 20:24 | |
klebs | in other words, i want numerics, when they are used as <.numeric> to always just return their <numeric-value> with *no* suffix | 20:25 | |
20:25
Xliff joined
|
|||
Xliff | \o | 20:25 | |
Xliff just purchased the parts for a new rig. | |||
Threadripper arrives in 10 days! :q | |||
20:25
xinming joined
|
|||
moon-child | threadrippers are nice! | 20:25 | |
Xliff | moon-child: Have one? | 20:26 | |
Will be my first AMD build... | |||
klebs | the trouble is, I have a quite large codebase which unfortunately assumes everywhere that it can directly use numerics naked as they are | ||
moon-child | Xliff: yea. Work-provided, so I didn't have to foot the bill, too | ||
Xliff | www.newegg.com/amd-ryzen-9-5950x/p...6819113663 | 20:27 | |
klebs | so doing that nesting would be a breaking change in perhaps many locations | ||
im looking for some way of hooking it somewhere so i can specify in one single place what i want to happen | |||
which is for something like "18.05f" to parse successfully as "numeric", but come back as "18.05" when we ask for <.numeric> within another rule | 20:28 | ||
is that possible? | |||
Xliff | moon-child: Hah! Nice. Unfortunately, I have to take matters into my own hands. | ||
klebs | perhaps i could edit the match object somehow? unfamiliar with the nuances of this | 20:29 | |
what about something like this? ```raku | 20:34 | ||
#!/usr/bin/env raku | |||
use v6; | |||
grammar Numerics { | |||
rule TOP { | |||
<.ws> <array-dimension> | |||
} | |||
token numeric-value { | |||
[ '+' | '-' | '~' ]? <[ 0..9 ]>+ [ '.' <[ 0..9 ]>+ ]? [ 'e' <.numeric> ]? | |||
} | |||
token numeric-suffix { | |||
| 'f' | |||
20:34
RandalSchwartz joined,
RandalSchwartz left
|
|||
moritz_ | please use a pastebin for code | 20:34 | |
klebs | pastebin.com/raw/PZKtLesP | 20:36 | |
oh, moritz!! I bought and read your book! thank you so much! I will remember to write you an amazon review 🙂 | 20:38 | ||
it was great! | |||
Xliff | m: my token numeric { <numeric-value> <numeric-suffix>? { $/ = $/<numeric-value>; say "edited: $/" }; } | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Unrecognized regex metacharacter ; (must be quoted to match literally) at <tmp>:1 ------> 3 = $/<numeric-value>; say "edited: $/" }7⏏5; } expecting any of: horizontal whitespac… |
||
klebs | super helpful to me | ||
Xliff | m: my token numeric { <numeric-value> <numeric-suffix>? { $/ = $/<numeric-value>; say "edited: $/" } } | ||
camelia | ( no output ) | ||
Xliff | m: my token numeric { <numeric-value> <numeric-suffix>? { $/ = $/<numeric-value>; say "edited: $/" } }; say "18.04" ~~ &numeric | ||
camelia | No such method 'numeric-value' for invocant of type 'Match' in regex numeric at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
moritz_ | assigning to $/ doesn't make much sense; using make() is better for extracting values and storing them in match objects | 20:39 | |
20:39
neither left
|
|||
Xliff | moritz: Would that code block be better served as <{ ... }> | 20:39 | |
Or does it matter? | |||
moritz_ | <{ ... }> is when you want to change the regex behaviour; { ... } is for pure side effects | 20:40 | |
Xliff | Ah, thanks! | ||
moritz_ | to be precise, the regex engine interprets the result of <{ ... }> as a regex, and matches that | 20:41 | |
Xliff | Why am I getting "Messages Failed to Load" on Discord every time I try to use it? | ||
klebs | i basically want to insert some sort of shim, because I unfortunately use <.numeric> all over the place in the grammar (which is quite large by now) | ||
i want to gobble any numeric-suffix without ever passing it upstream | |||
moritz_ | maybe try to use )> then to limit the match object? | ||
m: say 'abc' ~~ /a )> ../ | 20:42 | ||
camelia | 「a」 | ||
moritz_ | it matches the whole string, but only includes the a in the match object | ||
klebs | oh, that does seem to be what i am looking for -- however it doesn't seem to be working when I try it within the grammar | 20:44 | |
in that same pastebin, when i insert it in between numeric-value and numeric-suffix | 20:45 | ||
token numeric { <numeric-value> )> <numeric-suffix>? } | |||
moritz_ | then I really recommend going with { make +$<numeric-value> } and using $/<numeric>.made | ||
shouldn't be too hard to find the usages with your editor's search function | 20:46 | ||
Xliff | Can I get an invite for the raku discord, please? | ||
klebs | <@742445366489645080> it is here: www.raku.org/community/ | 20:48 | |
@moritz_ I am wondering why )> works for the example you gave but not within the grammar I have | |||
ie, pastebin.com/raw/2Ni0f5qR | 20:49 | ||
moritz_ | probably because the rest of the regex engine also thinks that the regex has only consumed the numeric part, not the letter after it | 20:50 | |
klebs | i see | 20:51 | |
is that a bug? that seems the same as lookahead, no? | 20:52 | ||
moritz_ | I don't know if it's a bug or a feature. Could go either way. | 20:57 | |
klebs | fair enough 🙂 | 20:58 | |
that is a useful trick i didn't know though (at least for individual matches) | |||
thanks! | |||
moritz_ | you're welcome | ||
klebs | your book was great 🙂 | ||
moritz_ | thanks :D | 20:59 | |
always happy about ratings on amazon... (hint, hint) :-) | |||
klebs | i will write you a glowing review for sure! | ||
moritz_ | thanks :D | 21:00 | |
klebs | what i liked about it the most was that it was basically 100% useful information, with an extraordinarily high ratio of information which was not obvious and unlocked higher usages of the skill itself | 21:01 | |
in fact, i i might use that sentence in my review 🙂 | 21:03 | ||
21:04
jjido left
|
|||
is there a way to edit the global match tree from within a { } block inside a token? | 21:09 | ||
Xliff | m: %h = ( a => 1, b => 2, c => 3 ); my $a = 'a'; %h{$a}:exists.say | 21:24 | |
camelia | 5===SORRY!5=== Error while compiling <tmp> Variable '%h' is not declared at <tmp>:1 ------> 3<BOL>7⏏5%h = ( a => 1, b => 2, c => 3 ); my $a = |
||
Xliff | m: my %h = ( a => 1, b => 2, c => 3 ); my $a = 'a'; %h{$a}:exists.say | ||
camelia | True | ||
22:04
evalable6 left,
linkable6 left
22:05
linkable6 joined
22:55
jast joined
22:57
monkey_ left
22:59
xinming left,
xinming joined
23:06
evalable6 joined
23:10
lichtkind left
|