🦋 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.
Poohmaan Hello all 03:41
reduce &add, 50, |1..10
How can we write it in the form 1..10.reduce(-> $a & add, 30, $a) or something similar 03:42
Where sub add($a, $b) {return $a+$b} 03:43
The first syntax works and gives me 85 with 30 as the initial value 03:44
tonyo m: say [+] 50,|(1..100); # Poohmaan 03:47
camelia 5100
tellable6 2023-06-03T17:08:55Z #raku <uzl[m]> tonyo Minor PR for adding Rakudoc: github.com/tony-o/perl6-csv-parser/pull/22
tonyo will take a look in the morning uzl[m]
SmokeMachine If someone got interested in my last idea, I just created a repo with that (github.com/FCO/RakuAST-Matcher). Still very early stages. I'd love to have some more critics and advices from people with more experience with RakuAST (lizmat ?). And I'd like to know if someone thinks something like that would be useful/make sense... Thank you! 04:52
Voldenet impressive but can't `visit` method on RakuAST::Node be used for this matching? 05:06
this one github.com/rakudo/rakudo/blob/main...kumod#L181 05:07
perhaps it'd save you from implementing match method for every node type 05:10
Xliff Is there a raku equivalent for Python's accumulate? 05:39
Voldenet Xliff: .produce 05:44
Xliff Voldenet++ 05:54
Hmmm.... repl.it doesn't have it. 05:55
Oh good lord! 2021.07! 05:56
Um... not in 2023.05, either? 05:57
v6.3?
v6.e, even?
Xliff \o 10:23
Does anyone have any clue as to how well NativeCall supports C++? I'm more worried about symbol mangling than anything else. 10:24
How well would a C++ class translate to Raku?
moritz afaic symbol manging is compiler specific 10:32
so you'd have to ask "how well does nativecall support c++ compiled with $specific-compiler" 10:33
Xliff And that would be gcc 10:39
Or "whatever the Linux version of UE5 is compiled with" 10:40
Xliff moritz: I guess a better question would be: How do I write NativeCall sub definitions for C++ method calls? 10:43
Especially constructors and destructors...
SmokeMachine Voldenet: do you mean using visit instead of the multiple match methods? 13:55
Xliff \o 17:01
SmokeMachine: Why not use .find-nodes?
m: use experimental :rakuast; my $ast = q«my $a = 42; say $a; class A { has $.a; method a ($a, $b) { say $a + $b }; }; ».AST; $ast.find-nodes( RakuAST::Var::Lexical, condition => *.name.substr(1) eq "b" ).gist.say 17:02
camelia (RakuAST::Var::Lexical.new("\$b"))
SmokeMachine Xliff: I think that’s harder than doing `ast-matcher(“$b”).search: $ast` 17:04
Xliff: but you could also use find-nodes like: $ast.find-nodes: RakuAST::Node, :condition{ match ‘$b’, $_ }`… in theory 17:09
Xliff: but my plan is to make it like a “grammar” for ast
Xliff SmokeMachine: So you want to make a more concise interface for it? 17:11
I've looked at the code, you look to be reinventing the wheel with all of the match methods.
Also, you are using a results object named Match, which will get confused with the regex Match. You might want to consider a name less prone to confusion. 17:12
SmokeMachine Xliff: I probably am… I just tried to write it in a easy way as a PoC. 17:13
Xliff Fair enough! Good luck!
SmokeMachine They are called RakuAST::Match, but yes… it may be better to rename it… any suggestion? 17:14
Xliff That's unique enough.
RakuAST::Match !~~ Match 17:15
You might want to make it RakuASTMatch
Just so there's no conflict with the shortname. You might get P6M errors otherwise.
SmokeMachine That makes sense, and also because that’s NOT a RakuAST node… 17:16
Xliff Yup.
SmokeMachine I’m planning to suggest lizmat to add something like that to rak to make it able to search by ast nodes… so, one could do: `rak <parameters> ‘my-func(1, ANYTHING)’` and that would search all files that calls function ‘my-func’ passing as arguments: 1 and anything. And that would not need to handle different formats… 17:21
Xliff ^^
(But it still needs a lot of work to be useful for anything…) 17:22
Xliff SmokeMachine: Why would rak need such a thing? 17:44
I am just wondering about a real-life use case is all. 17:45
At any rate, I have to take a nap. BBIAB
SmokeMachine I keep doing stuff like: rak ‘/sub\s+my-func/ 17:51
It would be great to do that like: rak ‘sub my-func (ANYTHING) {ANYTHING}’ to find implementation of &my-func 17:52
leont Xliff: yeah name mangling is not very portable, but in practice there are only two variants that matter (gcc and msvc) 19:23
Xliff OMGIBLOGED! - gist.github.com/Xliff/c6e5b7fb9fe5...9d2c7312ee 21:11
weekly, gist.github.com/Xliff/c6e5b7fb9fe5...9d2c7312ee
weekly: gist.github.com/Xliff/c6e5b7fb9fe5...9d2c7312ee 21:12
notable6 Xliff, Noted! (weekly)