🦋 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.
timotimo you're only asking about this from a performance standpoint? not like deployability / portability or so? 00:00
discord6 <BrightLight> I think I'm just trying to understand what makes some dynamically typed languages simpler to compile to machine code than others - AOT incremental compiler vs JIT and such. I am just trying to learn what I can. 00:03
timotimo doing ahead-of-time compilation of raku code would leave a whole lot of performance on the table due to unknowns like "what exact type will be here" (i.e. not a subtype or something mixed in etc) or "is this variable in a container at this point or not?" 00:04
moar's jit will generate a direct pointer access on an object when attribute access happens, but non-specialized code will only have the name and a suspected slot so it'll still go look at the attribute name table 00:05
discord6 <BrightLight> Thank you; 00:14
timotimo you're welcome :) 00:29
discord6 <BrightLight> Also, does Raku have nonlocal transfer of control of some form? For example a return-from <some-lexically-determined-block>. (I'm using Discord so code formatting on here is fine - not sure about the irc clients, so forgive me if my code example doesn't show up properly formatted. lisp (defun foo () (let ((a 1)) (flet ((bar () (let ((b 2)) (return-from foo b)))) (bar)))) 00:50
<BrightLight> Here bar returns from an external block (the function foo). 00:52
timotimo the specification specifies the ability to leave named blocks, at the moment we only have "break from a labelled loop" i think? 01:18
discord6 <BrightLight> Ah fair enough; it's a very nice feature to have so I'm glad to hear 01:21
discord6 <Highlander> On this topic, do you happen to know how much optimization we currently do when a type is specified by the user? Mixins and such make it a little harder, but I imagine optimistic specialization is possible 02:45
discord6 <Highlander> I know we specialize on types that tend to show up at runtime, but I haven't heard much about how user-specified types might help early on 02:47
patrickb I'm trying to call a Windows API function returning an LPWSTR (pointer to utf16 encoded string) using NativeCall. 09:26
I use `returns Str is encoded('utf16') is rw`. Resulting in `Malformed UTF-16; odd number of bytes (1)`. 09:27
When retrieving the thing via CArray the bytes look as I'd expect though (34, 0, 67, 0, ..., 0, 0). 09:28
Can anyone give a hint on how I can make this work?
lizmat obtain as bytes, then decode ? 09:33
patrickb How can I decode a List / CArray? It seems I can't make a native function return a Blob... 09:43
patrickb I managed to make it work. 10:02
paste.scsys.co.uk/588568 <-- I'd still expect this to work with `returns Str is encoded('utf16') is rw`. Is this a bug? Should I create an issue? 10:07
lizmat patrickb: probably 10:12
patrickb Will do! 10:13
lizmat one note: for 0 .. * -> $i, $j { @nat-arr[$i], @nat-arr[$j] }
patrickb Ah, nice!
lizmat is probably better readable, and with the current state of ... definitely faster 10:14
El_Che hi patrickb , lizmat 10:22
lizmat El_Che o/
patrickb Hi there! 10:23
github.com/rakudo/rakudo/issues/3629 <- Issue created.
lizmat patrickb++
patrickb El_Che: Have you seen github.com/Raku/raku.org/pull/146 ? 10:31
El_Che Ill have a look now 10:38
Xliff \o 11:13
Would a Buf work in place of a CArray[uint8] in all NativeCall instances (both as a parameter type and as a return type)? 11:14
It would seem like a natural thing for them to be, but a while ago, I ran in to segfaults whenever I did it and just wanted to know if that was a bug that had been addressed. 11:15
Xliff m: use NativeCall; sub malloc(uint64) returns Buf; my $a = malloc(100); say $a; 11:15
camelia 5===SORRY!5=== Error while compiling <tmp>
A unit-scoped sub definition is not allowed except on a MAIN sub;
Please use the block form. If you did not mean to declare a unit-scoped sub,
perhaps you accidentally placed a semicolon after routi…
Xliff m: use NativeCall; sub malloc(uint64) is native returns Buf; my $a = malloc(100); say $a;
camelia 5===SORRY!5=== Error while compiling <tmp>
A unit-scoped sub definition is not allowed except on a MAIN sub;
Please use the block form. If you did not mean to declare a unit-scoped sub,
perhaps you accidentally placed a semicolon after routi…
Xliff m: use NativeCall; sub malloc(uint64) is native returns Buf { * }; my $a = malloc(100); say $a; 11:16
m: 2 + 2
Eep! Did I just kill camelia?
lizmat Xliff: possibly :-) 11:22
nine: ^^
nine m: say "back" 11:37
camelia back
Geth_ doc: 45d04e5ea6 | (Jonathan Worthington)++ (committed using GitHub Web editor) | doc/Language/nativecall.pod6
Mention native callback exception handling

