🦋 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.
AlexDaniel` greppable: :P5 05:38
greppable6 AlexDaniel`, 21 lines, 9 modules: gist.github.com/5d59400d110d66b008...63f673c7ae
gfldex How do I access WHY of a class attribute? 08:11
CIAvash Not sure, using `^attributes` on the class? 08:35
kawaii Good morning :) I'm having some issues in capturing errors/exceptions from a Proc (or maybe an IO::Pipe?!) object. I have `my $cmd = run @cmd, :in, :out, :err;` but my process is dying at the point of `$cmd.in.close;`, I've tried wrapping it in a `try` block and doing `if $! { say $cmd.exitcode }` and `$cmd.err.slurp.say` but _nothing_ I do seems to let me assign the value of the exception or even see the exit code. 09:21
full routine code at the moment for those interested www.irccloud.com/pastebin/tYxJPGun/
moritz kawaii: my experience with this is that it's easier to get it working reliably with Proc::Async 09:22
one problem is that UNIX pipes only buffer so much output before they block. That means you must drain the stdout and stderr pipes before they run full, without blocking them if there's nothing to read 09:25
not an easy task when using blocking IO
(this might not be your actual problem, but still a problem that needs solving)
perlpunks.de/paste/show/5f7d89ba.323f.a6 this is part of the code I use to run external programs; no piping to stdin in this example though 09:26
kawaii moritz: thanks, I'll take a look at Proc::Async instead and see if it's simple enough to make it worth refactoring this block :) 09:27
moritz you can print to its stdin ith `$proc.print(Str)`, and at the end $proc.close-stdin; 09:28
good luck :-) 09:29
kawaii moritz: well, time to see if it works :D www.irccloud.com/pastebin/KOczCSdO/ 09:37
kawaii www.irccloud.com/pastebin/BU1txtpN...%21%20%3A) 09:46
moritz: nice, got it working the same as before like so; now time to see if I can capture errors, thanks for your help! :)
kawaii so I'm pretty new to using supplies/taps, and now my stdout and stderr are both supplies, are supplies False if nothing is sent down them? What's the best way to "do X if stderr else do Y if !stderr"? 09:51
MasterDuke kawaii: i think the docs have a good example with react/whenever 10:07
kawaii MasterDuke: yep, reading those now :D
hmm `whenever $cmd.stdout(:bin) { $document = $_; }` I tried this but I assume the actual result of my command isn't contained within `$_` 10:32
timotimo the whenever block could be run multiple times 10:34
so it would overwrite the previous value each time
kawaii timotimo: I am not really sure if what I'm writing even makes sense www.irccloud.com/pastebin/NKkIfapE/ 10:36
timotimo you can output a little message whenever the stdout block runs 10:40
to see if it's run multiple times
or initialize $document to be a buf8.new() and do $document ~= $_ inside the block which will work whether or not the block runs multiple times 10:41
kawaii www.irccloud.com/pastebin/DYyA3QGS/ 10:52
timotimo: further down the rabbit hole :D www.irccloud.com/pastebin/TJJDOy0Q/ 10:53
note that my `say 'awoo';` was nowhere to be seen 🤔
timotimo well, yeah, i don't think the program outputted anything on stdout 10:54
given how it spits out an error on stderr
Geth ¦ problem-solving: AlexDaniel self-unassigned META6 specification only exists "de facto" github.com/Raku/problem-solving/issues/236 10:56
kawaii timotimo: so I feel like something is up with my `print` and `close-stdin` then, if the program is upset about what it's being fed
wow async is awful to work with :D 10:57
timotimo have you tried outputting exactly what $content is that you're feeding into it?
i gotta go now tho
kawaii yeah it's just raw markdown 10:58
kawaii ah, start must be called before close-stdin 11:02
probably my issue
kawaii is there a regex flag to return a copy when applying to an immutable string? 13:23
timotimo you use S instead of s
kawaii big S returns me a string of 'False' timotimo 13:24
`CATCH { template 'templates/error.crotmp', $_.message ~~ s:g/"\n"/"<br>"/ }`
timotimo m: say S/lmao/roflmao/ given "hellmao" 13:25
camelia helroflmao
timotimo you need to use it a bit differently from s///
kawaii ahh
kawaii timotimo: thanks, works :D 13:26
Geth Raku-Steering-Council/main: 97030f054d | (Elizabeth Mattijsen)++ | announcements/20200907.md
Add announcement of Vadim Belman joining
14:42
rypervenche Is there a point in setting the type of a constant variable? 15:00
moritz rypervenche: what do you mean by "constant variable"? 15:05
rypervenche A variable set with the "constant" prefix. 15:06
moritz we call that a constant, not a variable :-)
rypervenche Touché :X
moritz well, you can always use the type annotation to communicate with the reader of the program 15:07
lizmat m: constant Int A = "foo"
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing initializer on constant declaration
at <tmp>:1
------> 3constant Int7⏏5 A = "foo"
lizmat m: constant Int $a = "foo"
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing initializer on constant declaration
at <tmp>:1
------> 3constant Int7⏏5 $a = "foo"
moritz oh
you cannot even
lizmat apparently :-)
rypervenche In the scripts that I've looked at, I usually see people not setting a constant's type. I was just curious if that was a personal choice or if there was maybe a reason one doesn't need to.
lizmat rypervenche: if a type were allowed, it would cause a compile-time check 15:08
m: my Int $a := BEGIN "foo"
camelia Type check failed in binding; expected Int but got Str ("foo")
in block <unit> at <tmp> line 1
lizmat hmmm... that's runtime :-)
[Coke] "as soon as possible (maybe sooner later)" 15:09
rypervenche Ⓜ my Int constant $a := 1; say $;
gah, emoji plugin...
m: my Int constant $a := 1; say $; 15:10
camelia (Any)
rypervenche m: my Int constant $a := 1; say $a;
camelia 1
lizmat m: my Int constant $a = "foo"
camelia 5===SORRY!5=== Error while compiling <tmp>
Type check failed in constant declaration of $a; expected Int but got Str ("foo")
at <tmp>:1
------> 3my Int constant $a = "foo"7⏏5<EOL>
rypervenche Ok, so perhaps if I were doing some operation that *could* result in a type that I'm not expecting when setting my constant, I might want to use that. Otherwise, if I'm simply setting a constant to a value, I wouldn't need/want the type check then, yes? 15:12
moritz correct 15:17
m: constant A = 42; sub f(Str $x) { }; if False { f(A) } # checking if the compiler is smart enough to catch that 15:18
camelia 5===SORRY!5=== Error while compiling <tmp>
Calling f(Int) will never work with declared signature (Str $x)
at <tmp>:1
------> 3t A = 42; sub f(Str $x) { }; if False { 7⏏5f(A) } # checking if the compiler is sma
rypervenche Thanks. I'm always looking to have good standards for myself and not do anything unnecessary or redundant. 15:22
cpan-raku New module released to CPAN! Math::Libgsl::Histogram (0.0.1) by 03FRITH 17:36
gfldex kawaii: Did you consider to use Shell::Piping? I'm asking because your problems sound strangly familiar and I believe to have covered them all in that module. 18:55
rypervenche m: enum RPS < rock paper scissors >; say 'rock' ~~ RPS; # Should this work, or is my syntax wrong? 20:51
camelia False
moritz m: enum RPS < rock paper scissors >; say rock ~~ RPS 20:53
camelia True
moritz rypervenche: ^^ that's how it works
and if you want to look up an enum element by name, you can do it like this: 20:54
m: enum RPS < rock paper scissors >; say RPS::<rock>.^name
camelia RPS
rypervenche moritz: Hmmm, how might I test a string given to me to see if it matches an enum then? (My first time using enums :P ) 20:57
For example, if I do something like: my $var = get;
moon-child m: enum RPS<rock paper scissors>; my $good = "rock"; my $bad = "granite"; say RPS::{$good}; say RPS::{$bad}; 20:59
camelia rock
(Any)
rypervenche Ahhhh, thanks. 21:00
moon-child x<y> is generally shorthand for x{"y"}
codesections o/ 23:05
tellable6 2020-10-05T20:08:06Z #raku <tbrowder> codesections is it ok to use yr raku.sublime-text syntax code? if so, what should attribution be? would it be ok to use in PR to Zola?
codesections .tell tbrowder Oh, I should probably have noted in the file: that code is forked from github.com/silentTee/sublimetext3-perl6-syntax 23:14
tellable6 codesections, I'll pass your message to tbrowder
codesections .tell tbrowder that code is under an MIT license, so using it should be fine (and using the minor alterations I made is also fine) 23:15
tellable6 codesections, I'll pass your message to tbrowder
tbrowder codesections: got it, thnx! 23:16