🦋 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.
Geth ¦ problem-solving: vrurg assigned to codesections Issue Rakudoc in third-party modules and some related topics github.com/Raku/problem-solving/issues/373 01:02
[Coke] you could remove any precomp dirs and then only used things will come back. 03:02
(which I know isn't what you were asking specificially) 03:06
rf . 03:22
Also, evening folks :)
Xliff \o 10:18
Is it possible to add aliases to a parameter at runtime? If so, how?
Here's my last attempt:
m: sub trait_mod:<is>(Parameter \p, :$aliased is required) { use nqp; $aliased.gist.say; p.^attributes[1].set_value(p, nqp::list_s) }; sub a ( :$b is aliased<bb bbb> ) { my $p = &?ROUTINE.signature.params.head; $p.^attributes[1].name.say; $p.named_names.elems.say }; a 10:19
camelia (bb bbb)
@!named_names
0
Xliff Nope.. not that one... 10:20
m: sub trait_mod:<is>(Parameter \p, :$aliased is required) { use nqp; $aliased.gist.say; p.^attributes[1].set_value(p, nqp::list_s) }; sub a ( :$b is aliased<bb bbb> ) { my $p = &?ROUTINE.signature.params.head; $p.^attributes[1].name.say; $p.named_names.elems.say }; a
camelia (bb bbb)
@!named_names
0
Xliff Maybe this one? 10:21
m: sub trait_mod:<is>(Parameter \p, :$aliased is required) { use nqp; $aliased.gist.say; p.^attributes[1].set_value(p, $aliased.List) }; sub a ( :$b is aliased<bb bbb> ) { my $p = &?ROUTINE.signature.params.head; $p.^attributes[1].name.say; $p.named_names.say }; a
camelia (bb bbb)
This type (List) does not support elems
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1

