🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is still being worked out
Set by lizmat on 22 May 2021.
Xliff Sometimes when I cast a CStruct to a CPointer, I get "This REPR cannot change type" (which makes no sense, this has to exist for NativeCall to even work!) -- is there a workaround? 00:56
^^ jnthn ugexe vrurg
raydiak maybe I'm confused, but wouldn't you cast to Pointer, not CPointer? 01:18
m: use NativeCall; class C is repr<CStruct> { has uint8 $.a; }; say nativecast Pointer, C.new 01:20
camelia NativeCall::Types::Pointer<0x48dd8d0>
raydiak if I am confused, maybe you could show us a short example? 01:21
Xliff raydiak: Yes. And for some reasons, if I do exactly what you did, I will get this message. 01:29
It might have to do with the fact that the Struct in question came from C, not Raku.
raydiak I don't think coming from C should cause it, but I could be wrong. without an example to analyze and play with, we can only blindly speculate 01:33
Xliff radiak: The only example I can give you is a script written off of one of my projects. 01:47
And I ahve yet to add that to Git 01:48
raydiak the reasons I keep suggesting that you reduce your problem to a short example are: (A) you're much more likely to get help because it makes it easier to help you, (B) often in the process of cutting your big project down to a small example, you'll zero in on the problem yourself through bisection, and (C) if it's hard to reduce, it points to places where you ought to have cleaner separation between the 01:54
different parts of your project
raydiak either way, hopefully someone with more nativecall experience will chime in here eventually and have a guess as to what you're doing wrong :) 02:03
raydiak fwiw, I tried casting a CStruct returned from a native function to a Pointer and it worked as expected: gist.github.com/raydiak/1268d5e52e...17d23d37ff 02:44
tonyo Xliff: is your C returning a pointer or a struct? 03:01
moon-child is there any way to dynamically load native symbols? Or do I need to go through dlsym&co? 03:53
moon-child m: constant T = :(Int) 04:11
camelia ===SORRY!===
QAST::Block with cuid 1 has not appeared
moon-child ^^ what does that mean?
summerisle moon-child: regarding the dynamic loading of symbols, i believe it is possible - you will probably need to examine the internals of NativeCall though 04:32
kybr does Raku have a built-in regex for Rat-like things? e.g., 1.2 04:39
Xliff ftonyo: Pointer to a Struct 05:16
^^tonyo
MasterDuke kybr: i don't think so, but moritz would be a good person to ask 05:50
moon-child is it possible to export an anonymous enum? 05:51
guifa moritz: I meant in the, e.g. EXPORTHOW. Or did it get absorbed into the main grammar? 06:08
moritz I have no idea if/how one can use elements of the main grammar in your own grammars :( 07:49
Geth doc: 6b5db81263 | (JJ Merelo)++ | doc/Language/101-basics.pod6
Clarifies example, closes #3887
08:15
lizmat 🦋 Welcome to the former MAIN() IRC channel of the Raku Programming Language (raku.org). This channel has moved to Libera (irc.libera.chat #raku) 10:38
Geth doc: 92b52bb418 | (Tom Browder)++ (committed using GitHub Web editor) | doc/Language/101-basics.pod6
Update 101-basics.pod6

Added missing noun, removed unnecssary spaces around the em dash.
10:46
El_Che once the channel has moved, a bot like the one in perl is handy: it tells people that joined that the channel moved 11:13
gfldex Is this where the cool kids hang out now? 11:26
tyil correct 11:27
tbrowder thnx to all who made this move to new chat place painless! 11:56
tbrowder whoa, time travel 12:00
andinus m: say 0; 12:22
camelia 0
nine Apparently camelia is better at staying connected to the channel than I am :D 12:33
tonyo Xliff: if you want to turn a pointer to a struct you need to deref it (using a cast, not another pointer) 15:47
Xliff tonyo: NativeCall handles that automatically when dealing with C-calls. I don't think that's the issue. Working on a smaller (hah!) example. Thanks the thought. 16:41
tonyo nativecall does not autocast pointers to structs 16:50
or vice versa 16:51
seems you already know what the issue is, though. 16:53
Grinnz just fyi, depending on how much trust you have for the new freenode staff, you may want to re-evaluate *!*@freenode/staff/* having access flags on this channel 16:54
and you can talk to daemon if you want the bot from #perl to actively inform people as they join 16:56
cheers and good luck
raydiak now that we're advertising the move in our topics on freenode...when is Geth getting moved over? and should we merge github.com/Raku/raku.org/pull/164 yet? 19:18
Xliff Here is a cut-down example which can be used showing some of my problems with CStructs and CUnions. First up is the "Cannot look up attributes in a EPhotoData type object, which is strange, since it is HAS scoped, which should mean it's an instance, not a type object! 20:07
tio.run/##dZPdauMwEIWvraeYgi/akjVt...eLTocM@9oP
WT3@la7VwhqNYI0IikR85XEo8U2mOnQne2k5FosW6lLdrqBNAyrdLjqJ0HwGbO6K5UnYfZ9doofHHG5sF8Z990zUpw/61gcJoEI/jyBrZbuO3fwPU13F35ULG5Rk86GlTvuXlV02vU1UHqqNqBNtkcmEE8kpJM1tA7lcqTuNQrfQdW/cpLLNVlxHU9Inp6nCv/cPgP
Here is a cut-down example which can be used showing some of my problems with CStructs and CUnions. First up is the "Cannot look up attributes in a EPhotoData type object, which is strange, since it is HAS scoped, which should mean it's an instance, not a type object! 20:08
Prepare for a URL of obnoxious length.
tio.run/##dZPdauMwEIWvraeYgi/akjVt...eLTocM@9oP
WT3@la7VwhqNYI0IikR85XEo8U2mOnQne2k5FosW6lLdrqBNAyrdLjqJ0HwGbO6K5UnYfZ9doofHHG5sF8Z990zUpw/61gcJoEI/jyBrZbuO3fwPU13F35ULG5Rk86GlTvuXlV02vU1UHqqNqBNtkcmEE8kpJM1tA7lcqTuNQrfQdW/cpLLNVlxHU9Inp6nCv/cPgP
raydiak I'm mildly surprised that even parses with "HAS". That's not a thing, you need "has". that service is running rakudo 2018.12 20:45
raydiak nevermind, apparently it's...something. just something I haven't seen before and can't find in the docs 20:47
raydiak ah, found it. my mistake. docs.rakulang.site/language/native...s_with_HAS 20:48
raydiak Xliff: you need another proxy over data like you did with mime_type and inlined, and to run it under a modern raku instead of a 2 1/2 year old one. with the proxy it works for me on 2021.04 21:03
Xliff raydiak: Oh. You mean tio.run is using an older version? LOL! Thanks. 21:04
raydiak yes quite old. you're welcome :) 21:05
Xliff raydiak: Can you link your code? 21:07
raydiak: When you making the move to libranet?
raydiak gist.github.com/raydiak/cded4a7621...8390023ffb 21:09
I'm already there
I just copied one of your proxies, changed the names in it, and made data private. no other changes besides the indents :) 21:11
tonyo if only there was a way to shorten urls
Xliff Heee!
raydiak++
raydiak if you really want to keep using these browser things for running raku, you might try glot.io. I haven't used it much personally, but it's well-known, supposed to be stable, and has sane URLs. and looks like their raku is only 3 months old
Xliff ROFL. OK. 21:13
tonyo for one thing, that CUnion may or may not have an `inlined` variable
Xliff repl.it used to be the same, but they grew profitable and so ... 21:14
Thanks for your glot.io suggestion. I will look inti it.
raydiak sure thing, happy to help 21:15
I probably should have engaged that over here. saw it on freenode first, answered there. seems fixed by putting another Proxy over EPhotoDataInlined!data gist.github.com/raydiak/cded4a7621...8390023ffb 21:19
and running under a modern raku...tio.run is way back on 2018.12
Xliff nqp::mul_I($aa, $bb) -> "Arg count 2 doesn't equal required operand count 4 for op 'mul_I'" 23:03
Hunh?!
Geth doc: Util++ created pull request #3889:
Fixed ctest and aspell
23:08
moon-child m: my %x = %(a => <1 2 3>); .say for %x<a> 23:37
camelia (1 2 3)
moon-child ^^ why isn't the output 1␤2␤3␤ ? 23:38
m: my %x = %(a => <1 2 3>); .say for |%x<a> #this works. But why? 23:39
camelia 1
2
3