🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
ToddAndMargo Raku (Perl6) question NativeCall question: 08:34
I have little ending 8 bytes in a CArray representing a memory address.  How do I create a Pointer out it?
This is frustrating as the array is 8 bytes and the pointer is also 8 bytes and the position of the bytes is the same in both.  AAAHHH!!!!! 09:04
mscha m: my @a =<a b c d e f g>; say @a/2; # :-) 12:08
camelia 3.5
mscha m: my @a = <a b c d e f g>; say @a div 2; # :-(
camelia Cannot resolve caller infix:<div>(Array:D, Int:D); none of these signatures matches:
(Int:D $a, Int:D $b --> Int:D)
(int $a, int $b --> int)
(uint $a, uint $b --> uint)
in block <unit> at <tmp> line 1
mscha m: my @a = <a b c d e f>; say @a.head(@a/2); # :-) 12:14
camelia (a b c)
mscha m: my @a = <a b c d e f>; say @a.tail(@a/2); # :-(
camelia Type check failed in binding to parameter '$toskip'; expected Int but got Rat (3.0)
in block <unit> at <tmp> line 1
mscha m: my @a = <a b c d e f>; say @a.tail(+@a div 2); # :-/
camelia (d e f)
Nemokosch what's the matter with the last one? 12:18
mscha Last one works fine, but is longer, less elegant.  If `head` works fine with a `Rat`, why doesn't `tail`? 12:19
sarna why is this error so weird? 12:24
m: sub foo { True }; foo or die "not true"
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
or used at line 1
sarna ah I can fix it with unless
Nemokosch yeah perhaps you shouldn't use "or die" pattern anyway 12:25
but foo() or die would have worked probably
by the way: github.com/Raku/problem-solving/issues/326 12:26
I opened this issue months ago so yeah...
if you could leave a comment, that would be really nice 12:27
watching Vadim's presentation from last year as a kind of training 12:48
sarna can raku strings hold arbitrary bytes or do they need to be valid utf-8? 12:53
or well, some other format..
[Coke] Strings need to be valid unicode, yes 12:58
If you need binary data, use Blob 12:59
Huh. Seems like we should refer to this on the Str class in the docs. docs.raku.org/language/unicode has some of it 13:02
Nemokosch you can do encode/decode business to get other formats into strings 13:04
[Coke] and there is encoding 'utf-c8' described on that unicode page to avoid converting the bytes. the strings have a normalization form that means some unicode doesn't *literally* round trip (example shown on that page) 13:08
Nemokosch so apparently all Raku blocks are very much like IIFE's 13:25
Anton Antonov Strings encoding and decoding is reliable source of headaches in my ZMQ based connections. 15:01
Nemokosch youtu.be/NYBc3tQEIh4?list=PL_OYHwb...mp;t=10151 15:52
"Array and Hash are containers, too"
It's a problem that not even core devs can apparently say the same thing about what a container is 15:53
lizmat, 2022.11.12 - "an Array is not a container. it is an object with containers (...) an array can be within a container, sure, but it is *not* a container" 15:56
sarna thanks! 17:21
I'm trying to use a library from perl via Inline::Perl5, and it's returning strings.. to me, these should be blobs. any way of converting these before they get decoded in raku? 17:22
(it's inflate/deflate from Compress::Zlib)
thowe Advent Calendar! Yas! drinking coffee and thinking of all the cool stuff I could do if I knew Raku better. 17:38