🦋 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.
SmokeMachine usercontent.irccloud-cdn.com/file/.../image.png 00:52
SmokeMachine github.com/FCO/ASTQuery 00:52
librasteve o/ is there an idiomatic way to declare alias(es) with has? 11:44
SmokeMachine how do you want to use that alias? on constructor? If that's the case, maybe something like this? 11:52
SmokeMachine m: class C { has $.a; method TWEAK(:$b, |) { $!a = $b } }; say C.new: :42b 11:52
camelia C.new(a => 42)
SmokeMachine librasteve: ☝️ 11:54
librasteve thanks for the fb - not really ... I had in mind something like has $.s($.server); 11:55
on the has declaration
lizmat librasteve this recently came up in one of leont's issues 11:56
librasteve I know (from the docs), I can go 11:57
class EncodedBuffer { has $.enc; has $.data; submethod BUILD(:encoding(:$!enc), :$!data) { } }
docs.raku.org/language/objects#Attributes 11:58
I can go with that for now
actually just gonna tie it close to where I need the abbreviation 12:00
my $s := $.server; my $proc = Proc::Async.new: :w, qqw|ssh -p {$s.port} -tt -i {$s.key-path} {$s.login}|; 12:01
(spose I could use a topicalizer)
lizmat librasteve I was thinking of syntax such as: has $.foo is built(:as<bar>) 12:15
librasteve okaaay 12:18
sub alias-named(:color(:$colour), :type(:class($kind))) {} 12:19
lizmat has $.foo is built(:as<bar baz>) perhaps?
librasteve what about something more like Capture syntax?
has $.foo is built is aliased(:bar(:baz($))); 12:22
anyway I don't really mind an I know that syntax is hard ... so leave it to you 12:24
(ie I trust your judgement)
knarkhov Hi, friends! I'm struggling with NativeCall. On C-side I have a function with FILE input arg: int process(FILE *filehandle) {...}. On Raku side I opened a filehandle via IO::Handle and now it's a problem to pass to native C-function. Any help is very appreciated. 14:01
knarkhov All good if I use a wrapper on C-side: int wrap_process(char *filename) { ... fp = fopen(fname, "r"); process(fp); ... }, but I need that stuff on Raku-side cause of external C-library 14:04
antononcube @kharkov Do you have a gist (or pastebin) with that code? 14:07
@kharkov I find / found the NativeCall Raku packages by Itsuki Toyota very instructive. For example, see: github.com/titsuki/raku-Algorithm-KdTree 14:09
... aka @titsuki ... 14:10
knarkhov in my case, as I can imagine, FILE is actually a struct in C, so I have to define it as a CStruct class, map IO::Handle to it somehow and then get a pointer via nativecast. 14:14
antononcube See the "Algorithm::KdTree" linked above -- it does C-structs and corresponding accessor functions in Raku. 14:16
knarkhov here's the module: gitlab.com/pheix/raku-node-ethereu...ZG.rakumod 14:19
antononcube @kharkhov I can take a closer look after 4-5 hours... 14:22
knarkhov it will be great! Thank you! I will post and update if I will get it working. 14:23
ugexe you could pass the file descriptor 14:31
i dunno if that is ideal or not 14:32
my $handle = "foo/bar/baz".IO.open; $handle.native-descriptor
knarkhov @ugexe, that was what I have tried in the beginning and got segfault. The problem is that C-func expects *FILE as pointer, but .native-descriptor gives int, so I have to "pack" to CArray and get a Pointer from it (similar to & in C): my $fhptr = nativecast(Pointer, CArray[int64].new($fh.native-descriptor)); 14:42
but that gives segfault as well((((
antononcube @kharkhov Sorry for advicing methodology instead of giving concrete code... But if you have IntelliJ's CLion you can use it together with the plugin comma-2.0. CLion has linter(s) built-in and can give you hints where the C-code might fail. 15:04
The C-code in your GitLab repository is simple, but still, CLion-with-Comma might be useful. 15:05
knarkhov honestly, I have just noticed - my $fhptr = nativecast(Pointer, CArray[int64].new($fh.native-descriptor)); works 1/10 times - I got my test passed at some moment: gitlab.com/pheix/raku-node-ethereu...189938968. So the approach with .native-descripto works, but bug is still there, I'm investigating... Thank you, I will ping you back on my new findings. 15:20
librasteve hi folks - I'm off to the London Perl Raku Workshop tomorrow and the number of raku presentations is much lower than the number of perl ones ... act.yapc.eu/lpw2024/schedule?day=2024-10-26 15:35
Please let me know if there is anything I should consider conveying to the wider perl / raku community ... I guess I will try to major on 6.e progress wrt to RakuAST is anyone asks how Raku is progressing... 15:37
knarkhov @ugexe, @antononcube, I got it working, 100x load/free are passed well: gitlab.com/pheix/raku-node-ethereu...8068#L458. The changes I've done: just opened file in bin mode on Raku side, slurp all its content to CArray, did CArray to Pointer nativecast and voala - it worked! Here's the diff: gitlab.com/pheix/raku-node-ethereu...18a8_31_30 15:54
librasteve antononcube: looks like there will be a BOF session on data science, I would like to mention your LLM and DataSet work to the attendees - do you have a good "index" page fof me to share? 16:20
ab5tract knarkhov: I think Xliff reported experiencing difficulties with arrays allocated in Raku which went away when using C-allocated arrays 16:23
antononcube @librasteve Let me think -- I should have something like that. (But lately, I have been more active making Raku-related movies, not som much posts.) 16:42
@librasteve When do you need this slide/page? Today or, say, by the end of the week?
librasteve cool - the session is tomorrow (Sat) UK time
don't make anything new (unless you want) ... even a "search google antononcube raku llm" would be cool 16:43
antononcube Agh, ok. I will make a initial version today. It is probably going to be based on some answers I gave on Reddit/r/rakulang.
Well. Raku RAG is pretty new and important. Same with Sparse Matrices (with named rows and columns.) 16:44
(This week, I have been working on a presentation for latter, BTW.) 16:45
librasteve thanks! 16:46
SmokeMachine I had a talk scheduled for tomorrow, but I won’t be able to do it… sorry, 1 less Raku talk… (but that would not be a good one anyway…) 22:38