The error reporting from MoarVM about this situation recently improved. This adds a mention about it to the documentation also.
12:50
linkable6 Link: docs.raku.org/language/nativecall
lichtkind in june 2019 was a perl 6 user survey 13:37
does anybody has the link?
thanks
Altai-man_ docs.google.com/forms/d/1WQpY740a8...#responses lichtkind 13:39
tellable6 2020-04-16T22:10:28Z #raku-dev <AlexDaniel> Altai-man_: github.com/ugexe/zef/issues/342
2020-04-16T22:12:10Z #raku-dev <AlexDaniel> Altai-man_: I don't know if it's the only issue, but at least it's something I was able to reproduce on my own setup
lichtkind Altai-man ++ thanks i got jsut the previous one in 2019
ähm 2018 13:40
Altai-man++ 13:41
guifa2 jnthn++ and (iirc) sena_kun++ for Comma release 16:37
sena_kun \o/ 16:38
guifa2 And congrats for figuring out mac code signing! 16:40
guifa2 knows it's a pain in the ass
lizmat we haz a Comma release ? 16:45
jnthn A couple of weeks ago, but I guess some are only just getting around to trying it :) 16:46
There's one every month for subscribers
Later this month there'll be a new community one also :)
lizmat and you didn't tweet about it ?
lizmat last thing I saw was twitter.com/jnthnwrthngtn/status/1...0065078275 16:46
jnthn Pretty sure I tweeted about the headline new feature that was coming in it :)
Yes, that one :) 16:47
lizmat yeah, but because there was no formal announcement, I assumed the release was held up on account of signing issues
lizmat and thus wasn't mentioned in the RWN 16:48
:-(
guifa2 jnthn: I only got the message for 2020.03 today 16:49
guifa2 just realized in typing that that 2020.03 means "came out two weeks ago..."
It kinda feels like we're still in March =\
jnthn It checks at every startup for updates, unless you disable that (or have no internets...)
guifa2 Is it possible to reference random Raku grammar tokens inside of an adhoc regex/grammar? 16:55
guifa2 is currently testing with just <identifier> to be replaced later, but it would be sweet if it's easy to reference the real one
sena_kun <Grammar::rule-i-want> ? 16:56
lizmat m: say "24 foobar 99" ~~ / <ident> /
camelia 「foobar」
ident => 「foobar」
guifa2 sweet 16:57
guifa2 sena_kun: gives a P6opaque error on that one 16:58
sena_kun guifa2, it was a worthy fight to try it out... :] 16:59
guifa2 I've just got about got an initial test of Binex. Not a pretty interface ATM but functional. Mainly missing the operators and still thinking through some other usability questions 17:01
timotimo guifa2: i think in the binary regex document there's a /foo/modifiers somewhere, where the modifiers ought to go at the start 17:11
guifa2 timotimo: lemme check it. As I'm writing it I'm catching little errors I had 17:12
s/writing/coding
timotimo *thumbs up* 17:13
guifa2 bgills' suggestion for Z and X are creating an interesting question 17:15
guifa2 It's possible for the same token to have two different values, an issue that doesn't exist in regex (where <foo> & <bar> must match identical text, and thus their capture values would be exactly the same) 17:18
err, rephrased, <foo> could be matching one value, but needing to return another, and <bar> would still be matching the same, but needing to return a different one. So <abc> if coerced to a blob, should it return to the original matched data, or give preference to foo/bar's modified values? 17:20
moritz what do you mean by "return another"? 18:57
moritz that it captures something else? 18:57
moritz a regex either matches or it doesn't, and it advances the cursor in the string zero or more characters 18:58
guifa2 moritz: correct. 19:01
bgills had a nice suggestion for binex syntax to allow for, e.g., b11.._XXXX, which would match any byte with the highest two bits on, but would then right-shift the value, so that 0b1101_1101 ~~ bin/b11.._XXXX/ would net you 0b0000_1101
moritz currently, $/ indexes into the originally matched string 19:03
but you could always attach the modified value to $/.ast
guifa2 Yeah, that's one of the solutions I'm thinking about 19:04
moritz I haven't read the proposal yet, so don't know the context exactly, but returning some that isn't quite Match but has a similar API might also be possible 19:05
guifa2 moritz: it's a super early proposal, so please feel free when you do read it to shred it to pieces :-) 19:06
Right now I'm thinking a trait (or separator declarator) might be a good way to go about it. "token is scoured { ... }" where the is-scoured trait would allow the use of X and Z (opting into the modifications, and allowing them to trickle up if desired), and disallowing &/&& because it creates an ambiguous modification value 19:07
jdv79 i just ran raku -e 'sleep' and perl -e 'sleep' and noticed raku uses 80M and perl uses 4M. is raku expected to always use way more mem? 19:27
jdv79 i have an app where a deliberately scaled down version takes 400M and now i'm curious if i'll be able to run the full intended version 19:29
Xliff can repr CPointers compose a DESTROY? 19:39
m: use NativeCall; class A is repr<CPointer> { submethod DESTROY { say "Hi!" }; }; A.new.say;
camelia A.new
Xliff m: use NativeCall; class A is repr<CPointer> { submethod DESTROY { say "Hi!" }; }; my $a = A.new; $a = Nil; sleep 5; 19:40
camelia ( no output )
Xliff Aand... GC was never run.
Xliff m: use NativeCall; class A is repr<CPointer> { submethod DESTROY { say "Hi!" }; }; { my $a = A.new; $a = Nil; }; sleep 5; 19:50
camelia ( no output )
Xliff m: use NativeCall; class A is repr<CPointer> { submethod DESTROY { say "Hi!" }; }; { my $a = A.new; $a.^METHODS.say }; sleep 5; 19:50
camelia Hi!
No such method 'METHODS' for invocant of type 'Perl6::Metamodel::ClassHOW'
in block <unit> at <tmp> line 1
Xliff m: use NativeCall; class A is repr<CPointer> { submethod DESTROY { say "Hi!" }; }; { my $a = A.new; $a.^methods.say }; sleep 5;
camelia (DESTROY BUILDALL)
Xliff m: use NativeCall; class A is repr<CPointer> { submethod DESTROY { say "Hi!" }; }; { my $a = A.new; A.^methods.say }; sleep 10; 19:51
camelia (DESTROY BUILDALL)
Xliff How can I force call the GC?
m: use NativeCall; use nqp; class A is repr<CPointer> { submethod DESTROY { say "Hi!" }; }; { my $a = A.new; A.^methods.say }; nqp::force_gc(); sleep 10; 19:52
camelia (DESTROY BUILDALL)
Hi!
guifa2 jdv79: on my system, perl -e 'sleep' uses 628k, but perl -e 'use Moose; sleep' uses 15M 19:56
Raku is more akin to perl+Moose (or perl+other OO package) than perl by itself. That said, raku -e 'sleep' on mine uses 50 MB, so there's a bit more stuff there for sure. 20:05
Doc_Holliwood why do we have sigilless variables? 20:39
what's their intended purpose?
jnthn Not enforcing context 20:51
guifa2 just looked up the design docs, and apparently the current sigilless vars were going to be sigiled, just with ¢ 20:54
jnthn Hah, I'd forgotten that bit of history :) 21:07
guifa2 jnthn: that also reminds me of a long ago project I had concocted: creating custom sigils. I think after digging around in Rakudo enough I might even be able to pull it off 21:23
I decided to not reinvent the wheel on Binex and I'm shamelessly ste--borrowing the built in regex grammar and actions and just deleting / adding what's necessary 21:24
But learning a lot about the internals along the way
Xliff m: class A { }; role B { }; my \a = A,new but B; a.^name.say 21:45
camelia 5===SORRY!5=== Error while compiling <tmp>
Unsupported use of C++ constructor syntax; in Raku please use method call syntax
at <tmp>:1
------> 3ss A { }; role B { }; my \a = A,new but 7⏏5B; a.^name.say
Xliff m: class A { }; role B { }; my \a = A.new but B; a.^name.say
camelia A+{B}
Xliff Huh! 21:46
I thought sigilless was equiv to "is raw" and that those were containerless.
lizmat Xliff: sigilless means binding 21:48
but if you bind a container...
m: my \x = $ = 42; dd x; x = 666; dd x
camelia Int $ = 42
Int $ = 666
Xliff lizmat: Yes, if you bind to a container you get the container, but if you don't is there a need to cont/decont? 21:50
lizmat indeed
Xliff Is that a yes or a no?
lizmat yes 21:51
that's why hot code can benefit from binding rather than assigning containers
Xliff Ah! So what's the best way to avoid the cont/decont penalty?
Now I'm confused. :/
lizmat see e.g 2d1ba433af8c730126e7 21:52
linkable6 (2020-04-14) github.com/rakudo/rakudo/commit/2d1ba433af Make Num.Rat conversion again 1.5x as fast
lizmat the original code used $a,$b,$c,$d etc with containers 21:53
by using binding, that saved 7 scalar allocations for each conversion
of num to Rat 21:54
m: my $a = 42; for ^1000000 { my $b = $a + 666 }; say now - INIT now 22:00
camelia 0.0945552
lizmat m: my $a = 42; for ^1000000 { my $b := $a + 666 }; say now - INIT now
camelia 0.03908242
lizmat m: my $a := 42; for ^1000000 { my $b := $a + 666 }; say now - INIT now
camelia 0.021793
Xliff So sigilless/bind does not need cont/decont. 22:07
Thanks.
cpan-raku New module released to CPAN! BitEnum (0.3) by 03CTILMES 22:15
chloekek … I just realized why it’s called kebab case. 22:33
tellable6 2020-04-17T11:21:06Z #raku-dev <lizmat> chloekek: wonder how that applies to CRAI ?
2020-04-17T11:21:36Z #raku-dev <lizmat> chloekek: that being en.wikipedia.org/wiki/BagIt
chloekek The letters are skewered along a centered stick. 22:34
I never noticed because where I live kebab usually refers to döner kebab, which is not served skewered. 22:35
lizmat: > A required tag file contains a manifest listing every file in the payload together with its corresponding checksum. — Sounds like my CRAI’s database. 22:36
s/my CRAI’s/CRAI’s SQLite/. 22:37
jnthn lizmat: Be a little careful with that assign vs. bind benchmark showing a 3x difference; in the binding case, assuming the lexical is lowered, then I think spesh can reason that the addition as dead code, so it's probably not actually measuring what you hope :)
jnthn lizmat: Yes, checked and indeed, the integer add totally vanishes in the bind case too. 22:48
jnthn In the binding case it can't yet toss that out because binding an attribute (the $!value of Scalar) is an effect 22:49
Sorry, s/binding/assignment/ in that one
However, EA would probably nail that one 22:50
.oO( All this optimization effort, just to screw up people's benchmarks... )