🦋 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.
kawaii timotimo: works perfect, thank you <3 00:01
timotimo == will always convert its arguments to numeric 00:02
you will not want to do that to the message content, and also not to the regex :)
codesections I know I can use `&say.file` to introspect on the file that declared a sub. I could have sworn there was a way to do the same for a Type, but now I can't find it in the docs 01:41
did I just make that up?
Geth ¦ problem-solving: vrurg assigned to jnthn Issue Allow overriding of compiler-handled operators github.com/Raku/problem-solving/issues/214 01:42
vrurg codesections: You certainly made that up. When a new type is created by the metamodel the information about the source file/line is not even passed into the constructor method. 01:49
codesections vrung: Thanks. And the same goes for a method on a type? I can use `.file` on a standalone sub but not on a method? 01:51
er, vrurg:,sorry
vrurg codesections: a method is a Routine, as a sub is too. Both carry this information on them. 01:53
m: class Foo { method foo { } }; say Foo.^lookup("foo").file 01:54
camelia <tmp>
vrurg codesections: ^^^
cpan-raku New module released to CPAN! App::AizuOnlineJudge (0.0.5) by 03TITSUKI
codesections Thanks! 01:55
vrurg codesections: welcome! :)
Geth doc: softmoth++ created pull request #3534:
Call it "Pod", not "POD" or "Pod6"
03:33
cpan-raku New module released to CPAN! Template::Mustache (1.2.2) by 03SOFTMOTH 04:00
timotimo 64.media.tumblr.com/1d27d0909e2b21...aa2189.jpg - cat *.raku 12:01
lizmat prettygood :-) 12:38
Xliff Hi. Are enums fixed after definition, or can the MOP be used to extend them? 14:07
timotimo i could imagine there exists caches somewhere, but otherwise i imagine you could. let's try, shall we
Xliff Here's what I'm trying to do: 14:08
gist.github.com/Xliff/600d1c8ba52c...f43fb24ccc
timotimo m: enum Blorp <One Two>; say Blorp.keys.raku; Blorp.^add_enum_value("hi", 5); say try Blorp("hi"); say try Blorp(5); 14:09
camelia ()
Too many positionals passed; expected 3 arguments but got 4
in block <unit> at <tmp> line 1
timotimo ah 14:10
m: enum Blorp <One Two>; say Blorp.keys.raku; Blorp.^add_enum_value(Pair.new("hi", 5)); say try Blorp("hi"); say try Blorp(5);
camelia ()
(Blorp)
hi => 5
timotimo m: enum Blorp <One Two>; say Blorp.keys.raku; Blorp.^add_enum_value(Pair.new("hi", 5)); say try Blorp("hi"); say try Blorp(5); say try Blorp.keys
Xliff Oooh!
camelia ()
(Blorp)
hi => 5
()
timotimo keys doesn't do what i think, it needs to be Blorp::.keys
and that's a package, which will most probably want a separate operation to add the new thing to it
Xliff enum Blorp <One Two>; say Blorp.keys.raku; Blorp.^add_enum_value(Pair.new("hi", 5)); say try Blorp("hi"); say try Blorp(5); say try Blorp::.keys
evalable6 ()
(Blorp)
hi => 5
(One Two)
timotimo i imagine that one will refuse changes 14:11
perhaps even when you grab the underlying storage and nqp:: bind a key or something
Xliff enum Blorp <One Two>; say Blorp.keys.raku; Blorp.^add_enum_value(Pair.new("hi", 5)); say try Blorp("hi"); say try Blorp(5); say try Blorp::.keys; say One; say hi
m: enum Blorp <One Two>; say Blorp.keys.raku; Blorp.^add_enum_value(Pair.new("hi", 5)); say try Blorp("hi"); say try Blorp(5); say try Blorp::.keys; say One; say hi
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
hi used at line 1
Xliff So maybe a better thing to do would be to add constants that map to the enum. 14:12
The values I'm trying to add aren't new, so....
Best way to add a constant to a compunit?
timotimo "add" a constant "to a compunit"? sounds vaguely like you want a sub EXPORT 14:20
Xliff Hmmm... Yeah. 14:24
Add an example export on that gist for me? I haven't had much luck adding things to the export table. Its easy when I can pass the whole Hash from EXPORT when I'm creating it wholesale. 14:26
I mean... would I append values to ::EXPORT::DEFAULT in that case?
timotimo sorry, i haven't had to work with EXPORT in a long time, the only time i really used it was my ADT module but there i only export what i explicitly create 14:40
Xliff timotimo: OK. Thanks! 15:10
tbrowder \o hi folks 15:40
question on $*CWD, docs are a little fuzzy to me 15:41
use case:
in an interactive raku prog, pass my cwd to an installed modules subroutine. what is the best way to do that? 15:42
like this: "somesub $*CWD" 15:43
and in the sub: sub somesub($cwd)"? 15:44
or?
tbrowder or is $*CWD defined magically inside the installed module? 15:50
defined/accessible... 15:51
timotimo $*CWD is a regular dynamic variable, it'll immediately be available if you've defined your own
timotimo dynamic variables are scoped "by the call stack" so to say 15:51
tbrowder so should i do something like: my $dir = $*CWD; my $res = somesub $dir 15:54
timotimo no
my $*CWD = "/foo/bar"; somesub()
tbrowder but the docs warn about that syntax 15:55
timotimo where?
tbrowder input/output 15:56
timotimo docs.raku.org/language/io here? 15:56
tbrowder no, the "definitive input/output guide" 15:57
timotimo i didn't know this existed lol
tbrowder sorry, "input/output, the definitive guide" by Zoffix 15:58
timotimo in that case, use temp $*CWD
tbrowder so, not knowing my curr dir, it seems like i shoud use "my $cwd = '.'.IO" and pass it to the sub and forget about $*CWD 16:02
timotimo um
your current dir is literally in $*CWD 16:03
if you just want to pass your current dir on to the sub, just do nothing and call the sub, if it will use $*CWD
tbrowder ok, so the magic of dyn vars carries throughout--awesome! 16:04
but, just to be clear, i could do the "$dir = $*CWD; somesub $dir" to satisfy my stubborness? 16:06
timotimo yes, if somesub takes an argument for the path 16:08
tbrowder i'm going to be using File::Find inside that sub and want to be clear what's happening from the caller's perspective. 16:08
tbrowder timotimo: thanks! 16:09
Geth doc: usev6++ created pull request #3535:
Tweak names of two variables
16:15
melezhik now Red has Postgresql tests with Rakudist - rakudist.raku.org/sparky/report/debian/542 16:40
timotimo pretty nice 16:47
melezhik yeah, thanks 17:03
basically Fernando asked me to restore test environment for Red/Pg and I did 17:04
I have a free tier amazon subscription, so I just spin up a small ec2 instance with Postgresql on it, enough for things like testing Red module 17:05
here is Red setup - github.com/melezhik/RakuDist/blob/...parrowfile 17:06
timotimo ah, the postgres instance is permanent 17:09
SmokeMachine melezhik: \o/ 17:30
Geth doc: 9db30691a6 | (Christian Bartolomäus)++ (committed using GitHub Web editor) | doc/Language/contexts.pod6
Tweak names of two variables (#3535)

The original names had the potential to cause confusion.
17:43
linkable6 Link: docs.raku.org/language/contexts
DOC#3535 [closed]: github.com/Raku/doc/pull/3535 Tweak names of two variables
melezhik SmokeMachine \o/ yeah, we did it! 18:30
timotimo yeah, in original version it was created on the same docker container, but I had some problems to run docker with systemd on new virtual server where RakuDist moved 18:32
melezhik so, I just decided to spin up a postgres separately on my ec2 instance, will work till my free tier is expired )) 18:34
but technically I might return ode day to the scheme all in one ( docker on the same docker ) approach, should not be a big deal 18:35
ode -> one
codesections if I call `take` inside a hyper block, will the values I get in my `gather` be in the same order as my input? Or is `take`ing a side effect (like `say`) and they could be in any order?
moritz take is a side effect 19:12
codesections thanks 19:15
timotimo it's possible that take-ing from multiple threads can be destructive to your data 19:17
hyper already collects your data for you, however, so perhaps you can Just??? Slip multiple results or Empty results you don't want 19:19
guifa2 Has anyone had much success lately with Net::FTP? Or is there a better ftp client these days?
Xliff When is sub EXPORT run? 19:28
timotimo when something use-es your module 19:29
or requires or whatever
Xliff It doesn't seem to be running when I perl6 -e 'use Module'
"sub EXPORT {}" is sufficient, yes?
Voldenet m: use nqp; $*CWD = "/"; say nqp::cwd()
camelia /home/camelia
Voldenet as expected
codesections These causes an infinite loop when I wouldn't expect it to: given 10 { when $_ < 0 { 'done' }; &?BLOCK($_ - 1) for ^2 }
is the postfix `for` implicitly creating a block? 19:30
Xliff codesections: create a closure for the &?BLOCK call? 19:31
Or user OUTER::
lizmat Xliff: the EXPORT should be in the compunit, but *not* in the package scope
unit class Foo; sub EXPORT { } # wrong
class Foo { } sub EXPORT { } # right 19:32
codesections Xliff: I don't understand. The `given` block should be a closure for the &?BLOCK call, right? I mean, this works 19:35
m: given 10 { .say; when $_ < 0 { 'done' }; &?BLOCK($_ - 1)}
camelia 10
9
8
7
6
5
4
3
2
1
0
-1
guifa2 codesections: what would stop the loop? 19:42
codesections I'm also not quite following the advice to use `OUTER::` and don't see anything about `OUTER::` in the docs
guifa2: the when statement?
Xliff given 10 { when $_ < 0 { 'done' }; sub b($n) { &?OUTER::BLOCK($n) } b($_ - 1) for ^2 }
m" given 10 { when $_ < 0 { 'done' }; sub b($n) { &?OUTER::BLOCK($n) } b($_ - 1) for ^2 } 19:43
m: given 10 { when $_ < 0 { 'done' }; sub b($n) { &?OUTER::BLOCK($n) } b($_ - 1) for ^2 }
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3one' }; sub b($n) { &?OUTER::BLOCK($n) }7⏏5 b($_ - 1) for ^2 }
expecting any of:
infix
infi…
Xliff m: given 10 { when $_ < 0 { 'done' }; sub b($n) { &?OUTER::BLOCK($n) }; b($_ - 1) for ^2 }
guifa2 the &?BLOCK isn't being conditionally called
perhaps you wanted to throw it in a "default"?
camelia MoarVM panic: Memory allocation failed; could not allocate 131072 bytes
Xliff codesections: Was acting on the thought that the for was creating an implicit block, as you suggested. 19:44
Looks the same, though.
codesections It's being conditionally *not* called, right? If the `when` statement is true, control flow exits the `given` block, right?
Xliff lizmat++ # Thanks!
lizmat yeah, been there done that :-) 19:45
codesections xliff: oh, I see what you meant by OUTER
guifa2 no
"when" juts means "run the code in this block if true"
Xliff Is the best way to access a symbol in EXPORT::DEFAULT -- "EXPORT::DEFAULT::{$sym}" ?
guifa2 m: given 10 { my &b = &?BLOCK; when * < 0 { say "done" }; default { b($_ - 1) } } 19:48
camelia done
Xliff Oh. HAH! guifa++ 19:49
guifa2 of course, you can't use &?BLOCK in the default block (I mean, you CAN, but it's referring to a different one)
melezhik I've added 2020.07 version to RakuDist, in case someone want to test against the latest version 19:50
codesections m: given 10 { my &b = &?BLOCK; when * < 0 { say "done" }; b($_ - 1 }
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3CK; when * < 0 { say "done" }; b($_ - 1 7⏏5}
codesections m: given 10 { my &b = &?BLOCK; when * < 0 { say "done" }; b($_ - 1) }
camelia done
codesections `default` wasn't doing any of the work there
codesections From the docs: > But there is a difference in how following code in the same, outer block is handled: When the when block is executed, control is passed to the enclosing block and following statements are ignored; but when the if block is executed, following statements are executed. 19:51
guifa2 hmmm 19:52
Xliff 10 -> default -> 9 -> default -> 8 -> default ... 0 -> done 19:53
Without the default it still works, it's just.... if there are more when blocks after the call to b() then you may run into a sleeping dragon. 19:54
^^ codesections
codesections assigning `my &b = &?BLOCK` works, though, thanks! It's a bit inelegant (since the idea of &?BLOCK is to have implicit recursion *without* naming to block) and reminds me a bit of the `that = this` from JavaScript…
Xliff codesections: You DO have implicit recursion, just be careful of implicit blocks! :) 19:55
guifa2 eventually (though NYI) I believe we're supposed to be able to label all blocks rather than just loops 20:00
which should help with that
codesections Wait… I think (though I haven't figured out the details) that the problem *isn't* an implicit block – it's that postfix `for` is setting the topic! 20:02
guifa2 oh right, because you're doing < 0 so it's calling it on the block for values of 0 and 1 each time 20:04
one of which terminates the other goes on forever
codesections (both of which go on forever, but yeah)
guifa2 err calling it with -1 and 0, because 0 - 1 and 1-1. 20:06
guifa2 needs his caffeine
codesections wait, wat 20:07
m: given 4 { .say; my $topic = $_; my &b = &?BLOCK; when $_ < 0 { 'done'}; b($topic - 1) for ^2}; say 'done';
camelia 4
3
2
1
0
-1
-1
0
-1
-1
1
0
-1
-1
0
-1
-1
2
1
0
-1
-1
0
-1
-1
1
0
-1
-1
0
-1
-1
3
2
1
0
-1
-1
0
-1
-1
1
0
-1
-1
0
-1
-1
2
1
0
-1
-1
0
-1
-1…
codesections m: given 3 { .say; my $topic = $_; my &b = &?BLOCK; when $_ < 0 { 'done'}; b($topic - 1) for ^2}; say 'done';
camelia 3
2
1
0
-1
-1
0
-1
-1
1
0
-1
-1
0
-1
-1
2
1
0
-1
-1
0
-1
-1
1
0
-1
-1
0
-1
-1
done
guifa2 for ^2 is the same as for (0, 1) 20:08
codesections (Oops, yeah, I forgot it there was a `- 1` even the first time. So I was thinking it was 0 and 1, not -1 and 0. My bad; you're right that only one is ∞) 20:09
thundergnat guifa2: FWIW Net::FTP works ok for the most part, it just won't pass it's tests because the test FTP server is offline. It works for me if I --force install it. 20:12
guifa2 thundergnat: yeah I noticed that, but after installing I can't get it to connect to the IANA ftp server
thundergnat guifa2: Sorry, I stand corrected. It worked the last time I tried it but seems to have bit-rotted since then. No longer works for me either. 20:19
guifa2 thundergnat: at least it's not just me then
Xliff which is executed first? BEGIN or EXPORT? 20:36
guifa2 Begin should be
timotimo yeah, EXPORT can only be run after it got parsed, after all 20:37
guifa2 export is called at runtime, but begin is called at compile time
timotimo i'd say export is called at parse-time of the user of your module 20:38
Xliff Hmmm... might have a chicken and egg problem. 20:39
I need the export table at BEGIN time.
timotimo at whose begin time?
Xliff HAH! 20:40
I have to have BEGIN defined after 'unit'
Then sub EXPORT {} will pick it up, properly.
\o/
One sec and then I can commit this.
github.com/Xliff/p6-OpenVR/blob/ma.../Enums.pm6 20:51
guifa2 Xliff: hmmm 20:52
So not fully grocking the BEGIN code, I'd say I'd move the sub export all the way down, and not attach the "is export" to everything, and manually make your map. But that's very off the cuff and I'd need to look at it a bit more in depth 20:56
Xliff guifa: Um. No. Tried that. 21:02
sub EXPORT must be out of module def, so it has to be ABOVE "unit package"
BEGIN needs to be after the unit def otherwise EXPORT::DEFAULT is unpopulated. 21:04
The rest of the code is just there to add alternative constants to the enum due to weirdness in the C code I'm writing a binding for.
codesections I'm still pretty confused by how `&?BLOCK` works (esp. with `OUTER` and/or `for` loops). So I wrote up a StackOverflow question stackoverflow.com/questions/630939...e-variable 21:57
guifa2 codesections: it looks like it may be a bug. Even using OUTER::OUTER::BLOCK I get the same 22:01
codesections Yeah. And I didn 22:05
codesections *didn't mention it in the question, but I tried other options (DYNAMIC, CALLER, etc) and always got the inner block's ID 22:06
guifa2 Although that said, I don't know if it has that information available. Things are designed to be single pass
And an inner block while be constructed before the outer 22:07
codesections That's why I didn't open an issue yet – I don't know if it's a bug, or just an inherent limitation
Xliff OK. My latest foray into sub EXPORT has met with unexpected failure after passing the first test case. 22:49
Xliff And now... after reordering... it works again. Weird. 22:52
Xliff Does raku do uint64 literals? 23:16
codesections m: my uint64 $a = 14; 23:25
camelia ( no output )
codesections Xliff: Like that? ^^^^ or do you mean something else? 23:26
Xliff codesections: Not quite. I was wondering if there was a literal, like there is in C: 1L would create a 64-bit integer with the value of 1. 23:30
Xliff I really didn't think so. Raku doesn't need 'em. 23:31
codesections Oh, I'm with you now. I don't think Raku does (it's certainly not listed in the docs: according to them, we have Number, Int, Rat, Num, and Complex literals (for numeric types) but nothing about the size) 23:33
docs.raku.org/language/syntax#Int_literals