🦋 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.
jnthn Ah, the macro bit I didn't play with, alas 00:01
stu002 I posted a mailing list question on custom roles, built-in types and monkey typing: www.mail-archive.com/perl6-users@p...09037.html I'd appreciate any feedback on how to approach this issue in idiomatic Raku. 00:08
tbrowder jnthn, as long as i can get one host working that can be macroized pretty easily. 00:10
guifa codesections: hmm, good question. The problem is since expensive-calculation might have sideeffects that effect the next line of code. Maybe there’s a way to toss everything in a sub that does it delayed 00:11
like sub delayed(Callable foo) { sub slow() { foo() }; return lazy gather { take slow } or something ? 00:12
might be missing some brackets and haven’t tested
rypervenche: the methods should always be acting on a single instance 00:13
jnthn: I’m revisiting my DateTime format code because Timezones. Is there any particular way i can structure things that will leave me better equipped for adopting RAST ? 00:16
00:18 zacts left
rypervenche guifa: Wouldn't I need to use >>.made instead of .made on some of my $/ though in my actions? This is what I'm working on right now: gist.github.com/rypervenche/773835...61df79e21d 00:23
guifa m: my $a = 5; say $a>>.Str 00:24
camelia (5)
guifa The joy of scalars is that they listify into single items lists :-)
so when in doubt, just treat everything as a list
rypervenche Huh...do you do that in your code as well? 00:25
timotimo guifa: there's a module for your "delayed", i think it's got "lazy" and "catchup"?
modules.raku.org/dist/Object::Dela...:ELIZABETH 00:26
00:26 zacts joined
timotimo slack and catchup actually 00:26
guifa rypervenche: I don’t think I’ve had many where it’s not really clear but I keep my tokens extremely tiny. 00:28
The general rule (actually, the only rule) is if there’s a quantifier of any type, or a named capture appears twice anywhere, it automatically becomes a list match and you can’t work on it as a scalar
rypervenche Hmmm, ok. I'll look at some code that others have written to try to get some ideas. Thanks. 00:32
Ahhhh, I must have been doing it wrong previously. I can add .WHAT to the level that I want and it will tell me if it's an Array. Perfect. 00:37
00:39 aborazmeh left
guifa cleaner than using WHAT would be 00:39
$foo ~~ Array
but .WHAT works too
rypervenche Ahh, I'm just going through each level manually. 00:40
cpan-raku New module released to CPAN! App::Mi6 (1.0.2) by 03SKAJI 00:46
rypervenche It looks like I was overthinking everything. The solution was just to loop through the array. Is there a cleaner way that I might do what I did in method TOP? gist.github.com/rypervenche/773835...61df79e21d 00:57
guifa what’s the best way to ignore an argument in a ^ twigiled subroutine? sink?
rypervenche: ah okay, I see probably the issue 00:58
Don’t try to do too much on any given level
method query-string { my %queries; for $<query> { … }; make %queries; } 01:00
and then
method TOP { make $query-string.made }
rypervenche Ooooh
guifa Trust me when I say your life will be much easier if you never try to jump a level :-)
and the ‘make $<foo>.made’ is very common 01:01
rypervenche So I'll essentially need to add actions for each/most level/s then.
I thought I'd be saving code/space by skipping them, but I see how much easier that is to read.
guifa It’s much cleaner. When you break them down small enough, most of them are one lines, are easy to immediately grok
If you’re looking for places to save… “make ~$/“ is definitely one of them 01:02
you can replace $<type>.made with $<type>,Str or ~$<type> and then avoid having a type method (ditto for value) 01:03
rypervenche Ah, do the stringification in one place (at least in this case). Very nice. Thanks so much for the help. 01:04
Much cleaner now. 01:07
guifa of course, I love how I said “you can avoid the make $/.Str” stuff and then I looked over an old actions class 01:09
github.com/alabamenhu/Intl-CLDR/bl...plurals.p6
lol
sure enough, there’s one for <value>
01:14 zacts left 01:15 sena_kun joined 01:16 Altai-man left 01:54 melezhik joined
melezhik .tell demostanis: "Also security doesn't seem to be that important as it's supposed to be running locally." I am not sure what you mean locally, sparrowdo could run over ssh as well 01:55
tellable6 melezhik, I'll pass your message to demostanis
01:58 melezhik left 02:06 Manifest0 left, Manifest0 joined 02:35 stu002 left
codesections fun 02:49
rw 02:53
03:03 defaultxr joined 03:10 cpan-raku left 03:14 Altai-man joined 03:16 sena_kun left 03:17 cpan-raku joined, cpan-raku left, cpan-raku joined 04:03 gordonfish- is now known as gordonfish
guifa2 whoa 04:26
class A { method morph($self is rw:) { $self = A.new } }; my $a = A.new; say $a.WHICH; $a.morph; say $a.WHICH; 04:27
evalable6 A|94104662207584
A|94104662207904
guifa2 apparently you *can* replace an object during a method call 04:28
I don't know who had the insane idea to allow that but… bless you 04:31
Whoa, and if you make morph a multi, you can even determine if the $self is writable or not 04:49
m: class A { multi method a ($self is rw:) { say "Read/write" }; multi method a ($self:) { say "Read-only" } }; A.new.a; my $a = A.new; $a.a 04:50
camelia Read-only
Read/write
05:03 evalable6 left, linkable6 left 05:06 linkable6 joined, evalable6 joined 05:15 sena_kun joined 05:17 Altai-man left 05:40 rindolf joined
xinming Yesterday, I'm thinking, wether raku would allow to replace a function definition directly in another module 05:59
Let's say, module A has function base-function, and it exports an api which is do-sth, where do-sth will call the base-function. in our code, Is it possible that we replace the base-function to a new one, when we call do-sth, the do-sth function will pick up the new function? 06:00
It's a bit like temp $var = "sdfsdfsf"
After we go out of the scope, the base-function is restored to old one. 06:01
06:01 sno left
guifa2 xinming: eh....almost 06:07
If you can reference the sub/method, you can wrap and unwrap it 06:08
That effect is global, though and not lexically scoped. The trick I've used is to use a dynamic variable as a flag to decide whether I want to call the original or do something else. 06:09
06:11 bocaneri left
guifa2 ModuleA::<&basefunction>.wrap( method (|c) { if $*REPLACEMENT { …… } else { callsame } ) 06:13
in the lexical scope you want to use the method, my $*REPLACEMENT = True; 06:14
06:17 stu002 joined
guifa2 xinming: I hope that gives you a good starting point. I'm about to go to bed now, it's quite late here 06:20
06:21 bocaneri joined 06:22 bocaneri left 06:23 bocaneri joined 06:46 xinming left 06:47 xinming joined 06:49 Sgeo left 06:53 satori__ left 06:54 stoned75 joined 06:56 wamba joined 07:27 reach_satori joined 07:31 silug7 joined, silug left, silug7 is now known as silug, vrurg_ joined
Geth_ doc/supply-split: 3757cf86dc | (Stoned Elipot)++ | doc/Type/Supply.pod6
Add Supply.split #3187
07:32
07:32 vrurg left
Geth_ doc: stoned++ created pull request #3552:
Add Supply.split #3187
07:32
linkable6 DOC#3187 [open]: github.com/Raku/doc/issues/3187 [big][docs][help wanted][versions] Checklist for version 2020.01
07:45 JJMerelo joined 07:50 sjm_uk joined
JJMerelo New 20th anniversary calendar entry raku-advent.blog/2020/08/09/rfc-5-...-comments/ 07:55
07:56 molaf joined
Geth_ advent: 3be31cb6f8 | (JJ Merelo)++ | 20th/articles/rfc54.md
Adds links, eliminates whitespace, gets ready to upload @p6steve
08:05
08:09 stu002 left 08:14 Altai-man joined
JJMerelo .tell p6steve I've made some small changes and scheduled your post for tomorrow AM. I would need you to send me your email so that I can invite you to the site and assign authorship of the article to you 08:14
tellable6 JJMerelo, I'll pass your message to p6steve
JJMerelo .seen p6steve
tellable6 JJMerelo, I saw p6steve 2017-10-29T08:02:09Z in #perl6: <p6steve> thanks!
JJMerelo uh-oh
Geth_ advent: 0157b09847 | (JJ Merelo)++ | 20th/articles/rfc54.md
Some small corrections to publish

Please @p6steve send me your email address so that I can invite you to the WordPress blog and assign authorship of the article once you've accepted.
08:16
08:16 sena_kun left 08:23 stu002 joined
Geth_ doc: a4d4b2263c | stoned++ (committed using GitHub Web editor) | doc/Type/Supply.pod6
Add Supply.split #3187 (#3552)
08:24
linkable6 Link: docs.raku.org/type/Supply
linkable6 DOC#3187 [open]: github.com/Raku/doc/issues/3187 [big][docs][help wanted][versions] Checklist for version 2020.01
DOC#3552 [closed]: github.com/Raku/doc/pull/3552 Add Supply.split
08:42 Kaiepi left 08:45 defaultxr left
xinming guifa2: Thanks, But I'd say, wrap is globally, I mean, if we can restore it automatically when we go out of scope will be best. 09:00
09:03 Kaiepi joined 09:08 JJMerelo left 09:21 sjm_uk left 09:26 xinming left 09:27 Kaiepi left, xinming joined 09:31 JJMerelo joined 09:34 Kaiepi joined 10:01 sjm_uk joined 10:15 sena_kun joined 10:16 ensamvarg3 joined, Altai-man left 10:31 stu002 left 11:27 JJMerelo left
Geth_ ¦ problem-solving: CIAvash assigned to jnthn Issue Destructuring infinite ranges and sequences github.com/Raku/problem-solving/issues/218 11:44
advent: ab5tract++ created pull request #58:
RFC 43
11:58
12:00 mscha joined 12:02 sno joined
mscha Quick Q: what's the equivalent of this Perl 5 construct? my ($y, $m, $d) = '20200809' =~ /(\d{4})(\d{2})(\d{2})/ 12:03
m: my ($y, $m, $d) = ('20200809' ~~ /(\d**4)(\d**2)(\d**2)/)[*]; say "$d-$m-$y"; 12:04
camelia 09-08-2020
mscha That does the trick, but it won't work without the `[*]` 12:05
12:13 ab5tract joined
ab5tract .tell JJMerelo can you ping me in private when you get online? In the end I could use a new advent invite to a different email address 12:15
tellable6 ab5tract, I'll pass your message to JJMerelo
12:16 gnufr33dom left
CIAvash m: my ($y, $m, $d) := '20200809' ~~ /(\d**4)(\d**2)(\d**2)/; say "$d-$m-$y"; 12:17
camelia 09-08-2020
CIAvash mscha: ↑ 12:19
mscha Thanks, CIAvash!
12:25 sno left 12:27 sno joined 12:32 wamba left 12:35 lichtkind joined 12:46 xinming left 12:47 xinming joined 13:12 oddp joined 13:14 Altai-man joined 13:16 sena_kun left 13:25 mscha left
guifa xinming: You can unwrap when out of scope. my $wrapper = ModuleA::<&baseFunction>.wrap( … ); ……; ModueA::<&baseFuncion>.unwrap($wrapper) 13:32
13:32 wamba joined
guifa However, if your code is asychronous at all, you can’t guarantee that outside of the scope the wrapped version won’t be called. 13:33
13:48 ab5tract left 14:07 MilkmanDan left 14:08 stoned75 left, MilkmanDan joined 14:32 domidumont left 14:56 Kaiepi left 15:00 Kaiepi joined 15:02 Kaiepi left 15:03 Kaiepi joined, Kaiepi left 15:14 sena_kun joined 15:16 Altai-man left 15:35 Sgeo joined 15:39 Kaiepi joined 15:40 stoned75 joined
codesections Is this idiomatic code for flattening a nested Hash? It feels clunky/like I'm missing a better way: 15:41
m: my %h = a => [1,2,3], b => [7,8,9]; dd %h.values.map(*.flat).flat 15:42
camelia (7, 8, 9, 1, 2, 3).Seq
codesections Oh, the Array docs suggest the following, which still isn't *great*, but is much better 15:44
m: my %h = a => [1,2,3], b => [7,8,9]; dd %h.values».List.flat
camelia (7, 8, 9, 1, 2, 3).Seq
codesections never mind, then :)
15:45 [Sno] joined 15:46 sno left
Geth_ advent/master: 4 commits pushed by ab5tract++, (Juan Julián Merelo Guervós)++ 15:48
stoned75 q 15:49
15:50 [Sno] left 15:58 wamba left 16:16 demostanis joined
demostanis Hello people, is there a way to (like in JavaScript) give a default value to a variable defined with my (...) in case it's Nil? 16:17
tellable6 2020-08-09T01:55:05Z #raku <melezhik> demostanis: "Also security doesn't seem to be that important as it's supposed to be running locally." I am not sure what you mean locally, sparrowdo could run over ssh as well
demostanis Example: my ($a, $b = "default value) = (1) # $a = 1, $b = Nil 16:18
rypervenche m: my $var = Nil // "blah"; say $var;
camelia blah
demostanis Yeah, but what if I define it with my (...)?
rypervenche Oh sorry, I misunderstood. 16:19
demostanis melezhik: What I meant is that the sparrowfile is executed locally, and isn't being fetched from an untrusted somewhere else? Am I right?
tellable6 demostanis, I'll pass your message to melezhik
demostanis I'm doing this in a proto subroutine 16:20
my ($thing1, $thing2 = "might not exist so should give a default value") = {*}
codesections demostanis: interesting, I'm surprised that this vvvv doesn't work 16:21
m: my ($a, $b = 42) = (1,)
camelia ( no output )
codesections m: say my ($a, $b = 42) = (1,)
camelia (1 (Any))
demostanis Do I have to do $b = "default value" if !$b.defined
Isn't there a cleaner way? And why won't Rakudo throw any error if my ($a, $b = "...") isn't correct? 16:22
guifa You can use the default trait
demostanis What is it?
guifa m: my $a is default(‘default’); my $a = “set”; say $a; $a = Nil, say $a; 16:23
camelia Potential difficulties:
Redeclaration of symbol '$a'.
at <tmp>:1
------> 3my $a is default(‘default’); my $a7⏏5 = “set”; say $a; $a = Nil, say $a;
set
default
guifa err
m: my $a is default(‘default’); $a = “set”; say $a; $a = Nil, say $a;
camelia set
default
demostanis m: my ($hello, $world is default("John")) = ("hello ") 16:24
camelia ( no output )
demostanis m: say my ($hello, $world is default("John")) = ("hello ")
camelia (hello (Any))
demostanis Nope?
guifa m: say my ($hello, $world is default("John")) = ("hello “, Nil)
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in double quotes; couldn't find final '"' (corresponding starter was at line 1)
at <tmp>:1
------> 3ld is default("John")) = ("hello “, Nil)7⏏5<EOL>
expectin…
guifa er stupid quote replacement on Colloquy
codesections I was trying that too. Doesn't work 16:25
m: say my ($hello, $world is default("John")) = ("hello ", Nil)
camelia (hello (Any))
demostanis Okay, thanks, I didn't know about it!
guifa Oh duh. Trait needs to go with declarator. Compare 16:27
m: (my $hello, my $world is default("John")) = (Nil, Nil)
camelia ( no output )
guifa m: say (my $hello, my $world is default("John")) = ("hello ", Nil)
camelia (hello John)
codesections demostanis: one note that doesn't help solve your problem but that you might want to know (it's tripped me up before): in Raku `("Hello")` doesn't create a 1-element List. You need `("Hello", )` or just `"Hello",`
guifa m: say my ($hello, $world) is default('John') = (Nil, Nil)
camelia (John John)
guifa You’ll just have to content yourself with repeating my once or twice :-) 16:28
demostanis codesections: Oh yeah, sorry, I often do this mistake 16:31
codesections Me too :)
guifa The nice thing about the commas making the lists is that you can remove sooo many parentheses 16:35
16:38 poohman joined 16:39 leah2 left
poohman hello all, I was searching for using grammars in Binary streams - as far as I could find there were a few searches for this earlier and it seems like Raku does not support this as of now 16:40
I have seem some excellent work by dwarring in the pdf grammar module - he has done something like that 16:41
should I go for something like Katai Structs or can I try in Raku 16:42
we have Perl bindings for Katai Structs
any suggestions or ideas? 16:43
guifa poohman: I’m working on binary grammars but I don’t have them ready yet, but you can check out the project here
github.com/alabamenhu/BinexObjex
poohman hi guifa, thanks, Ill have a look 16:44
guifa, just curious - have you looked at Katai Structs?
guifa Be warned there’s probably lots of bugs, I haven’t touched it in a bit as I’m waiting for RakuAST to be released
poohman sure thanks for the heads up 16:45
guifa Yeah, Binex is designed to be similar, except run more like Raku grammars with mostly the same syntax.
If you’re familiar with Katai already
I’d look into just using the Perl module in Raku 16:46
poohman ok thanks 16:47
codesections m: my ($hello, $world) = ([Z] ("hello", Nil), ((), 'John')).map({.head // .tail})
camelia ( no output )
codesections m: say my ($hello, $world) = ([Z] ("hello", Nil), ((), 'John')).map({.head // .tail})
camelia (hello John)
guifa o.O
That is one of the ugliest lines of code I’ve seen in a while ;-)
codesections demostanis: ^^^ alternate syntax that's probably less useful than `in default` but might be better in some cases 16:48
:D
16:49 leah2 joined
codesections well, it lets you do something like `my ($a, $b) = ([Z] get-values, $defaults).map({.head // .tail})` if you already have defaults defined 16:49
(and I just like zipping lists, what can I say?) 16:50
I know `when` and using a literal regex will automatically smartmatch against the topic if no other smartmatch is provided. Is there any other case where Raku does that auto-aginst-the-topic behavior? 16:52
rypervenche In a sink context. 16:53
From the regexes doc: In case a Regex object is used in sink context, or in a context in which it is coerced to Bool, the topic variable $_ is automatically matched against it: 16:54
codesections Right, that's a better/more technical way to say what I meant. I know regex will auto-match against the topic (in sink contexts). And I know `when` will too. Are there any other catigories besides those two? 16:55
guifa I can’t think of any off the top of my head 16:56
codesections Thanks
guifa It’s sort of a very Perl-esque way to do things
(and one of the few that Raku moved slightly away from)
codesections Oh? How so? I don't know Perl 16:57
guifa So in perl, the topic was reset with each operation
demostanis codesections: I think I'm too new to Raku to understand your piece of code
guifa my $a = 5; # now $_ = 5
my @b = 1,2,3; # now $_ is 1,2,3
16:58 domidumont joined
guifa pop 16:58
16:58 domidumont left
guifa # now b is 1,2; and $_ is 3 16:58
codesections Ah, interesting
guifa I don’t think either way is per se better, but it’s important to be consistent with either one
That said 16:59
I wonder if I can catch the topic variable
in a sub, I mean
17:00 zacts joined
guifa Yup 17:00
sub foo { say CALLER::<$_> }; for ^3 { foo }
m: sub foo { say CALLER::<$_> }; for ^3 { foo }
camelia Cannot access '$_' through CALLER, because it is not declared as dynamic
in sub foo at <tmp> line 1
in block <unit> at <tmp> line 1
guifa hmmmm
codesections Raku lets you do chained assignment, so you could do $_ = my $a = 5 17:01
guifa thinks this is a (relatively) recent change. It’s working on TIO
But it makes sense for $_ to not be dynamic
17:02 stoned75 left
guifa That said, $/ is dynamic. So you can totally much with it if you want 17:02
17:04 demostanis left 17:14 Altai-man joined 17:16 sena_kun left 17:18 wamba joined 17:20 melezhik joined
melezhik .tell demostanis: "sparrowfile ... isn't being fetched from an untrusted somewhere else" - correct 17:21
tellable6 melezhik, I'll pass your message to demostanis
17:29 natrys joined 17:30 melezhik left 17:43 lichtkind left
guifa I wish it using the $^args were a bit more forgiving on number of arguments — basically, ignoring additional ones 17:45
17:49 poohman left 17:52 aluaces left 17:53 mowcat joined 18:08 ensamvarg3 left, zacts left 18:09 zacts joined 18:13 lichtkind joined, xinming_ joined 18:14 mowcat left, mowcat joined 18:16 xinming left
codesections you mean so that you could do something like `my &f = { say $^a }; f(1, 2)` without getting an error? 18:21
guifa2 yeah
I have a giant hash of callables and all of them need $a, most need $b, and a small handful need $c 18:22
I was using {sink $^b; $^a.foo } for those that didn't need $b
but once I realized I needed $c… it just feels wasteful 18:23
using @^foo defeats the naming advantage. ah well 18:24
I'll just give them all a signature. It's just already a huuuuuuuuge hash with long lines because I'm trying to do one line per entry
codesections is there a way to do named formal args? something like `%^:a`? 18:25
18:25 cpan-raku left
codesections Probably not, "named formal arguments" sounds like a contradiction 18:26
Altai-man codesections, yeah. 18:27
m: { say $:hehe }(hehe => 42)
camelia 42
Altai-man codesections, ^
m: { say $^foo }(42)
camelia 42
Altai-man ^ positional formal one
codesections guifa: Would the named variant ^^^ solve your use case 18:28
?
guifa2 WHOA 18:29
I had no idea you could twiggle with colons
although it is clearly documented so I s'pose I should have 18:30
That's perfect for me, actually since it helps for self documenting on the calling side 18:31
codesections m: my &f = {say $:a }; f(a=>0, b=>2) 18:32
camelia Unexpected named argument 'b' passed
in block <unit> at <tmp> line 1
codesections Do you run into that error ^^^ ?
guifa2 ouch
guifa2 hadn't tried it yet 18:33
18:33 domidumont joined
guifa2 formal signature it is then 18:35
codesections This is a bit sloppy/less safe, but you could use dynamic formal variables:
m: my &f = {say $:a }; f(a=>0, b=>2)
camelia Unexpected named argument 'b' passed
in block <unit> at <tmp> line 1
codesections m: my &f = {say $*a }; { my $*a = 0; f} 18:36
camelia 0
codesections (sorry, wrong paste the fist time)
18:36 domidumont left
xinming_ my $c = \(1, 2, 3, :a<b>, "a" => 1); [$c.list, $c.hash].raku.say; 18:36
evalable6 [(1, 2, 3, :a(1)), Map.new((:a("b")))]
CIAvash guifa2: If understood you correctly, you can use `@_ ` inside your sub to refer to parameters 18:37
xinming_ Inthis example, what if both :a<b>, and "a" => 1 are in a scalar, How can we let raku DWIM?
the quoted "a" => 1 will be put into list, while :a<b> will be in hash. What if we use slip, and they are all in an array, where the array contains list of pairs? 18:39
guifa2 CIAvash: indeed, but using @_ means you lose the semantic connection to the variables. (%_ is a possibility, but this is a hot enough loop that hash access is a major slowdown). I'll try with the dynamics
codesections CIAvash: ooh, I knew about @_, but you saying that made me realize that there's also `%_`
xinming_ That makes me quite curious, wether this is handled in syntax level
codesections Wow, that's a pretty hot loop – *Hash access* is too slow? Does Raku do something weird where Hash access isn't O(1), or is it just the time of dereferencing the pointers that's too slow? 18:41
guifa2 m: my $c = \(1, 2, 3, "a" => 1, :a<b>, ); [$c.list, $c.hash].raku.say;
camelia [(1, 2, 3, :a(1)), Map.new((:a("b")))]
timotimo where can i see the code? :)
guifa2 codesections: it's O(1), but hash access compared to attribute access is hugely different. I can't imagine hash access being faster than access bound arguments 18:43
When you have %hash<a><b><c><d><e><f><g><h><i><j> over and over again haha
codesections Yeah, that *is* a lot of indirection :) 18:44
18:44 bocaneri left
guifa2 When I mentioned needing a $c, it's because I've been passing in something around, say, level E up there to avoid a few levels of calls, but suddenly I needed a sister element of E that I can only access from C level. 18:45
timotimo: you can see the old monstrosity code here: github.com/alabamenhu/Intl-CLDR/bl...teTime.pm6 18:46
18:46 raku-bridge1 joined, cpan-raku joined, cpan-raku left, cpan-raku joined
guifa2 I'm converting the giant given/when into a single hash whose keys are <a aa aaa aaaa aaaaa A AA AAA AAAA AAAAA>, etc, which should be a good bit faster 18:46
but then have to deal with passing vars into the callable values 18:47
timotimo the "for @pattern" loop? 18:48
codesections Makes sense. Dynamic variables enclosed in a lexical block to limit their scope otherwise seem like a good fit for that usecase 18:50
guifa2 Yeah. What I was thinking about doing is in the pattern parsing action, just return a list of callables.
codesections Even though I don't love dynamic variables for many use cases
guifa2 @pattern».(args…).join 18:51
(the current version can only generate a handful of patterns a second which is… awful lol)
s/generate/format 18:52
18:56 Geth joined 18:58 raku-bridge1 left, raku-bridge2 joined 19:00 wamba left 19:01 raku-bridge2 left 19:02 [Sno] joined, Geth_ left, raku-bridge3 joined 19:03 raku-bridge3 left, raku-bridge4 joined 19:06 raku-bridge4 left 19:07 raku-bridge5 joined 19:08 raku-bridge5 left 19:09 raku-bridge6 joined
timotimo oof 19:11
did you try to --profile it, or run any other kind of profiler at it?
guifa2 timotimo: the html profiler can't locate a file for me. Is there a way to cleanly view the SQL file generated? I couldn't find info on that but I probably just missed them 19:14
timotimo moarperf will display all the info from the sql for you
19:15 sena_kun joined 19:16 molaf left, Altai-man left 19:17 raku-bridge6 left
timotimo github.com/Raku/nqp/pull/354#issue...-296382898 - also check this out; it will need a rename or two of the variables, though 19:18
19:18 raku-bridge7 joined, raku-bridge7 left, raku-bridge7 joined
guifa2 timotimo++ 19:19
There's a LOT of perf tuning I need to do for Intl
19:26 raku-bridge7 left, raku-bridge8 joined, raku-bridge8 left 19:27 Geth_ joined, Geth left, cpan-raku left 19:28 raku-bridge1 joined 19:35 raku-bridge left, raku-bridge1 is now known as raku-bridge, sjm_uk left 19:44 cpan-raku joined, cpan-raku left, cpan-raku joined 19:47 raku-bridge left 19:48 Geth_ left, cpan-raku left 19:49 Geth joined 19:50 raku-bridge joined, raku-bridge left, raku-bridge joined 20:06 ab5tract joined 20:07 raku-bridge left, raku-bridge joined 20:08 cpan-raku joined, cpan-raku left, cpan-raku joined
guifa codesections timotimo here’s a quick mockup of the speed difference between arguments and dynamics 20:10
bit.ly/2XKD38D
dynamics are ~5x slower 20:11
timotimo even with our dynamic variable cache, they aren't extremely fast
arguments, on the other hand, tend to be extremely well optimized 20:12
guifa Yeah, so that definitely pushes me to making all of my little code blocks get a signature
Actually interesting 20:16
20:17 Kaiepi left
guifa It’s FASTER to pass containers 20:17
I would have thought binding everything and passing in contextless/sigiless vars would have been faster 20:18
timotimo optimizer performance can be a bit "bumpy" 20:19
guifa But consistently it’s about a 1 : 2.5 : 5 performance ration between $args, \args and $*args
yeah, I know stuff isn’t crazy optimized yet, so I swear I’m not trying to prematurely optimize 20:20
20:20 rir joined
timotimo unexpected things can prevent some optimizations, is what i mean 20:20
so the impact can be surprising
20:21 Geth left 20:22 aluaces joined
guifa indeed 20:22
20:22 aluaces is now known as alberto
guifa More testing actually shows that… it’s having an explicit signature 20:22
ab5tract .tell JJMerelo if you could send the invite to my email in CONTRIBUTORS that would be awesome. if not, no worries -- the post will be live and pre-published for Tuesday mid-morning tomorrow no matter what
tellable6 ab5tract, I'll pass your message to JJMerelo
20:23 Geth joined, raku-bridge left, alberto is now known as Guest2056
guifa -> $a, $b, $c { $a + $b + $c } vs { $^a + $^b + $^c } 20:23
I would have thought that they were functinoal identical but that’s not the case, it turns out
err s/functionally identical/compile identically
20:23 raku-bridge joined, raku-bridge left, raku-bridge joined
timotimo that's the speed difference? 20:26
guifa yeah 20:27
20:27 raku-bridge left, raku-bridge joined, raku-bridge left, raku-bridge joined
guifa Granted, I’m testing this on TIO, so I should probably go and do it on a newer version; one sec 20:27
same results on 2020.01 20:28
Although the ratio is now more like 1 : 2 : 3 20:29
codesections very interesting 20:30
20:32 Kaiepi joined
codesections Here's the output I get from your Tio script on 2020.06: 20:33
arg in 0.04354408
dyn in 0.06789509
arg in 0.0064172
dyn in 0.0642456
arg in 0.0064169
dyn in 0.0639006
It looks like they're not *that* different to start with, but the dynamic variable prevents optimization in later calls (I bet it prevents the function inlined, though that doesn't entierly make sense) over time 20:34
20:39 Geth left, cpan-raku left, raku-bridge left 20:41 Geth joined
sena_kun sourceable6, 1+2 20:41
sourceable6 sena_kun, No idea, boss. Can you give me a Code object?
20:42 cpan-raku joined, cpan-raku left, cpan-raku joined, raku-bridge joined, raku-bridge left, raku-bridge joined
sena_kun sourceable6, &infix:<+>; 20:42
sourceable6 sena_kun, github.com/rakudo/rakudo/blob/7986...c.pm6#L208
AlexDaniel` sourcable6: 1 + 2
sourceable6 AlexDaniel`, github.com/rakudo/rakudo/blob/7986...t.pm6#L335
coverable6 AlexDaniel`, and I oop! Backtrace: gist.github.com/10ebb3922e67f2a5af...2bc74e004d
20:43 rindolf left
AlexDaniel` sena_kun: seems like it wants spaces 20:43
sena_kun So be it, could trigger it anway. ;)
20:44 ab5tract left 20:47 Black_Ribbon joined
AlexDaniel sena_kun: yes but that particular candidate is in a different file :) 20:49
sena_kun Oh, you are right. To be honest, I was expecting to find where `is assoc` is set, but I suspect it is somewhere deeper in the guts, really, and I don't want to increase size of my article which is already pretty big. 20:50
guifa2 codesections: the first run is the slowest, but once they heat up, you can see it's an order of magnitude. Although when I got the 1:2:3 I upped the repetition count by an order of magnitude too 20:54
AlexDaniel sena_kun: github.com/rakudo/rakudo/blob/7986....nqp#L3666
sena_kun: and also: github.com/rakudo/rakudo/blob/7986....nqp#L4106 20:55
rir Could not @Demostanis have just used `my $v = something() // default;` in his proto function. (I'm late for reading the docs and interruptions.) 20:56
sena_kun AlexDaniel, what a nice low-levelness.
AlexDaniel sena_kun: I don't know why it's there 20:57
maybe jnthn has a long explanation
codesections Well, I guess I'm curious about the "once they heat up" part. I assume a lot of that is from warming the cache or giving the JIT more info to work with. Which is what I mean by saying that the dyn variable seems not to prevent inlining or something
guifa ^^ 20:58
sena_kun Well, it's no wonder fundamental operators to run things are implemented using low-level bits.
AlexDaniel sena_kun: it's not fundamental operators, it's all operators
sena_kun: maybe it has something to do with the penalty involved when defining new operators
codesections rir: If I remember that conversation correctly, no, that's what they wanted to be able to do but that isn't valid syntax (though I'd love to be wrong if you have a working example!)
sena_kun AlexDaniel, fair enough. 20:59
guifa2 codesections: Replace the dynamic would with a &explicity = -> $a, $b, $c, $d, $e, $f, $g { $a+$b+$c+$d+$e+$f+$g }; there shouldn't be a problem inlining that one though, which is weird
21:01 molaf joined
AlexDaniel m: sub foo{ multi infix:<+>(42, 42) { ‘yes’ } }; say 42 + 42 21:02
camelia 84
AlexDaniel hmmmm
cool
guifa2 AlexDaniel: meh, kind of. But it also means defining operators for new classes sucks :-( 21:03
AlexDaniel guifa2: why?
guifa2 Lemme put together an example of when it can go awry 21:04
AlexDaniel I always thought that it is actually as good as it can be because someone's custom operators can never affect my code 21:05
some may be surprised to hear that but it's part of Raku that I truly like :)
sena_kun guifa2, you are very welcome to provide an example. :) 21:06
AlexDaniel sena_kun: why tho, lemme have something I like xD 21:09
guifa2 tio.run/##K0gtyjH7/78gMTk7MT1VwS0/...QCIQxv//AA
rir p6: proto p(Any $x |) { my $v = $x // 'Default' } ; sub nil { return Nil } ; sub one { return 1 } ; p( nil()).say; p( one()).say;
camelia 5===SORRY!5=== Error while compiling <tmp>
Malformed parameter
at <tmp>:1
------> 3proto p(Any $x7⏏5 |) { my $v = $x // 'Default' } ; sub ni
expecting any of:
constraint
rir p6: proto p(Any $x, |) { my $v = $x // 'Default' } ; sub nil { return Nil } ; sub one { return 1 } ; p( nil()).say; p( one()).say; 21:10
camelia Default
1
sena_kun AlexDaniel, I am writing an article about operators applied to objects right now and that'll suck to suggest it to get people tell me "Bah, this is just wrong and bad".
AlexDaniel right 21:11
codesections rir: oooh, I see what you mean! That *is* a nice solution, even compared to the `is Default` idea guifa had – and *especially* compared to the ugly zipping code I produced :D 21:12
sena_kun So input on the topic is very helpful, I guess.
guifa2 Compare the difference to making something Associative by just defining AT-KEY, etc, and violà any object handles the built in post circumfixes as they feel is correct 21:13
AlexDaniel guifa2: isn't it a bug? I'm not sure
guifa2 No, that's how it's supposed to work