🦋 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.
00:00 reportable6 left 00:03 reportable6 joined
guifa_ Tirifto: ha, indeed sometimes there's always an easier way around :-) (especially depending on what the information is that you're holding in the attributes) 00:10
00:27 ingy left 00:28 ingy joined 00:40 deoac joined 00:50 eseyman left, manu_ joined 00:51 manu_ is now known as eseyman 01:29 deoac left 01:34 aqua2 left 02:23 teatwo joined 02:26 tea3po left 02:30 deoac joined 02:31 derpydoo joined 02:56 Xliff joined
Xliff \\l 02:58
Ack... \o, even!
So is there a way to check a string for an invalid UTF8 sequence?
[Coke] tonyo: trying to get it run locally (done!) so I can work on some bugs 02:59
avuserow Xliff: assuming you have a Buf, you could try to decode it and check for errors? 03:10
m: CATCH {when /Malformed/ {say "it's bad"}}; Buf.new(0xff, 0xff).decode 03:11
camelia it's bad
avuserow m: CATCH {when /Malformed/ {say "it's bad"}}; Buf.new("abc".ords).decode
camelia ( no output )
avuserow looks like it's just an adhoc exception, otherwise you could match by type 03:14
[Coke] jjatria: hi; running raku.land locally takes 30+ minutes to download everything and make the web service report it has anything. how do you recommend testing changes to the app?
(restarting and waiting 30m is not boss)
Xliff CATCH {when /Malformed/ {say "it's bad"}}; Buf.new(0xff, 0xff).decode; say "Still running..."
evalable6 it's bad
Xliff ^^ Program must continue. 03:15
[Coke] m: Buf.new(0xff, 0xff).decode 03:16
camelia Malformed UTF-8 at line 1 col 1
in block <unit> at <tmp> line 1
Xliff CATCH {when /Malformed/ {say "it's bad"; .resume}}; Buf.new(0xff, 0xff).decode; say "Still running..."
m: CATCH { when /Malformed/ {say "it's bad"; .resume}}; Buf.new(0xff, 0xff).decode; say "Still running..." 03:17
camelia it's bad
This exception is not resumable
in block at <tmp> line 1
in any at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff So why is that exception not resumable?
avuserow m: sub is-valid-utf8(Buf $in) {CATCH {when /Malformed/ {return False;}}; $in.decode; return True}; say is-valid-utf8(Buf.new: 0xff, 0xff); say is-valid-utf8(Buf.new: "abc".ords)
camelia False
True
[Coke] Xliff: you need a block
Xliff m: { CATCH { when /Malformed/ {say "it's bad"; }}; Buf.new(0xff, 0xff).decode; } say "Still running..."
camelia ===SORRY!=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> bad"; }}; Buf.new(0xff, 0xff).decode; }⏏ say "Still running..."
expecting any of:
infix
Xliff m: { CATCH { when /Malformed/ {say "it's bad"; }}; Buf.new(0xff, 0xff).decode; }; say "Still running..." 03:18
camelia it's bad
Still running...
[Coke] m: {CATCH { when /Malformed/ {say "it's bad"; .resume}}; Buf.new(0xff, 0xff).decode;}; say "Still Running..."
camelia it's bad
This exception is not resumable
in block at <tmp> line 1
in any at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff [Coke]++
[Coke] m: {CATCH { when /Malformed/ {say "it's bad";}}; Buf.new(0xff, 0xff).decode;}; say "Still Running..."
camelia it's bad
Still Running...
[Coke] me type slow 03:20
Xliff :)
[Coke] xliff++
Xliff [Coke]: s'okay. Me type bad. 03:21
[Coke]: Oh, and hit 1,000,000 lines of Raku last month.
Still working, though. Now dealing with the Evolution libs.
One of these days I'll figure out a way to add what I need to zef so I can release! 03:22
So how can I test the above CATCH with a react/whenever? 03:23
avuserow did you see the subroutine version I posted above? it returns a boolean so you can do whatever at that point 03:24
Xliff aveuserow: O I C. Let me try that, thanks!
avuserow hmm, maybe that CATCH block ought to have a 'default' clause too, maybe return Nil or False or something 03:29
can't think of any other exceptions but that doesn't mean it can't happen :) 03:30
Xliff Heh! It will work fornow. 03:48
03:56 linkable6 left, evalable6 left 03:58 linkable6 joined, evalable6 joined 04:54 avar left, avar joined 05:42 derpydoo left 05:49 derpydoo joined 05:55 deoac left 06:00 reportable6 left 06:02 reportable6 joined 06:25 jpn joined 06:36 jpn left 06:43 jpn joined 07:02 perlmaros left, perlmaros joined 07:24 jpn left 08:06 jpn joined 08:10 jpn left 08:29 euandreh joined 09:05 DarthGandalf left 09:35 Sgeo left 09:52 euandreh left 09:54 jpn joined 09:58 jpn left 10:12 kaol left 10:13 kaol joined 10:37 DarthGandalf joined 11:37 evalable6 left, linkable6 left 11:38 linkable6 joined 11:39 evalable6 joined 11:49 GreaseMonkey left 11:50 greaser|q joined 12:00 reportable6 left 12:02 reportable6 joined 12:15 Xliff left 12:33 zara joined 12:56 kawaii left 12:57 kawaii joined
tbrowder__ hi, looking for some advice using a Build.rakumod file and a build script. 13:37
the build script is fairly lengthy but shouldn't be used by a user of the module. any recs on where to put it? i'm thinking in an ./xbin directory. 13:39
then zef shouldn't install it 13:40
13:57 linkable6 left 13:58 linkable6 joined 14:05 zara left
ugexe I’d probably put it under build/bin/ or something. But also it could all just go in the Build.pm file as well. Spawning that script isn’t going to be as simple as you might think because e.g. one of its dependencies may not be installed yet (just fetched and included for when zef invokes the build.pm module) 14:14
14:15 jpn joined 14:22 teatwo left 14:23 teatwo joined 14:25 jpn left 14:35 japhb left, japhb joined
Tirifto Is there a way to condition an argument in a function call with its definedness? 14:44
avuserow m: sub foo ($f?) { dd $f }; my $a; foo($_ with $a); $a = 3; foo($_ with $a) 14:47
camelia ===SORRY!=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> foo ($f?) { dd $f }; my $a; foo($_ with ⏏$a); $a = 3; foo($_ wit…
avuserow m: sub foo($f?) { dd $f }; my $a; foo($_ with $a); $a = 3; foo($_ with $a)
camelia ===SORRY!=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> foo($f?) { dd $f }; my $a; foo($_ with ⏏$a); $a = 3; foo($_ wit…
14:48 deoac joined
Tirifto avuserow, do extra brackets do the trick? :o 14:53
m: sub foo ($f?) { say $f }; my $a; foo(($_ with $a)); $a = 3; foo(($_ with $a));
camelia ()
3
Tirifto (Looks like it might, but I’m not 100% sure ‘()’ is Raku’s way of showing what I wanted to see. xP) 14:54
thowe So, I have this thing that I wrote in Catalyst a while ago that has stood the test of time as being indispensable at work. Then I rewrote it in Mojolicious. But I am trying to learn Raku in fits and starts. What's the best Mojolicious replacement in Raku this year? 15:00
lizmat cro.services
thowe I was afraid it is Cro ;) Guess I really need to learn something now... 15:02
Cro looks like it doesn't suffer fools gladly.
lizmat perhaps humming-bird instead ?
15:04 Vyrus left
thowe no no... I need to knuckle under on the one that's gonna teach me Raku. Mojo, similarly, made me much better at Perl (at one time anyway). 15:04
But I haven't heard of humming-bird, I should see what it is.
lizmat raku.land/zef:rawleyfowler/Humming-Bird 15:05
Tirifto avuserow, okay, putting the expression in brackets seems to work well! One caveat is that one has to flatten the expression if the argument is positional. Thanks for the pointer! :-)
thowe Cro also appears to have some community behind it... frameworks seem to come and go as hobby projects, and I like the stuff that manages to get some maturity. 15:06
my other question might be what's the Raku equiv of the Mojo Embedded Perl templating? 15:07
Also, Hi Lizmat! We met in Orlando. You were very helpful to me then; thank you. Been a while. 15:09
lizmat indeed, it's been a while
sadly I won't be visiting the US in the foreseeable future, and Florida most definitely not
thowe Yeah, sadly I understand. I'm in Oregon, where most of us scratch our heads and wonder "what the actual fuck...", but we have our own messes. 15:12
lizmat fwiw, Oregon is still on our list of "ok" :-) 15:13
Tirifto Rather silly question: is there sugar for lexifying dynamic variables? Basically, a way to do this: ‘my $a = $*a; my $code = { say $a }’, but without having to declare $a first, and instead referring to $*a more directly. 15:14
lizmat my $code = { say $*a } 15:16
?
Tirifto lizmat, that would ultimately search for $*a from wherever $code is called, which might not be where it was defined. Basically I have a block which gets a variable dynamically, but declares another block which should get that variable’s value from the enclosing block lexically. 15:18
lizmat gotcha 15:19
my $code = do given $*a -> $a { { say $a } } 15:20
feels like an obfuscation
guifa_ Tirifto: that seems a bit odd
for the $_ with $foo 15:21
lizmat what if $foo is intentionally not defined ?
Tirifto lizmat, yeah… ^ ^’ Well, declaring a new variable works for me. I was just wondering if there was perhaps any magical symbol to say ‘treat this variable as lexical here’. :-) 15:22
lizmat understood: not that I know of
guifa_ then it should pass Empty which would result in effectively no elements passed ,right?
lizmat yeah, but $_ would not contain $foo 15:23
m: .say for with Int
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
with used at line 1
lizmat meh
guifa_ re the dynamic variable, perhaps OUTER:: ?
Tirifto guifa_, re with, what about it seems odd? :o 15:24
guifa_ m: .say with Int 15:25
camelia ( no output )
guifa_ I wouldn't expect the extra parentheses to be necessary, that's all
Tirifto Ah, yeah. 15:26
m: my $*x; my $code = { say $*OUTER::x }; $code(); 15:33
camelia ===SORRY!=== Error while compiling <tmp>
Dynamic variables cannot have package-like names (with '::'), so
'$*OUTER::x' is not allowed.
at <tmp>:1
------> my $*x; my $code = { say $*OUTER::x⏏ }; $code();
guifa_ I just tried this on an older version and the issue was OUTER was still being resolved in the context of the caller
actually 15:34
nm
I had a typo
15:34 Vyrus joined
guifa_ m: sub a { my $*x = 10; -> { say OUTER::<$*x> } }; sub b { my $*x = 20; a }; my $*x = 30; b()() 15:36
camelia 10
guifa_ but it still requires the $*x to be somewhere in the scope of a. Not sure if you can do OUTER::CALLERS ha 15:37
OOH
you can
m: sub a { -> { say OUTER::CALLERS::<$*a> } }; sub b { my $*a = 20; a }; my $*a = 30; b()() 15:38
camelia (Any)
guifa_ um, well, you COULD haha
tio.run/##K0gtyjH7/7@4NEkhUaH60AJd...tDU0Pz/HwA
bisectable: sub a { -> { say OUTER::CALLERS::<$*a> } }; sub b { my $*a = 20; a }; my $*a = 30; b()() 15:39
bisectable6 guifa_, Will bisect the whole range automagically because no endpoints were provided, hang tight
guifa_, Output on all releases: gist.github.com/2817d8c33ae66a47b2...70b79d9f09
guifa_, Bisecting by output (old=2019.03.1 new=2019.07.1) because on both starting points the exit code is 0
guifa_, bisect log: gist.github.com/4ee23c9ad93b8b31ce...b02eec5466 15:40
guifa_, (2019-04-08) github.com/rakudo/rakudo/commit/55...6d4b96ed8a
guifa_, Bisecting by exit code (old=2016.07.1 new=2016.08.1). Old exit code: 1
guifa_, bisect log: gist.github.com/56391ebcd3f672eaaf...263bb85a9f
guifa_, (2016-08-19) github.com/rakudo/rakudo/commit/25...b0673f26e2
guifa_, Output on all releases and bisected commits: gist.github.com/3c97e56b8f34a6f11a...8852ee9d93
guifa_ hmm. summer 2019 doesn't quite coincide with newdisp so I wonder what changed. those commits bisectable found don't seem like they'd affect the packages 15:41
Tirifto guifa_, awesome! Thank you! :D 15:42
guifa_ meh I'm not sure if it actually works or which one is supposed to be correct so don't rely on it
TBH your solution of my $value-for-closure = $*dynamic-value reads very nicely to me (assuming descriptive names) 15:43
Tirifto Hmm… looks like it doesn’t work in my program after all. Not really sure why. x) 15:46
guifa_ is afk 15:47
Tirifto But yeah, I would agree that ‘$name = $*name’ probably reads the best. :-)
16:34 linkable6 left, evalable6 left 16:36 evalable6 joined 16:37 linkable6 joined
tbrowder__ ugexe: i was planning to use a sub of that module if that would help the installation, otherwise no other raku modules need be refernced. 16:49
*referenced 16:51
17:04 jdv left, jdv joined
ugexe referencing your own modules inside a build script is already iffy 17:32
because of the same dependency thing i mentioned before
if the sub you want to reference doesn't have any external dependencies i guess its ok 17:33
if it does have external dependencies then you have to really know what you're doing and not make any assumptions about what might be installed and what might be getting provided by a non-installation repo 17:34
tbrowder__ ok, thnx 17:35
17:56 jpn joined 18:00 reportable6 left 18:01 reportable6 joined 18:15 jpn left 18:17 zara joined 18:18 jpn joined 18:20 zara is now known as holyghost 18:26 synthmeat left
tbrowder__ ugexe: another question on the build process with a Build mod: if the modules itss it needs are in META6.json "build-depends" shouldn't that satisfy 18:26
18:26 synthmeat joined
tbrowder__ the script's needs? 18:27
ugexe yes, they will be provided to Build.pm. The question is when you spawn your script externally will you also set up e.g. -I correctly to provide those build-depends that aren't installed but *are* available to Build.pm? 18:28
Build.pm gets run something like `raku -I /path/to/dependency -I /path/to/your/distribution Build.rakumod`. /path/to/dependency hasn't been installed yet btu is available to Build.rakumod 18:30
if you then do something like `shell ...` to something that needs /path/to/dependency then you need to explicitly handle that
run $*EXECUTABLE, $*REPO.repo-chain.map({ "-I" ~ $_.path-spec }), build/my-raku-build-script.raku 18:33
something like that would handle that scenario although its not ideal either 18:34
18:36 Xliff joined 18:40 jpn left 18:48 squashable6 left 18:49 squashable6 joined 19:07 jgaz left 19:11 somebody1807 joined 19:13 Sgeo joined
somebody1807 Is anyone able to explain the difference between Lock and Lock::Async regarding return values within the protected code block, as shown in this example (gitlab.com/-/snippets/2557479)? 19:23
[Coke] docs.raku.org/type/Lock 19:24
Any await performed while a Lock is held will behave in a blocking manner; the standard non-blocking behavior of await relies on the code following the `await` resuming on a different Thread from the pool, which is incompatible with the requirement that a Lock be unlocked by the same thread that locked it. See Lock::Async for an alternative mechanism that does not have this shortcoming.
docs.raku.org/type/Lock/Async.html
Unlike Lock, which provides a traditional OS-backed mutual exclusion mechanism, Lock::Async works with the high-level concurrency features of Raku 19:25
(all text above cut and paste from the doc site
somebody1807 I understand the thead-blocking nature of Lock, and I understand Lock::Async uses raku constructs to avoid blocking threads, but I don't see by how that explains the return behaviour being different 19:26
[Coke] ... should have read the snippet.
somebody1807 I am not trying to be obtuse, but perhaps I am not as intelligent as you, because I still don't understand 19:27
If it helps to explain my ignorance, I am self taught programmer
Did you see in my example how the return behaviour inside the protected code-block is different? Are you saying, in your understanding, this is expected behaviour? 19:28
I have read those doc pages multiple times now, and I have read multiple times the excerpts you copy and pasted, and I cannot see the answer for the difference in the behaviour of the very simple example I linked earlier. 19:33
The protect method for Lock::Async isn't even returning a Promise for me to attempt to use 'result' or one of the other Promise methods on. It just seems to me to be an oversight in the functionality parity between the two, or some severe fundamental lack of understanding on my part 19:34
[Coke] somebody1807: *I* should have read the snippet before posting cut and pastes of the docs. 19:37
You're not being obtuse.
19:37 jpn joined
tonyo tbrowder__: i'm laid up with some health stuff and was thinking more on something you mentioned when i wrote that cro blog post - you still think that might be an interesting, maybe not a book, but something expanded out and a little longer? 19:37
[Coke] I'm guessing it either an issue with return in the context of an async lock, or as you say, missing parity between the methods. I don't know, sorry. :( 19:38
somebody1807 I appreciate the help anyway. Is this (github.com/Raku/doc/issues) the correct place to raise an issue regarding the matter? 19:39
CIAvash somebody1807: You're not creating any promises and you are not awaiting any promises 19:40
m: sub get2 () { my $lock = Lock::Async.new; my $x; await start $lock.protect({ $x = 'value'; }); $x }; say get2; 19:41
camelia value
19:41 jpn left
somebody1807 Yes, I gathered as much. I was just speaking in the context of trying to understand an earlier reply to me from Coke. Regarding your proposed solution, I have come to that conclusion on my own, but in your opinion, would it not be beneficial for it to function in the same way as Lock.protect return behaviour? 19:43
ugexe Lock::Async.protect doesn't have a return value
somebody1807 Shouldn't it though? Lock.protect does, as shown in my earlier example (gitlab.com/-/snippets/2557479).
ugexe er n/m, i thought it was declaring --> Nil but it doesnt 19:44
somebody1807 In your opinion, is there any technical reason for the difference in behaviour, or is it likely just an oversight? 19:45
[Coke] somebody1807: not sure if this is a doc issue or a rakudo issue. 19:46
would probably raise a rakudo issue (with a note that if it's intentional, let's update the docs to note it()
ugexe i would imagine the protect is non-blocking
so what is it supposed to return to you 19:47
somebody1807 To be fair, [Coke], the docs don't seem to make any mention of the return behavior of Lock shown in my example either. I read about it in a reddit post of lizmat
ugexe i guess it could return a promise
ugexe checks if it is actually non blocking
somebody1807 The non-blocking nature of Lock::Async.protect is referring to thread-blocking. It still halts at that part of the script if the lock can't be acquired. 19:48
It just waits using 'await' to avoid tying up a thread
(From my understanding)
CIAvash I don't think it makes sense to return a value, if I'm not mistaken, you are supposed to use them inside promises and I don't think you can return from inside promises. So you should be returning or collecting promises, I think 19:49
somebody1807 Sounds plausible 19:50
Seemingly is intentional then
Thanks for the help, all
19:54 somebody1807 left
ugexe I wonder if it should return an error or warning though 19:54
m: sub foo { start { return 42 } }; foo(); sleep 1;
camelia Unhandled exception in code scheduled on thread 4
Attempt to return outside of immediately-enclosing Routine (i.e. `return` execution is outside the dynamic scope of the Routine where `return` was used)
in block at <tmp> line 1
CIAvash with await, it panics even 20:01
m: sub foo { await start { return 'value'; }; }; say foo
camelia MoarVM panic: Internal error: Unwound entire stack and missed handler
avuserow Tirifto: glad you could make it work, and sorry that I had to run without saying anything more. B 20:12
20:13 squashable6 left 20:15 squashable6 joined 20:36 _________ left 20:37 _________ joined 21:07 derpydoo left 22:07 linkable6 left, evalable6 left 22:10 evalable6 joined, linkable6 joined 22:19 derpydoo joined 22:24 derpydoo left 23:06 holyghost left 23:52 squashable6 left 23:54 squashable6 joined