🦋 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 getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
tbrowder hi, all 10:13
lizmat tbrowder o/ 10:15
Nemokosch 👋 10:16
tbrowder i need to dynamically use a class' attributes. i know it can be done (moritz demoed it) but i cannot remember the syntax. say i have a class Foo with attribute a is rw, i would like to do something like my $attr = "a". my $o = Foo.new; $o.{$attr} = 5; 10:18
lizmat: hi
lizmat $o.attr = 5 10:19
m: class Foo { has $.a is rw }; my $f = Foo.new; $f.a = 42; dd $f
camelia Foo $f = Foo.new(a => 42)
tbrowder yes, that's known, but how can i have an external scalar define the attribute name and use it with the class object? 10:23
in perl one could separate the object's arrow with whitespace and use a var for the attribute name 10:24
moritz docs.raku.org/routine/get_value 10:25
also set_value
lizmat m: class A { has $.foo = 42 }; my $a = A.new; my $b = "foo"; $a."$b"() 10:26
camelia ( no output )
lizmat m: class A { has $.foo = 42 }; my $a = A.new; my $b = "foo"; say $a."$b"()
camelia 42
tbrowder i'm not explaining this very well
tbrowder ah, my george that's it! thnx! 10:27
*by
Nemokosch my george? xD
lizmat it's a euphemism for "by Jove" I believe :-) 10:27
Xliff \o
tbrowder "by george" a mild epithet
Xliff gist.github.com/Xliff/74ffdc15f4c2...49240c5e78
tbrowder yes, same as by jove 10:28
Nemokosch I think you explained it well - that is, if you really meant this $a."$b"()
this is too advanced language use for me o.O 10:29
tbrowder yes. that may be in docs but i can't find it. it is probably in one of our raku/perl books 10:30
Xliff Could someone take a look at that gist and see if I am missing something obvious which would account for the referenced error message? 10:39
TIA
lizmat Xliff: please provide a full stacktrace with the gist 10:42
Xliff --ll-exception? 10:43
lizmat yup
Xliff One sec
Done 10:44
lizmat and t/10-raw-hashtable.t ? 10:45
Xliff That's the listing in the gist. 10:46
Added a header to make that clear.
lizmat where is g_hash_table_insert defined ? 10:47
Xliff In the listing to t/10-raw-hashtable.t 10:48
It's the... 2nd sub definition
lizmat ack
Xliff :)
I made this as self-contained as possible! 10:49
My golfs tend to be an entire course. 10:50
lizmat why are you using := on the guint and gboolean definition ?
could you make that "=" ?
Xliff No particular reason. That's very old code.
Yes, I can.
Do you think that would make a difference
?
lizmat the "uint32" makes it suspect to me, as that has recently had changes 10:51
internally
Xliff Nah. No diff.
Oh, hey! My uints are actually unsigned, now! 10:54
nine++\ 10:55
lizmat { * } perhaps {*} ?
Xliff That has caught me before, but never on NC stubs. Attempting.
Nope. 10:56
lizmat then I'm out of ideas :-(
Xliff I am legit confused, because I don't know where in that code a Whatever could be injected.
I thought like you did and couldn't fix it. 10:57
It's weird because much of my other code works and they all use "{ * }"
So why these particular routines?!
lizmat: So... bug it?
lizmat guess so... it looks like a golf people could work with 10:58
tbrowder ref dynamic attr help: i think that's the last piece needed to port a very ugly Perl module to a much more attractive Raku module. thanks again, lizmat (and moritz)!
Xliff OK
tbrowder this time i did as todd does and saved it in a README keeper 10:59
Xliff #4820 11:04
lizmat yeah, just saw it coming in :-)
Xliff lizmat: Thanks for taking a look. 11:06
Now off to $dayJob.
Xliff Has anyone used raku to successfully send commands to mysql? 12:48
lizmat DBish supports MySQL, doesn't it ? 12:52
Xliff Yes, but for reasons... I need to go through the client. 13:11
I've tried using run(:in), but it doesn't seem to work. 13:12
moritz how does it not work? 14:55
MasterDuke moritz: have you seen github.com/rakudo/rakudo/pull/4807 ? 15:05
Voldenet Xliff: mysql (well, mariadb in this case) works for me ix.io/3SKU 15:10
Voldenet I needed libmysqlclient, because DB::MySQL installs just fine even without it 15:11
Xliff Voldenet++ 15:13
Ah, but that is not through the client. 15:14
No matter. I think I've worked around most of it.
Thanks for looking, though.
Voldenet Oh right, I missed the /through the client/ part
Xliff :)
moritz MasterDuke: I have, but I'm allergic to these low-level builtins, so not commenting on the PR 15:16
the part in the actions is cool though
MasterDuke ha. well, fwiw, the one commit where i really had a question is just github.com/rakudo/rakudo/pull/4807...fa2b5e4531 15:17
Voldenet Xliff: ix.io/3SKY actually it wasn't that complicated fortunately 15:25
i'm sure it'd be even better with –defaults-file instead of stdin password 15:28
(i just wrote this for the sake of finishing what I started)
btw, I'm quite surprised that this way of providing password works, I wouldn't have expected that 15:35
Xliff Voldenet: Huh! And here I was using run()! 16:44
Xliff So. 17:23
It turns out that if you have a NativeCall stub ala: sub malloc (uint64 $size) returns pointer is native { * }
You CANNOT use &malloc as a function pointer. 17:24
Not directly. It must be surrounded by an anonymous sub.
Otherwise Rakudo will used the subs defined block, and ignore the NativeCall traits.
This is the root cause of #4820