@!named_names
Xliff There it is!
lizmat Xliff: trait_mods are compile time, not runtime 10:22
m: sub trait_mod:<is>($a, :$foo!) { say "trait" }; my $a is foo; INIT say "INIT" 10:24
camelia trait
INIT
Xliff lizmat: So is there no way to assign an alias to a parameter via trait?
The current method is.... LTA
lizmat could you gist what you mean it to do *exactly* ? 10:26
Xliff lizmat: OK, I'd like to do something like this: "sub a (:$b is aliased<bb bbb>) { say $b }" which is syntactical sugar for "sub a (:bbb(:bb(:$b))) { say $b }" 12:43
lizmat wouldn't that be just setting the @!named_names attribute on the Parameter object ? 12:46
Xliff Yes, but since it's private, how can that be done?
In my example (above) I tried doing it using .set_value and it threw an error.
"This type (List) does not support elems" 12:47
lizmat nqp::bindattr(p,Parameter,'$!named_names',my str @ = <foo bar>)
Xliff Er...
nqp::bindattr(p,Parameter,'@!named_names'...) # ???
Will try that in a sec. Thanks.
lizmat yeah, it expects a native str array 12:48
Xliff WTF.... 12:49
m: sub trait_mod:<is>(Parameter \p, :$aliased is required) { use nqp; $aliased.gist.say; p.^attributes[1].set_value(p, $aliased.List) }; sub a ( :$b is aliased<bb bbb> ) { my $p = &?ROUTINE.signature.params.head; $p.^attributes[1].name.say; $p.named_names.say }
camelia (bb bbb)
Xliff It's working now!?
lizmat even better :-) 12:50
Xliff m: $*RAKU.compiler.version.say
camelia v2023.05.151.g.3.d.0.b.32228
lizmat you can lose the "use nqp" then :-)
even better still!
Xliff m: sub trait_mod:<is>(Parameter \p, :$aliased is required) { $aliased.gist.say; p.^attributes[1].set_value(p, (p.name.substr(2), |$aliased).List) }; sub a ( :$b is aliased<bb bbb> ) { my $p = &?ROUTINE.signature.params.head; $p.^attributes[1].name.say; $p.named_names.say } 12:52
camelia (bb bbb)
Xliff m: sub trait_mod:<is>(Parameter \p, :$aliased is required) { p.^attributes[1].set_value(p, (p.name.substr(2), |$aliased).List) }; sub a ( :$b is aliased<bb bbb> ) { my $p = &?ROUTINE.signature.params.head; $p.^attributes[1].name.say; $p.named_names.say }; a 12:55
camelia @!named_names
This type (List) does not support elems
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff lizmat: Nope... not calling a() ^^
lizmat try storing $aliased in a native str array, and setting that 12:56
also: less fragile would be .^attrbutes.first(*.name eq '$!named_names') ? 12:57
Xliff lizmat: Close... 13:00
m: sub trait_mod:<is>(Parameter \p, :$aliased is required) { use nqp; nqp::bindattr(p,Parameter,'@!named_names', my str @ = (p.name.substr(1), |$aliased).Array ) }; sub a ( :$b is aliased<bb bbb c> ) { my $p = &?ROUTINE.signature.params.head; $p.^attributes[1].name.say; $p.named_names.say }; a( bb => 2 )
camelia Unexpected named argument 'bb' passed
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
Xliff This works though...
m: sub trait_mod:<is>(Parameter \p, :$aliased is required) { use nqp; nqp::bindattr(p,Parameter,'@!named_names', my str @ = (p.name.substr(1), |$aliased).Array ) }; sub a ( :$b is aliased<bb bbb c> ) { my $p = &?ROUTINE.signature.params.head; $p.^attributes[1].name.say; $p.named_names.say }; a( )
camelia @!named_names
(b bb bbb c)
Xliff But only if... 13:01
m: sub trait_mod:<is>(Parameter \p, :$aliased is required) { use nqp; nqp::bindattr(p,Parameter,'@!named_names', my str @ = (p.name.substr(1), |$aliased).Array ) }; sub a ( :$b is aliased<bb bbb c> ) { my $p = &?ROUTINE.signature.params.head; $p.^attributes[1].name.say; $p.named_names.say }; a( b => 0 )
camelia @!named_names
(b bb bbb c)
dakkar oh, as we're talking about MOP and attributes: thoughts on `attributes()` vs `attribute_table()` ? 13:16
Xliff So that error is emitted in BOOTSTRAP.c - and BOOTSTRAP scares me, sooo.... 13:18
lizmat Xliff: it should :-)
fortunately, RakuAST has a completely new bootstrap 13:19
dakkar so it will be *differently* scary 😜
Xliff Looks like the aliases have already been added to where they are expected by the time my trait is run, so the extras are not known to nqp::capturenamedshash
lizmat well, then I guess you will have to wait until RakuAST :-( 13:20
Xliff Heh. And how will RakuAST fix the problem?
Looks like the problem is in nqp, and isn't nqp -before- RakuAST? 13:21
Seems like this is something the parser might be doing.
lizmat well, you should be able to change the RakuAST::Paramater object before the Parameter object is created 13:22
Xliff Ah, OK. That sounds good. 13:26
Xliff So will there be a COMPILE phase where RakuAST objects are serialized into QAST? 13:28
The best time to do what I need will be then. Would be curious to know how the tree can be exposed before that happens.
lizmat: Has that mechanism been spec'd out, yet?
lizmat Xliff: not entirely, but in my RakuAST blog posts you can see how you can walk the tree with .map 13:53
in the CHECK phaser
Xliff OK, so in my example, maybe I can just create a CHECK phaser via RakuAST and perform my modifications that way? 14:55
tbrowder__ [Coke]: i'll take you up on yr offer to find yr windows cookbook draft when you get a chance. thnx. 14:58
lizmat Xliff: that'd be the idea, yes 15:08
Xliff lizmat: OK, thanks. Do you think there will be a better access mechanism than $*CU? If I only want to change a Parameter object, it would be nice to go directly to its AST representation and work from that. 15:14
Thoughts?
lizmat Xliff: none sofar... $*CU is the only way "in" at the moment 15:15
[Coke] tbrowder__: gist.github.com/coke/f6488d106d4a5...3e69b553f5 was the WIP 15:22
Notably missing: the way I build on windows, which uses nmake & the microsoft compiler. 15:23
tg57 Does anyone know good job boards for startups that are hiring? 17:52
tonyo . 18:10
molotov Why raku crashes on this code 18:32
use NativeCall;
sub NtQuerySystemInformation() returns Pointer is native('ntdll.dll') {*};
class SYSTEM_BASIC_INFORMATION is repr('CStruct') {
tellable6 2023-06-20T20:27:37Z #raku <tonyo> molotov: what do you mean by bitfields?
molotov   ...
}
my $tempo = NtQuerySystemInformation();
my &query = nativecast(:(uint32, SYSTEM_BASIC_INFORMATION, uint32, uint32 is rw --> int32) , $tempo);
my SYSTEM_BASIC_INFORMATION $info .= new;
my uint32 $rets = 0;
my $ntstatus = query(0, $info, nativesizeof($info), $rets); #this crushes
What I miss defining parameters of NtQuerySystemInformation dynamically?
tellable6 I mean something like this 18:35
struct todo {
   uint16_t a : 1;
   uint16_t b : 15;
}
[Coke] molotov: please use a pastebin service, or github gist, etc. for multi-line code samples
molotov [Coke] I cant 18:36
molotov There's no good point in the official documentation about native call interface (I mean my trouble) 18:40
molotov Understood, nobody knows. 18:54
lizmat nobody currently online knows, indeed
tbrowder__ [Coke]: thanks for the gist 18:55
molotov miserable raku 19:00
awful documentation
lizmat molotov: it can only become better if we know what's wrong: github.com/Raku/doc/issues/new/choose 19:02
"awful" doesn't cut it 19:03
molotov lizmat damn raku! Better go back to Python. 19:07
El_Che I am sure the Python people will love his presence there 19:27
jast or it will go the other way there: "this is so much better than raku!" - "uh, what is raku" :-) 19:28
CIAvash I don't know if anybody wants, this but I created a Raku organization on Zulip(zulip.com/) to discourage use of Discord and encourage use of Libre Software. Also it is good for people working as teams on Raku projects(it also has video and voice chat). And I requested for sponsorship so that the organization gets upgraded to the "Standard" plan(one of its benefits is that you can make "streams" viewed by anyone, not just logged in users), so 19:33
they accepted my request and the plan got upgraded("Your organization's request for sponsored hosting has been approved! You have been upgraded to Zulip Cloud Standard, free of charge. :tada: If you could list Zulip as a sponsor on your website, we would really appreciate it!"). You can view the organization here(no content yet! of course), just streams: raku.zulipchat.com/
lizmat CIAvash++ 19:34
weekly: raku.zulipchat.com/
notable6 lizmat, Noted! (weekly)
jast FWIW the docs for NativeCall seem to make immediate sense to me, the only thing I couldn't find from a simple read-through is how to define c structs with bit fields, or if it's possible in the first place.
CIAvash if anyone on the core team or other teams are interested, let me know so I make you admin/...
jast (that's not a real question from me btw, I'm not doing any NativeCall things nor, in fact, any Raku things right now :)) 19:36
tonyo lol 20:32
i do know, if it doesn't just work then use the work around by either doing the thing i said or reading about how bitfield works 20:33
coleman Zulip is mindbending; it's such a unique chat paradigm 20:48
coleman The IETF uses it for some dev projects. JMAP, for one. 20:52
librasteve fwiw I think we need a more closed group with tighter moderation 20:58
(even if that means dropping Discord)
which i now voluntarily do 21:00
rf @tg57 jobs.perl.org/ 21:02
[Coke] I was spoiled by a MUD that someone wrote at my uni because everyone hated IRC. 21:12
used it for probably 20 years. (it's still in use, but because it was gated, the community shrank every few years) 21:13
coleman API looks nifty zulip.com/api/send-message 21:28
A lot of times the default/flagship GitHub integrations for these sorts of things waste too much vertical space per post (imo) 21:30
CIAVash: would you mind dialing the public visibility back on the infra stream in Zulip? Maybe just to "needs org membership" 21:34
[Coke] .seen rawley 22:09
tellable6 [Coke], I haven't seen rawley around, did you mean valley?
rf Hey [Coke] 22:39
rf === rawley
or I should say `rf eqv rawley` 22:40
coleman he mentioned you in #raku-doc, rf 22:43
rf Ah didn't auto-join that channel since my last install whoops 22:49