🦋 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.
raku-bridge <DataKinds> ruby -e 'loop { puts "hello"; break }' 😛 00:02
AlexDaniel still doesn't hurt to tell that it's valid Raku code too :P 00:34
raku-bridge <DataKinds> could I bother y'all to help me understand what's going on here? modules.raku.org/dist/Cro::HTTP::S...Pg.pm6#L66 01:02
<DataKinds> what's Capture? I read the docs and it doesn't feel any clearer 01:03
<DataKinds> ahh I found it docs.raku.org/type/Mu#method_Capture 01:05
<DataKinds> that's cute
rypervenche Is it possible for a map block to know if the variable it is working on is the last element of the list? 02:58
raku-bridge <DataKinds> rypervenche: does the LAST phaser work? 03:55
rypervenche Oh, I just figured out a much better way to do what I'm trying to do. 03:56
vrurg weekly: vrurg.github.io/arfb.html 03:59
notable6 vrurg, Noted! (weekly)
antoniogamiz o/ 09:12
is there a module to make end to end testing in web pages? 09:13
samebchase- What's the best way to pipe the output of program into a Raku script for further processing? Want to use it in a shell pipeline 09:43
antoniogamiz >?
antoniogamiz samebchase-, idk if this can help you: stackoverflow.com/a/4643808/8849071 09:45
gfldex lolibloggedalittle: gfldex.wordpress.com/2020/07/06/unrecursing/ 09:46
samebchase- I have been able to call external programs from Raku using `qqx`, but I want to do something like: "cat file | ./script.raku"
gfldex samebchase-: I'm actually working on the best way right now. May take another few weeks.
samebchase- gfldex: yes, I liked that blog post! 09:46
What variable should I use in Raku to refer to the piped in data?
gfldex samebchase-: docs.raku.org/language/variables#i...$*ARGFILES 09:47
antoniogamiz samebchase-, maybe docs.raku.org/type/IO::Pipe
samebchase- Thanks gfldex, and antoniogamiz for all the help! This is what I need. 09:48
antoniogamiz though ARGGILES is better I think
gfldex samebchase-: there is also docs.raku.org/type/IO::Handle#routine_lines 09:49
sjn o/ 09:50
samebchase- gfldex: Can I use $*IN directly? 09:51
sjn I seem to remember there once was a list of "low-hanging fruit" tasks somewhere. Does anyone here remember if this still exists somewhere, of if I remember wrong? :-)
gfldex samebchase-: yes
raku: .say for lines;
evalable6 ♥🦋 ꒛㎲₊⼦🂴⧿⌟ⓜ≹℻ …
gfldex, Full output: gist.github.com/6a29eb382ab6c7b7a5...65d425b704
samebchase- awesome, `lines` is doing the trick! 09:56
AlexDaniel sjn: depends on what you want to work on 09:57
sjn: if you want to work on rakudo, then maybe try this: github.com/rakudo/rakudo/issues?q=...resolve%22
Geth doc: 56b42ef062 | Antonio++ (committed using GitHub Web editor) | 2 files
fix: rename doc-generation.json to documentable.json, refs Raku/Documentable#62
10:05
codesections I suspect the answer to this may just be, "no, it's not possible" and that's fine. But I figure it's worth a shot: when building a CLI with Raku's built-in arg parser, is there a way to get it to accept options with a space (--length 42) instead of just with an equals (--length=42) ? 10:28
antoniogamiz hum, good question 10:29
El_Che codesections: I wrote a module for that 10:33
codesections: github.com/nxadm/SuperMAIN
no extra syntax or semantics 10:34
Manifest0 Getopt::Long will also allow to do that
[ptc] m: say sort(["\c[CHICKEN]", "\c[EGG]"])
camelia (🐔 🥚)
codesections cool, I'll check both of those out. Thanks
El_Che have fun
[ptc] bummer, doesn't appear on my terminal :-/ 10:35
codesections ptc I guess you'll never know
[ptc] codesections: www.babelstone.co.uk/Unicode/whatisit.html shows the result :-) 10:36
codesections :)
[ptc] python seems to agree with the ordering as well: twitter.com/bencbartlett/status/12...87393?s=20 10:37
El_Che codesections: both modules have a very different scopes, I think. Getopt::Long is feature-rich and with semantics and syntax close to the Perl module with the same name. SuperMAIN just enables a few features (named everywhere, spaces between param names and values and auto alias) with changes in your code 10:38
depending on what you need, one may be more appropiate than the other
codesections Yeah, I'm looking at the READMEs now. Looks like SuperMAIN is just what I'm looking for at the moment – I like the built in syntax 10:41
El_Che codesections: feel free to ping if something does not work. 10:42
codesections thanks :)
sjn AlexDaniel: thanks! I'm actually talking with another person who found that the idea of "easy to resolve" issues (low hanging fruit) was something worth adopting, so he wanted an example of it (thanks for the url! :-)) 10:50
AlexDaniel sjn: well, as you can see, most of these tickets are pretty old. Nobody is really marking the tickets actively 10:51
antoniogamiz what is the difference between xt/ and t/? 10:52
AlexDaniel one easy to resolve issue would be to mark tickets easy to resolve :)
antoniogamiz: usually xt/ is for tests that you shouldn't normally run. For example, if they take too long to finish, or something like that 10:53
antoniogamiz: they're still tests and are likely used by the maintainers of the project
for example, all tests in whateverable are xt tests: github.com/Raku/whateverable/tree/master/xt 10:54
because I don't think anybody wants the test suite to start up an IRC server, run hundreds of tests per each bot, download all the required builds, etc.
antoniogamiz oh it makes sense
thanks :)
has anyone made end to end testing for a webpage with raku? 10:55
AlexDaniel I wanna know too
antoniogamiz well, I gotta go, .tell me if someone appears :D 10:56
dakkar El_Che: thank you for writing that module! I just sent you a bug report ☺ 11:04
El_Che dakkar: great catch 11:10
it should be an easy fix, and I'll add the tests
El_Che I naively use split and join to eagerly 11:11
dakkar command line option parsing is harder than it looks! 11:14
(I once sent a bug report to Damian because one of his opt-parsing p5 modules got confused by whitespace!)
El_Che dakkar: it certainly is 11:26
dakkar: I try to document the cornercases in my tests
dakkar: but we'll find most of them only when enough people use it 11:27
codesections El_Che: I believe I found another corner case for you :) 11:34
(and thanks for the module!)
El_Che hehe :)
I know what to do :) 11:35
rypervenche What's the difference between my Str @array and something like my @array = Array[Str].new; ? 13:03
I may have the syntax wrong on that last one.
moritz the first one is a type constraint on the variable @array 13:05
the second one is an initiliazation
but the second allows you to to write: @array = (1, 2, 3); 13:06
without a type error
m: my Str @a; @a.push: 'a'; say 'OK'; @a.push(42)
camelia OK
Type check failed in assignment to @a; expected Str but got Int (42)
in block <unit> at <tmp> line 1
moritz m: my @a = Array[Str].new; @a.push: 'a'; say 'OK'; @a.push(42)
camelia OK
moritz m: my @a := Array[Str].new; @a.push: 'a'; say 'OK'; @a.push(42) 13:07
camelia OK
Type check failed in assignment to ; expected Str but got Int (42)
in block <unit> at <tmp> line 1
moritz m: my @a := Array[Str].new; @a.push: 'a'; @a := Arry.new(); say 'OK'; @a.push(42)
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared name:
Arry used at line 1. Did you mean 'array', 'Array'?
moritz m: my @a := Array[Str].new; @a.push: 'a'; @a := Array.new(); say 'OK'; @a.push(42)
camelia OK
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2020/07/06/2020-...beginning/ 14:58
ensamvarg m: $a = 2; 15:30
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$a' is not declared
at <tmp>:1
------> 3<BOL>7⏏5$a = 2;
ensamvarg m: my $a = 2; 15:31
camelia ( no output )
ensamvarg m: my $a = 2; print $a;
camelia 2
AlexDaniel m: my $a = 2; say $a²; 15:33
camelia 4
AlexDaniel m: my $a = 2; say $a³²
camelia 4294967296
ensamvarg m: my $a = 2; say ¼$a; 15:35
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3my $a = 2; say ¼7⏏5$a;
expecting any of:
infix
infix stopper
postfix
statement end
statement mod…
ensamvarg m: my $a = 2; say $a¼;
camelia 5===SORRY!5=== Error while compiling <tmp>
Bogus postfix
at <tmp>:1
------> 3my $a = 2; say $a7⏏5¼;
expecting any of:
infix
infix stopper
postfix
statement end
statement modifier…
AlexDaniel ensamvarg: hmm what do you want to happen? 15:37
ensamvarg: maybe try with a × (or *) sign? 15:38
m: my $a = 2; say $a × ¼;
camelia 0.5
AlexDaniel m: my $a = 2; say $a * ¼;
camelia 0.5
ensamvarg AlexDaniel: Thank you, AlexDaniel. 15:40
m: my $a = 2; say $a * ¼; 15:41
camelia 0.5
codesections I have a question about the semantics of Raku lists. Here's what is confusing me: 15:42
sub show-capture(|c) { say "list: {c.list}"; say "hash: {c.hash}"}
m: sub show-capture(|c) { say "list: {c.list}"; say "hash: {c.hash}"} 15:43
camelia ( no output )
codesections m: show-capture(:foo)
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
show-capture used at line 1
AlexDaniel m: sub show-capture(|c) { say "list: {c.list}"; say "hash: {c.hash}"}; show-capture(:foo)
camelia list:
hash: foo True
codesections thanks
AlexDaniel codesections: that's just how Captures work 15:44
codesections m: sub show-capture(|c) { say "list: {c.list}"; say "hash: {c.hash}"}; show-capture(do if True {:foo} )
camelia list: foo True
hash:
AlexDaniel m: sub show-capture(|c) { say "list: {c.list}"; say "hash: {c.hash}"}; show-capture(|do if True {:foo} ) 15:45
camelia list:
hash: foo True
codesections yeah. That's the bit that I'm not following. Why is the slip operator needed? 15:45
AlexDaniel m: sub show-capture(|c) { say "list: {c.list}"; say "hash: {c.hash}"}; my $pair = :foo; show-capture($pair)
camelia list: foo True
hash:
AlexDaniel m: sub show-capture(|c) { say "list: {c.list}"; say "hash: {c.hash}"}; my $pair = :foo; show-capture(|$pair)
camelia list:
hash: foo True
AlexDaniel codesections: it's like this ↑
codesections So, does `do` create a pair? 15:46
AlexDaniel if you pass an object as an argument it just takes it as a positional argument
codesections: no, `:foo` is a pair
codesections oh, right. `:foo` is already a pair, but is being destructured when passed in literally! 15:47
AlexDaniel yeah
codesections Ok, thanks. That was tripping me up for quite a while.
A little more magic than I was expecting, but I get it now
AlexDaniel codesections: actually it's hard to make it work any other way 15:48
codesections: otherwise you won't have any predictability as to whether an argument ends up being positional or named
for example
foo($bar) – what does it do?
right now it's simple, it's passing $bar as a positional arg, that's very clear 15:49
if it slipped pairs and hashes automatically the answer would've been “nobody knows, we have to figure out what $bar is first”
codesections Yeah. I mean, the language could just *not* destructure a literal `:foo` (and make everyone type `|:foo` every time). That would be the more explicit/less magic way, but would also be really annoying.
but yeah, I agree it couldn't slip pairs and hashes automatically – all it could do is *not* slip them when passed literally 15:50
AlexDaniel you have an interesting point
codesections: wanna have a heart attack? 15:51
codesections sure 15:52
AlexDaniel m: sub foo(:$bar) { say “bar is $bar” }; foo():42bar
camelia bar is 42
AlexDaniel m: sub foo(:$bar) { say “bar is $bar” }; foo:42bar
camelia bar is 42
AlexDaniel jnthn: ↑ I wonder if this would surprise you :)
lizmat m: foo:42bar; sub foo(:$bar) { say “bar is $bar” } 15:53
camelia bar is 42
AlexDaniel you can also do this if you want:
lizmat now, *that* surprises me
AlexDaniel m: sub foo(:$bar, :$baz) { say “bar is $bar, $baz” }; foo:42bar:43baz
camelia bar is 42, 43
lizmat AlexDaniel I'm pretty sure that's all intentional 15:54
AlexDaniel lizmat: almost everything in Raku is intentional
but I still have to pick up my jaw from the floor every time :P
lizmat nah, most of it just naturally falls out of its foundation :-) 15:55
codesections Yeah, AlexDaniel's examples don't surprise me – but probably because I just saw that syntax in the docs when I was trying to figure my issue out
lizmat AlexDaniel: it's the same mechanism that allows s:i:g/foo/bar/
AlexDaniel lizmat: I wouldn't call it same, I don't think it always worked 15:56
6c: sub foo(:$bar, :$baz) { say “bar is $bar, $baz” }; foo:42bar:43baz
committable6 AlexDaniel, Sorry kid, that's not my department.
AlexDaniel uhh poor bot
oh I think I know 15:58
actually, no, I don't… given that it was unable to gist the error it's probably a precomp bug again :( 16:00
bisectable6: sub foo(:$bar, :$baz) { say “bar is $bar, $baz” }; foo:42bar:43baz
bisectable6 AlexDaniel, Will bisect the whole range automagically because no endpoints were provided, hang tight
AlexDaniel, Sorry kid, that's not my department.
AlexDaniel yeaah…
bot spam incoming, sry 16:01
lucs Wow, that's a lot of bots. 16:02
lucs Is their usage publically documented? 16:02
AlexDaniel lucs: of course: github.com/Raku/whateverable/wiki
lucs Thanks
codesections m: multi p(:$foo, *% where $foo == 0) { 0 }; multi p(:$foo, :$bar) { 47 }; say p(:foo(42), (do if True { :bar })); 16:14
camelia Cannot resolve caller p(bar => True, :foo(42)); none of these signatures match:
(:$foo, *% where { ... })
(:$foo, :$bar)
in block <unit> at <tmp> line 1
codesections that was the error message that caused me such trouble
m: multi p(:$foo, :$bar) { 47 }; say p(:foo(42), (do if True { :bar })); 16:15
camelia Cannot resolve caller p(Pair:D, :foo(Int)); none of these signatures match:
(:$foo, :$bar)
in block <unit> at <tmp> line 1
AlexDaniel lizmat: ↑ the error message is wrong here?
codesections Not the second one -- that one's fine
AlexDaniel it doesn't show that `bar => True` is a positional
yeah, the one before
lizmat Pair:D, ? 16:16
that's a positional?
codesections But the first msg doesn't say `Pair`. It just has `bar => True` 16:17
AlexDaniel “Cannot resolve caller p(bar => True, :foo(42))”
lizmat hmmmm
maybe make an issue for it, so it won't fall through the cracks ?
AlexDaniel codesections: please :) 16:18
codesections Will do. Would this be for the doc repo or the Rakudo repo? 16:19
AlexDaniel codesections: rakudo 16:19
oddp Thank you for yet another edition of the weekly, liz! 16:20
lizmat oddp: yw 16:20
AlexDaniel bisectable: sub foo(:$bar, :$baz) { say “bar is $bar, $baz” }; foo:42bar:43baz 16:21
bisectable6 AlexDaniel, Will bisect the whole range automagically because no endpoints were provided, hang tight
bisectable6 AlexDaniel, Output on all releases: gist.github.com/ffc7fbd362d91488c4...be3cc88b86 16:21
AlexDaniel, Output on all releases and bisected commits: gist.github.com/6ef4a5291e3b37936e...b00ff6e5cd
AlexDaniel hmmm 16:21
AlexDaniel I think I ran out of space but actually didn't 16:22
it's weird
guifa2 lizmat: I was looking at making LanguageTag a value type because it seems a natural fit. But do you think it would be necessary for it to be inmutable for that to work realstically?
lizmat yes, it should be immutable, that's really the definition of a value type :-) 16:23
guifa2 *sigh* I kind of figured. Arg, I really liked the beauty of being able to say "$langtag.language = $foo" to edit the language, but maybe it wouldn't be terrible for it to be immutable especially if I have a robust clone method 16:24
gfldex AlexDaniel: I can help you with your imagined space problem. My next blogpost will explain. :-> 16:41
rypervenche guifa2: I saw your talk recently. Very cool to see the progress that you've made with Intl-CLDR :) 17:01
gfldex lolibloggedalittle: gfldex.wordpress.com/2020/07/06/sp...g-up-sort/
guifa2 rypervenche: thanks! it's been slow but steady progress, but I'm hopeful by this time next year it'll be really powerful 17:03
AlexDaniel gfldex: I ran out of inodes! 17:17
gfldex Sorry, cant help you with that first world probem. :-> 17:18
AlexDaniel okay back to 60% inode use… 17:19
lizmat afk for a few hours& 17:26
gfldex AlexDaniel: If you run out of inodes again, you might give btrfs a try. It got a limit of 2^64 inodes. 18:02
El_Che use ZFS? dynamic all the way 18:05
docs.oracle.com/cd/E19253-01/819-5...#6n7ht6qtm 18:06
guifa2 (jnthn | sena_kun)++ on a minor detail I just noticed with Comma. When you open a project for the first time, it defaults to the README.md (yet another reason for a fancy banner image ha, my module had teh pwetty™ in Comma) 18:29
Zero_Dogg Does a rakumod file automatically create its own private namespace? Ie. when I "use" something above the "unit class" line, what kind of namespace is that actually being declared in? 18:37
rypervenche When trying to use raku from the command line to grep out some things from stdin, I'm unable to add a :g to my regex. Curious what I might be doing wrong. 18:38
| raku -e 'say $*IN.lines ~~ /\" (<-["]>+ mp3) \"/'; This grabs one instance, but if I add :g before the / it gives; Unexpected closing bracket at -e:1 ------> say $*IN.lines ~~ :g/\" (<-["⏏]>+ mp3) \"/ 18:39
guifa2 Zero_Dogg: so by default, if the rakumod is declared as a package of some sort, then the namespace will be whatever that package is called. 18:41
But if the package exports things, they will end up in the current name space 18:42
(that's a fairly simplistic overview but hopefully it helps)
Zero_Dogg guifa2: okay, so even if that use statement is before the actual unit declaration, it's actually imported into that namespace then
guifa2: nod, just trying to wrap my head around it :) 18:43
guifa2 If you've got a specific example, I'm happy to take a look at it. 18:45
Zero_Dogg not really, I'm doing something rather basic. just "use App::Base;" followed by "unit class App::Backend::Foo is App::Base;" 18:48
guifa2 ah, well in that case you don't actually need to use the use statement 18:57
Zero_Dogg I don't?
It implicitly does it? 18:58
AlexDaniel gfldex: no no… no… 19:06
gfldex: already gave it a try and regretted so many times that I didn't use something as stable as ext4
gfldex you need a fairly recent kernel. Or at least used to. The fairly recent kernel back then are not not so recent anymore. 19:07
AlexDaniel last time I had issues was like half a year ago 19:08
I'm using debian unstable so the kernel is as recent as it can be
gfldex well …
guifa2 Zero_Dogg: actually, I may have spoken too soon, as I'm testing out the structure you're using. You may need to have a "use Foo::Bar" after all 19:09
gfldex AlexDaniel: Linux 5.4.0-4-amd64 GNU/Linux that is Debian/unstable. Mainline is at 5.7.7. 19:10
AlexDaniel gfldex: then how can I have 5.7.0
gfldex not without pain :) 19:11
Zero_Dogg guifa2: oh well, what I have now works, I just want to make sure I understand why correctly :)
guifa2 Zero_Dogg: I've always found the module loading / symbol export a bit confusing. One of these days I should probably investigate it much further and write up a guide (in the typical "learn by teaching" methodology haha) 19:12
AlexDaniel gfldex: are you sure? packages.debian.org/sid/linux-image-amd64
Zero_Dogg guifa2: haha, looking forward to it :P
gfldex AlexDaniel: oh, that one is quite new. I don't fancy booting my machine tho. I didn't have problems with btrfs because I'm cheating. I use bcache with an ssd to make sure that metadata is always on some permanent storage. 19:14
AlexDaniel hmm
gfldex: my last issue was that I was trying to figure out why it is so slow, so I tried to run the rebalance operation on the metadata
gfldex Also I use a mirror for metadata and data. That way scrubbing can actually help
AlexDaniel and it segfaulted…
gfldex ouch 19:15
AlexDaniel so, basically I asked the filesystem to do something and it segfaulted halfway through
I was prepared for the worst but folks on #btrfs said “ah you're probably alright, take a chance and reboot”
and yeah, it was fine
but omg…
gfldex You belly shouldn't feel like that. :) 19:16
ShimmerFairy rypervenche: You can't put adverbs there, you'd need to type m:g/my regex/ (that is, using the m// form) 19:18
gfldex ShimmerFairy: does the adverb go to ~~ or to say in this case?
AlexDaniel I started using it initially thinking that I'll be using cow snapshots
rypervenche ShimmerFairy: Ahh, that changes things. It gives me the output of False now. I suppose I need to reread the regexes page since I'm likely not doing what I really want to be doing.
AlexDaniel but I just don't, so I'm not sure what's the point of having worse performance… just for the shininess? :) 19:19
gfldex AlexDaniel: did you have plenty of free RAMs? btrfs likes those. It can slow down quite a bit machines with little RAM. 19:20
ShimmerFairy gfldex: I think it's seen as the RHS of the ~~, and then gets confused by the funny-looking code between the // (remember, you can do things like $filehandle ~~ :e to do the same thing as $filehandle.e)
AlexDaniel sorry Raku eats all my ram :P
gfldex No wonder Camelia can grow to a wingspan of 10 foot. 19:22
ShimmerFairy To put it another way, I think in that case it's not seen as an adverb in the first place, but as a Pair. 19:24
Zero_Dogg aside from using modules and thus getting precompilation, is there anything else I can do to speed up raku compilation overhead? I've split what I can into modules, what's left is basically a MAIN and USAGE, but it's still taking over 1 second to display --help or --version 19:34
El_Che Zero_Dogg: normally, just the first time 19:35
Zero_Dogg El_Che: This is subsequent runs, so two "app --help" after each other each take 1s+ 19:36
El_Che that looks problematic indeed. Is the filesystem read-only? 19:37
Zero_Dogg nope, and it has built a load of stuff in lib/.precomp 19:38
El_Che maybe someone with more knowlegde of precom will have an idea. nine? lizmat? 19:39
lizmat does the module have "no precompilation" in it?
Zero_Dogg stubbing out MAIN and removing the import of modules reduces it to 0.7s, which is fairly long for an essentially empty script
nope. I think module precomp is working as intended, actually 19:40
lizmat does --profile give any hints?
rypervenche How can I get this to match both a1.mp3 and b1.mp3?; echo 'blah:"a1.mp3", then:"b1.mp3", end' | raku -e 'say $*IN.lines ~~ m:i/ <?after \: \"> <-[":]>+ \. mp3 <?before \">/;' 19:43
Using m:i:g/ doesn't give what I would expect.
Zero_Dogg lizmat: can't say it's telling me much, no. It's not spending that time in *my* code, it's in the interpreter/vm
lizmat hmmm 19:44
El_Che Zero_Dogg: recent rakudo? 19:45
Zero_Dogg This might be expected, I'm just trying to figure out if I can somehow optimize it, since it's very noticeable with command-line apps. My perl apps use 0,06s for --help, while my raku app uses 1,25s 19:46
El_Che: 2020.02
AlexDaniel rypervenche: but this does work: raku -e 'say $*IN.slurp ~~ m:i:g/ <?after \: \"> <-[":]>+ \. mp3 <?before \">/; 19:46
El_Che 1,25 is noticeable and thus annoying, indeed
AlexDaniel Zero_Dogg: on which architecture is that? 19:47
Zero_Dogg AlexDaniel: x86-64
rypervenche AlexDaniel: Ahh I wasn't sure if .lines was the right tool for the job. That does the trick. Thanks! 19:48
AlexDaniel could it be that there's too much stuff in the precomp folders?
rypervenche: well, your input has only one line… 19:49
AlexDaniel rypervenche: so $*IN.lines[0] ~~ also works 19:49
rypervenche AlexDaniel: I'm doing a curl from a website, but I did the echo as a test. but still. I didn't care about going through each line. I needed it to run across the entirety of the data. slurp works perfectly :) 19:50
Zero_Dogg AlexDaniel: maybe? I tried stubbing out almost everything (including imports) but it's still slow. "raku -e 'say "Hello"'" is fast though, so I'm a bit confused. I'm using MAIN and USAGE subs
lizmat lines.head # AlexDaniel
AlexDaniel lizmat: #huffmancodinggonewrong ? :) 19:52
guifa2 haha
MasterDuke Zero_Dogg: try --profile-compile
AlexDaniel Zero_Dogg: if nothing else works, do try wiping all of your precomp folders and trying again
I had this issue once
although it's still unclear to me as to why it'd cause slowness 19:53
lizmat lines defaults to $*IN, .head is faster than [0] on a Seq, as it doesn't need to set up caching
AlexDaniel lizmat: well, that's kinda the point. .[0] is shorter, more readable and just more versatile (e.g. for non-0 indices you need some .skip combination) 19:54
lizmat then by all means, use [0]
I thought this was about getting the first line only 19:55
AlexDaniel yeah but it turns seqs into what can be best described as arrays
Zero_Dogg MasterDuke: That gave me a 12M html file that my browsers are really struggling with :P 19:56
Zero_Dogg Removing precomp's didn't change anything 19:56
MasterDuke that's not normal, so something probably isn't getting precomped 19:57
i'd suggest creating a sql profile and using moarperf to view it
AlexDaniel actually, why indexing with [] does some sort of action at a distance at all, instead of just working? 19:59
for 0..10 { say $seq[$_] } # this can just work without any issues
AlexDaniel for everything else it's fair to fail with “You're iterating your Seq backwards, dum dum!” 20:00
AlexDaniel that is, this would just work: 20:03
m: my $s = ‘foo bar baz’.words; say $s.head; say $s[2]
camelia foo
The iterator of this Seq is already in use/consumed by another Seq
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in block <unit> at <tmp> line 1
AlexDaniel also, notice how caching behavior just happens not to help you in this case
lizmat m: m: my $s = ‘foo bar baz’.words; say $s[2]; say $s.head; 20:05
camelia baz
foo
Zero_Dogg MasterDuke: anything in particualr to look for in there? 20:23
lizmat www.flickr.com/photos/wendyga/5008...ed-public/ # a clear message ? 20:39
[Coke] ... not really, no. :) 20:46
[Coke] ... I haven't collected comics in a while... is that the beyonder? 20:48
timotimo perl7 died so raku could change the world? 20:49
honestly, i'm not educated about the comics, so i don't know what that character is 20:50
is it a villain that's as big as a skyscraper?
AlexDaniel “claimed to be omnipotent being who kidnapped the heroes and villains of the Marvel Universe and had them do battle on another planet called Battleworld” “The character later appeared in a more antagonistic role in the 1985 sequel Secret Wars II, in which he took human form, and threatened to destroy the Marvel multiverse.” 20:54
timotimo thanks AD
AlexDaniel actually it's the first time I hear about it 20:55
my point is that it doesn't depict a good image of Raku 20:56
timotimo well, all three of these are kind-of villains, but iron man is framed quite heroic at least on a surface level - only refering to the recent movies, of course
[Coke] AlexDaniel: if that's even him. 20:57
AlexDaniel there's more than one Beyonder?
timotimo to infinity, and the beyonder! 20:59
[Coke] I was only guessing that was him in the image.
El_Che "The Beyonder is an infinite-dimensional,[26] or beyond-dimensional,[2] entity" <-- maybe he want to work on raku arrays
AlexDaniel xD
[Coke]: well, the description says so
[Coke] AlexDaniel: OH 21:00
AlexDaniel: I didn't even see there was a description. And I got it! woo!
AlexDaniel good for you, but I still don't get it :P 21:01
[Coke] oh, me either. :)
lucs How can I set environment variables that will be visible to a program that I 'run'? 21:10
AlexDaniel lucs: run accepts an :env or :ENV (?) named arg 21:11
lucs: by default it's set to %*ENV I think, so you can change %*ENV directly
at least that's how I always understood it 21:12
lucs: and “env” vs “ENV” depends on whether you use run or Proc::Async, I think
please double check :)
lucs Ah, I missed that :env (will check).
Although setting %*ENV<Foo> to whatever appears not to be picked up.
AlexDaniel that's weird 21:13
m: %*ENV<foo> = 42; run <perl6 -e>, ‘say %*ENV<foo>’
camelia 42
AlexDaniel lucs: how is that not being picked up?
lucs Hmm... Like I said, "appears" -- I'm fighting with procmail, so not sure exactly what's going on. 21:14
AlexDaniel lizmat: speaking of at a distance caching of seqs, some core operations cache your seqs without any warning 21:16
for example
ah
nevermind
lizmat ?
:-)
AlexDaniel misread my code :)
lizmat ah, *phew* 21:17
AlexDaniel lizmat: actually, I was just doing it wrong a bit. Here: 21:19
m: my $seq = <foo bar baz>.words; say sort $seq; say $seq.head; say $seq
camelia (bar baz foo)
foo
(foo bar baz)
AlexDaniel so if I sort a Seq with a `sort` sub, then it's cached without any warning 21:20
buuuut
m: my $seq = <foo bar baz>.words; say $seq.sort; say $seq.head; say $seq
camelia (bar baz foo)
The iterator of this Seq is already in use/consumed by another Seq
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in block <unit> at <tmp> line 1
AlexDaniel but .sort method doesn't cache!
lucs AlexDaniel: (FWIW, procmail is happy when I do 'procmail foo=42 ...')
timotimo ooh, fascinating
AlexDaniel just out of curiousity 21:21
c: releases my $seq = <foo bar baz>.words; say sort $seq; say $seq.head; say $seq
committable6 AlexDaniel, gist.github.com/0a5e532111f89e5c1c...888fae75a8
AlexDaniel bisect: old=2017.03 my $seq = <foo bar baz>.words; say sort $seq; say $seq.head; say $seq
bisectable6 AlexDaniel, Bisecting by exit code (old=2017.03 new=5f423a7). Old exit code: 1
bisectable6 AlexDaniel, bisect log: gist.github.com/0986828e7cc5c93bd6...26cc3fb14a 21:22
AlexDaniel, (2017-05-03) github.com/rakudo/rakudo/commit/40...988b03939f
AlexDaniel R#3781 21:24
linkable6 R#3781 [open]: github.com/rakudo/rakudo/issues/3781 [regression] Unexpected caching of Seqs
guifa2 Speaking of ENV…for those that work in *nix more often, is a generally acceptable practice to read values at the beginning and assume they're static, leaving it to the user to restart if they change them? 21:26
guifa2 is looking to add in some extra user locale information into UserLanguage, but it's going to get complex enough it'd probably be nicer to just cache it when it's first loaded 21:27
AlexDaniel guifa2: huh? ENV variables don't just propagate when they're changed. Or what are we talking about?
guifa2 AlexDaniel: that's why I ask the question haha, I'm not as familiar as to how that stuff goes but want to model behavior more or less based on that 21:28
AlexDaniel “By default, when a process is created, it inherits a duplicate environment of its parent process, except for explicit changes made by the parent when it creates the child” 21:28
so your %*ENV won't change no matter what, unless you change it yourself of course 21:29
guifa2 AlexDaniel++ so I think it's reasonable for me to have it cached then
(on the Mac and Windows, I could actually pick up different results later in runtime because I have to use a different detection method) 21:30
AlexDaniel timotimo: fascinating is an interesting word to describe that. There are clearly no visible boundaries for seq caching which makes it hard to know if your seqs are going to waste memory or not 21:31
on small scale that's unnoticable, but we're beyond fun one-liner snippets, right?
guifa2 AlexDaniel: caching is also the most performant, so since the *nix results would never change, makes my decision for UserLanguage easy :-) 21:32
AlexDaniel guifa2: I'm starting to confuse the two conversations x)
guifa2 steps away from the keyboard *simpsons-bush-gif* 21:33
AlexDaniel maybe I should start my own documentation
AlexDaniel “Seqs are things that sometimes turn into lists. How would you know when they do that? Well, I dunno, just test it, and maybe it'll last for a release or two.” 21:34
lizmat PositionalBindFailover # docs.raku.org/type/PositionalBindFailover 21:35
AlexDaniel lizmat: did you see the bug report?
AlexDaniel c: 400f4ec8835c^,400f4ec8835c my $seq := ‘foobar’.comb; say reverse $seq; say $seq.head; say $seq 21:39
committable6 AlexDaniel, gist.github.com/9f309c83dd80f60335...1f92bdd7ec 21:40
AlexDaniel lizmat: and you show me these docs as if I don't understand something 21:43
the docs barely even describe when sequences are cached 21:44
for example
$seq ~ ‘z’
does it cache or not?
can you guess? 21:45
oddp Same thing haunts us over at dlang with ranges and .save. :)
AlexDaniel well, I propose a very simple answer: no 21:46
lizmat interesting
AlexDaniel seqs are never cached. That's it. Easy
want to cache it? Turn it into a list explicitly
OK fine maybe passing a seq as a @ arg can turn it into an array or whatever, I'm fine OK with that 21:47
lizmat fwiw, I would love to drop the PositionalBindFailover dance
but the last time I tried it, too much broke
AlexDaniel do it, and then we release usable Raku 7 21:48
lizmat: why did it break? Did you make $seq[$i] work?
lizmat $seq[$i] implies caching 21:49
that would just not be allowed if Seq doesn't cache
AlexDaniel lizmat: no, it implies “give me an element on that index”
which you can absolutely do 21:50
for 0..10 { say $seq[$_] }
no problem
lizmat because it cached
AlexDaniel no
lizmat *caches
AlexDaniel you can remove caching and make it work
say $seq[3]; say $seq[10]; say $seq[15];
this can also work
lizmat but not for 10 ... 0
AlexDaniel correct
lizmat: in which case you'd get “The iterator of this Seq is already in use/consumed by another Seq” or something similar, that's already the current situation 21:51
codesections Coming from different languages, $seq[10] implies constant-ish lookup time to me (because it looks like array access), which wouldn't be the case with that proposed syntax, right? 21:52
AlexDaniel codesections: what if you have a linked list?
lizmat codesections: whether cached or not, it would need to produce values 0..9
AlexDaniel codesections: I like your point, I like the idea of thinking about the language in these terms 21:53
codesections: but in this particular case I don't think O(1) is implied
codesections Well, I don't know enough about Raku's implementation details to know how it's done around theses parts, but I wouldn't expect something that is accessed with seq[i] to be a linked list
AlexDaniel or O(1-ish) :) 21:54
codesections I'd expect something like seq.nth(i)
AlexDaniel codesections: yeah, you can currently do .skip($i).head or something similar
it's a lot more painful but it's kinda like that 21:55
but [] is a perfectly usable syntax IMO, no time constraints implied
codesections yeah, that's very similar to what I'm used to (Iterators in Rust)
AlexDaniel codesections: btw lists can be lazy too here, so it's not just Seqs at all
codesections Fair point
AlexDaniel but right now you can't use [] unless you're ready for your Seqs to turn into Lists (which is essentially what caching is) 21:56
lizmat AlexDaniel: lazy lists *are* iterators under the hood. Seq is just a wrapper for an iterator 21:57
AlexDaniel it's weird, basically it was decided that [] implies working random access
lizmat: laziness is an interesting term… 21:58
would be nice to define that too :P
and have .is-lazy work :P
lizmat Looking at how Seq is currently implemented, is that we could actually rather easily *not* cache a Seq if the AT-POS indices were always increasing 21:59
timotimo what if the at-pos indices are lazy? :δ
AlexDaniel just explode once you stumble upon one 22:00
lizmat right, and what if that contract is broken? There is no way to get older values
AlexDaniel: you'd be amazed how much fails then...
AlexDaniel lizmat: let's test it? Forget about the spectest, commit it into a branch and let's see what Blin says
lizmat will look at that tomorrow 22:01
AlexDaniel thanks!
lizmat I'm not sure Raku will actually build with such a change, so don't get your hopes up too much :-)
AlexDaniel I do expect a lot of spectest failures, but that's OK because we're redefining the spec with that change
lizmat: well, if it doesn't build then the core relies on caching? 22:02
lizmat that would be the implication...
lizmat I sorta half expect it will build, but that installing the core modules *will* fail 22:02
AlexDaniel what's `skip`? 22:59
sourceable6: <foo bar.words.skip(1) 23:00
sourceable6 AlexDaniel, No idea, boss. Can you give me a Code object? Output: gist.github.com/4020fa99bab008a4a5...5f654d8b13
AlexDaniel sourceable6: <foo bar>.words.skip(1)
sourceable6 AlexDaniel, github.com/rakudo/rakudo/blob/a745....pm6#L1997
AlexDaniel so .skip is a constructor for new Seqs?
or whatever you wanna call that
so every time I want to skip a value, I create a new Seq object? 23:01
that's honestly a yet another argument for proper implementation of [] on Seqs
codesections That's the same way `.skip` is implemented in Rust, doc.rust-lang.org/std/iter/trait.I...ethod.skip 23:02
AlexDaniel codesections: but how do they make it fast?
timotimo rust is probably a bunch better at not creating objects that aren't needed
"zero-overhead abstractions" and such
codesections yeah. But that's part of the point I'm gesturing at 23:03
timotimo is Seq an Any and doesn't have its own skip method?
m: say Seq ~~ Any
camelia True
timotimo m: say Seq.^lookup("skip") 23:03
camelia skip
timotimo m: say Seq.^lookup("skip").raku
camelia proto method skip ($: |) {*}
timotimo m: say Seq.^lookup("skip").candidates>>.raku
camelia (multi method skip ($: *%_) { #`(Method|66610304) ... } multi method skip ($: Whatever $, *%_) { #`(Method|66610448) ... } multi method skip ($: Callable:D $w, *%_) { #`(Method|66610592) ... } multi method skip ($: $n, *%_) { #`(Method|66610736) ... }…
timotimo m: say Seq.^lookup("skip").candidates>>.package>>.raku 23:04
camelia (Any Any Any Any)
AlexDaniel timotimo: sourceable is right
timotimo mhm
quite possibly Seq can just return self after skipping? it's not like seqs can sensibly be cloned?
AlexDaniel I haven't seen it give a wrong result ever, yet
timotimo i mean, some can, but not all
AlexDaniel timotimo: no no you can't return self
codesections whether the "new object" is created doesn't *need* to be tied to whether there's a performace penalty; it can be an abstraction showing that you've lost access to the previous elements without (literally, in memory) allocating a new object
AlexDaniel timotimo: because something else can have that same seq too 23:05
timotimo do we guarantee that a Seq is still sane after we called .skip on it?
AlexDaniel codesections: right. I guess other compilers can do something like that
m: my $s = <foo bar baz>.words; my $other = $s.skip(1); say $s 23:06
camelia The iterator of this Seq is already in use/consumed by another Seq
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in block <unit> at <tmp> line 1
AlexDaniel timotimo: ↑
timotimo m: my @a = 1, 1, *+* ... *; my $seq := @a.Seq; say $seq.head(1); my $oseq := $seq.skip(1); say $oseq.head(); say $seq.head();
camelia (1)
The iterator of this Seq is already in use/consumed by another Seq
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in block <unit> at <tmp> line 1
timotimo ah, so if you return self there, it wouldn't give you that error 23:07
AlexDaniel right, and you will even get a wrong result
timotimo i imagine the self.iterator does that?
i've wanted to skip an iterator forward without going through a whole dance
but i guess what i should have done is $seq .= skip(1)
AlexDaniel or, in Raku 7, just index with [] 23:08
x)
btw I don't know about iterators, there's no such thing for users in normal code 23:09
right?
timotimo true
you can build your own if you want to 23:10
and you can directly grab an object's iterator
and we code-gen some for loops to grab an object's iterator and .pull-one until it gives IterationEnd 23:11
AlexDaniel squints
timotimo hm? 23:13
AlexDaniel timotimo: why is that needed? 23:14
timotimo: why, for example, Seqs can't be our iterators? 23:15
conceptually, what's the difference between a Seq and an Iterator? 23:16
AlexDaniel codesections: see, I ask very dumb questions here, please don't mind :) 23:16
codesections :) 23:17
timotimo can you pull one value out of a Seq and then iterate over the rest with a for loop or map or something? 23:18
codesections It is interesting how similar this is to Rust's Iterator. They have exactly the same semantics, with a `next` in place of `.pull-one`
AlexDaniel codesections: so they have an Iterator, do they have Seqs? 23:19
AlexDaniel timotimo: interesting question 23:20
no, but why not?
basically, currently it's guaranteed you have just one consumer of a Seq 23:21
codesections Well Rust's `Iterator` is a Trait (which, despite the name, is more similar to Raku's role if I'm understanding roles-vs-traits correctly in Raku)
timotimo Seq is there to have a list-like API, so it can be used mostly interchangeably?
iterator doesn't have .map, but Seq does
AlexDaniel well, you can add .map to an iterator… maybe? 23:22
timotimo all of Any-iterable-methods? :)
AlexDaniel well, or other way around, make Seqs our iterators
it's an interesting design decision 23:24
I should amend my dumbed down description above, saying that Seqs always have just one consumer
… unless they're cached…
AlexDaniel but it's still guaranteeing that you won't accidentally read just the remaining values out of a seq (because something else read the first ones) 23:25
AlexDaniel codesections: Iterator is also a role 23:27
AlexDaniel m: my $s = <a b c>.words; say $s.pairs 23:34
camelia (0 => a 1 => b 2 => c)
AlexDaniel m: my $s = <a b c>.words; say pairs $s
camelia (0 => a 1 => b 2 => c)
AlexDaniel m: my $s = <a b c>.words; say $s.antipairs
camelia (a => 0 b => 1 c => 2)
AlexDaniel m: my $s = <a b c>.words; say antipairs $s 23:35
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
antipairs used at line 1
AlexDaniel :|
srsly?
R#3782 23:36
linkable6 R#3782 [open]: github.com/rakudo/rakudo/issues/3782 antipairs sub is not implemented