[06:31] yeah, the 2nd one was the one I'm thinking about [06:33] i did stumble on Think Raku and htat looked enticing but may be a little too basic, though I'm sure I'd get something out of it [06:33] so I had this test trying to run a command in my module: [06:33] ``` [06:33] my $proc; [06:33] output-like { [06:33] $proc = run 'bin/process_vimwiki_with_raku_module', :out, :err; [06:33] $proc.err.slurp(:close).say; [06:33] $proc.out.slurp(:close).say; [06:33] say $proc.exitcode; [06:33] }, rx 'hi', 'got output'; [06:33] ``` [06:35] took me a while before it dawned on my I had a permission problem. But I could not get proc to report the "permission denied" error and I don't know why. the :err and :out were reporting nothing. [06:53] *** sivoais_ left [06:54] *** sivoais joined [08:03] i think that's because the "permission denied" error is coming from/printed by the shell, not the stderr of the process [08:04] so is there no way to get at that? [08:05] i'm not sure. lots of noise when i try to google that [08:08] you could do something like `my $executable = "bin/process_vimwiki_with_raku_module"; if $executable.IO.x { $proc = run $executable. :out, :err; ... }` [08:10] that would work if I knew what to specifically look for [08:10] but let's say it fails for some other reason, how would I know? [08:11] well, the exitcode is usually non-zero if there's a problem [08:11] *** discord-raku-bot left [08:11] *** discord-raku-bot joined [08:13] hm, `.x` just seems to check if there's an execute bit set at all, not whether you have permission [08:14] right, but if the os failed to execute the command for some other reason, there's no way to get at the reason? [08:19] well, you could use `shell` instead of `run` [08:20] oh interesting. didn't know that existed [08:21] there are downsides, but i do get the 'permission denied' in the :err of the `shell` call [08:21] i'll do that if this every happens again (hopefully next time I'll realize faster that it's probably a perm problem [08:22] alright, off to bed. thanks. later [08:22] np [08:24] seems like run is a good candidate to create a wrapper script for. Quite a bit of code compare to good old back ticks or system() command. [08:24] wrapper function, I mean [08:36] yep [09:07] *** dakkar joined [09:18] `run` currently has issues, you can use `Proc::Async` instead https://docs.raku.org/type/Proc::Async [10:12] *** wingfold joined [10:51] *** wingfold left [11:06] *** razetime joined [12:07] *** wingfold joined [12:08] *** immediate joined [14:27] oh interesting. good to know. what are the issues with run? Is it just on latest raku version? I'm running rakudo from december. [14:38] *** wingfold left [14:54] and what are the issues exactly? [15:03] the reason I use run rather than Proc::Async is exactly that the latter is overkill; one might as well use Python and subprocess [15:07] What is the difference between calling comb and just matching against the pattern? [15:09] comb? [15:09] are you asking me about my proc code above? [15:09] probably not [15:17] nop [15:33] Nemokosch: comb doesn't only take patterns [15:34] "abcdef".comb(2) is a bit more readable than, say, "abcdef" ~~ m:g/ .. / [15:35] Also, comb by default returns strings, whereas matching provides match objects (which stringify as you'd expect, but aren't actually strings, so there's a bit more overhead that may not be necessary) [16:09] Yes, I knew the latter [16:09] to be more specific: what do they do with overlapping matchings? [16:10] *** razetime left [16:11] for `comb`, I suppose it makes sense to not deal with stuff like this [16:11] but I wouldn't have been surprised if `match` could produce overlapping matchings inside the list [16:11] or like, matching in general [16:25] got this to run a command in my test file [16:25] ``` [16:25] sub run_cmd(*@args) { [16:25] my $proc; [16:25] $proc = run 'bin/process_vimwiki_with_raku_module', @args, :out, :err; [16:25] $proc.err.slurp(:close).say; [16:25] $proc.out.slurp(:close).say; [16:25] } [16:25] ``` [16:26] so I want to simulate running a the command with no @args passed [16:26] how do I default @args to undefined? [16:37] ok, nvm. problem was with the call to run_cmd [16:37] was using a capture [17:35] *** dakkar left [18:51] *** uzl[m] joined [20:23] *** immediate left [21:02] *** sisar joined [21:18] *** sisar left [22:34] How can I do multi resolution based on the number of arguments pass via an @args argument? [22:35] so if there is one element...oh just hit me, I think [22:35] I can do `*@args.elems == 1`, is that right? [22:36] or actually `*@args where @args.elem == 1` I guess [22:37] the most common is [22:37] @args where * == 1 [22:38] ah, intersting [22:38] == is a numerical equality, so * == 1 is actually *.Numeric == 1, which in turn is @args.Numeric == 1, and for Positionals, the numeric is identical to .elems [22:39] actually, you can even get rid of the * == [22:39] right [22:39] figured it was something like that. didn't know about the .Numeric bit, though. thanks! [22:39] @args where 2 [22:40] huh. that's kind of crazy [22:41] IIRC is because when it's given a literal, it does smartmatching @args ~~ 2, and that also will push @args into numeric context, generating the 2 [22:41] but IMO where * == 2 or where .elems == 2 makes more sense to me in general coding [22:43] yeah, the "where" kind of makes it weird [22:43] when would be nice [22:58] now if I wanted to make sure args[2] was an Int, what's the proper way of doing that? [22:58] at the same time I'm checking the number of args? [22:58] I can just add an `&& @args[1]` [22:58] but I'm not sure how to get the type. I remember reading this can be tricky and some methods are unreliable [23:01] you can't just add && … because then the smart matching won't work as expected [23:02] actually wait [23:02] ok. and so how do I properly check the type of the arugment? [23:02] you can. Sorry my code still had a 'where 2' so .[2] would necessarily have to fail [23:02] *@args where 3 && .[2] ~~ Int [23:04] jesus [23:04] Yes [23:04] Something else, I think I have asked this before [23:04] But if you know how many args you're going to get, why do you need the slurpy? [23:05] How do you stop a sequence when reaching zero as a value? [23:06] Another option, probably cleaner: [23:06] that was a holdover from when I was doing thing the old school way and doing argument checks inside the body [23:06] what I do is write code the way I know how and then try to figure out how to make it more raku like [23:06] how does that work? Wouldn't `3 && condition` just be the condition [23:06] I would thing you would need `3 & *[2] ~~ Int:D` or sth [23:06] I would think you would need `3 & *[2] ~~ Int:D` or sth [23:07] multi sub foo ( @args ($, Int, $, $) ) # all of the $ are "I don't care" [23:07] which could also use any slurpies, depending on how you want to call [23:08] oh, wow, that's nice [23:08] a lot easier to wrap my head around and read [23:11] lakmatiol: 3 && .[2] ~~ Int:D is equivalent to [23:14] err actually, you're right. [23:14] * guifa_ needs to finish coffee before coding [23:15] But I'm not sure if the whatever block works in that context. It's probably best to just do an explicit block at that point [23:15] where { .elems == 3 && .[2] ~~ Int } [23:16] Nemokosch: what's the context of creating / using the sequence? [23:16] where is this bridged to? [23:16] libera? [23:17] hmm, complier seems to have a problem with multis used with @args (Str, Int, etc). It can't tell @args (Str, Int) apart from @args(Str) [23:17] huh [23:18] *** drakonis joined [23:19] got this: `multi process_args(@args (Str) where @args.elems == 1)` [23:19] and this: [23:19] `multi process_args( @args (Str, Int) where @args.elems == 2 )` [23:19] aha, so it is. [23:19] getting this: Re-declaration of process_args from process_vimwiki_with_raku_module:32 [23:19] Nemokosch: 10, * - 1 ... 0 will terminate on zero, just have to make sure the sequence actually hits zero. Otherwise can use 10, * - 1 ... * ≤ 0; [23:19] (sometimes useful to the ≤ 0 if you've got fractional stuff, etc ) [23:23] even without the types in signature, it still can't distinguish between `where @args.elems == 1` and `where @args.elems == 2` [23:23] m: multi sub foo(*@a (Str)) { say "A" }; multi sub foo(*@b (Str, Int) ) { say "B" }; foo 'a'; foo 'b', 1; [23:23] rakudo-moar fde422c60: OUTPUT: «A␤B␤» [23:24] m: multi sub foo(*@a (Str) where @a.elems == 1) { say "A" }; multi sub foo(*@b (Str, Int) where @b.elems == 2) { say "B" }; foo 'a'; foo 'b', 1; [23:24] rakudo-moar fde422c60: OUTPUT: «A␤B␤» [23:24] do you have maybe another nother process_args that you didn't declare as multi? [23:28] yeah, trying to work through that now and figure out what's going on. [23:29] could also be a bug in the IDE. I got an IDE error [23:31] Yeah, the IDE might just be looking at @args, and not compare beyond that [23:31] are you using Comma or? [23:31] yeah, comma [23:32] I've noticed lately it's occasionally had some issues with multi subs. But the code should run fine (as you can see above) [23:32] so I'm getting the same error when the code is run. maybe i'm doing the multi wrong. it's been a few weeks since I've done it so i'm rusty [23:32] Can you post the code as a gist? [23:33] * guifa_ has to go afk for a bit [23:33] heh, yeah, was wondering when that feature might come in handy [23:35] ok, here it is: https://gist.github.com/sdondley/ab982e5031aea58d09d718e6f924d526 [23:35] i'll post the whole file, too, one sec [23:36] https://gist.github.com/sdondley/d73d48449b924fd2774416d6e0a01cee [23:36] there's the whole file, most of it is commented out [23:48] ok, it is the IDE. it is running fine, had to fix something else in my code to get it to run [23:50] you can see the errors there underlined [23:50] let me restart [23:50] errors came back [23:54] yeah, so code runs perfectly fine, IDE reports bugs. comma doesn''t have a very good reporting system. they seem short-handed