🦋 Welcome to the IRC channel of the core developers of the Raku Programming Language (raku.org #rakulang). This channel is logged for the purpose of history keeping about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Logs available at irclogs.raku.org/raku-dev/live.html | For MoarVM see #moarvm
Set by lizmat on 8 June 2022.
gfldex lizmat: Did you spend braintime on how RakuAST macros could interact with POD? 08:07
lizmat yes, I've set up things in such a way that RakuDoc nodes can be part of a statementlist 08:35
and as such are RakuAST nodes like any other RakuAST node
lizmat nine vrurg it looks like I hit a snag with doc parsing that could be solved by *always* loading the core.c setting 11:00
wasn't there another reason to want to do that ? 11:01
nine It would be a simplification and we are always going to load that anyway 11:04
lizmat ok, then I will continue on that premise 11:06
it will only block parsing pod only files for now 11:07
as it won't see some methods in the augmented RakuAST::Doc::Block class
yet
BTW, I have given up on making the RakuDoc parsing a slang 11:08
should someone grok slangs in the future, it would be relatively easy to make it one again 11:09
lizmat progress! +2 -4 :-) 12:40
[TuxCM] Rakudo v2023.04-15-g1f010bd8a (v6.d) on MoarVM 2023.04-1-g965be0af5
csv-ip5xs0.818 - 0.827
csv-ip5xs-205.062 - 5.538
csv-parser3.479 - 3.603
csv-test-xs-200.378 - 0.381
test6.250 - 7.498
test-t1.356 - 1.387
test-t --race0.845 - 0.873
test-t-2020.573 - 21.362
test-t-20 --race6.272 - 6.433
13:22
If I have a named argument to a method «method foo (@kh)», how can I check in the code if it was passed (I expect it to be empty if given) 13:24
vrurg lizmat: don't forget that when it comes to compiling the core itself there will be no setting to load. I mean, the pre-loading code should not be hard to get around. 13:25
tellable6 2023-04-27T01:58:59Z #raku <Xliff> vrurg I was the one behind the initial implementation, but the one that made it into main is nine's.
2023-04-27T01:59:48Z #raku <Xliff> vrurg To my knowledge, the only way to limit the number of jobs is logic left at the application level.
2023-04-27T02:01:37Z #raku <Xliff> vrurg See my parallel compilation runner, here - github.com/Xliff/p6-GtkPlus/blob/m...d.pl6#L124
vrurg [TuxCM]: I use something like `sub foo(*%p) { %p<named>:exists }` 13:26
[TuxCM]: methods has default slurpy %_, but I avoid using it in big code for readability. 13:27
[TuxCM] looks like exactly this: github.com/rakudo/rakudo/issues/2483 13:34
vrurg I use a similar approach sometimes: 'my class NOT-SET {};` or, sometimes, `my class NOT-SET is Nil {}`. 13:37
This is when the value is not supposed to escape its lexical scope. 13:38
[TuxCM] in my current case the method where I want this is a few levels deep, and using what you (and Liz) suggest will cause noise 13:40
vrurg What kind of noise? 13:44
m: sub foo(Int $a = 0 but my role NOT-SET {}) { say ($a ~~ NOT-SET ?? "NOT " !! ""), "PASSED ", $a; } foo; foo(0);
camelia ===SORRY!=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> T-SET ?? "NOT " !! ""), "PASSED ", $a; }⏏ foo; foo(0);
expecting any of:
infix
infix stop…
vrurg m: sub foo(Int $a = 0 but my role NOT-SET {}) { say ($a ~~ NOT-SET ?? "NOT " !! ""), "PASSED ", $a; }; foo; foo(0);
camelia NOT PASSED 0
PASSED 0
[TuxCM] github.com/Tux/CSV/commit/0a7f83f3...45a7cb2aa4 - See line 1576 14:03
Noise meaning I have to do the NOT-SET role stuff on all levels
vrurg I don't get what you want to achieve in there. Find out if @kv was passed in? BTW, what if the role has a method is-default? Then you could do $param.?is-default. A little bit costly, but if not used in a hot path then it'd be OK. 14:08
nine Of course the other way to do this is just turn it into two multi candidates, one with that (mandatory) argument, the other without. If you're in the one with argument, you know that it's been provided 14:54
That should give you the highest performing solution
[TuxCM] nine, I thought about that, but with 5 optional parameters, that would be 32 variations 15:36
in this case, I want the default for $out depend on the fact that @kh was actually given as arg 15:37
[TuxCM] And the NOT-SET role breaks all other signatures down the line, as the type suddenly is Array+{Text::CSV::NOT-SET} instead of Array 16:04
Voldenet > If I have a named argument to a method «method foo (@kh)», how can I check in the code if it was passed (I expect it to be empty if given) 16:42
m: sub foo (:@kh = Empty) { @kh.defined.say }; foo(:kh(^10)); foo()
camelia True
False
Voldenet maybe I'm oversimplifying the question 16:44
lizmat m: my class NOT-SET { }; sub a(:$a = NOT-SET) { say "not set" if $a ~~ NOT-SET }; a(:a(Empty)) 16:47
camelia ( no output )
lizmat basically, use a sentinel value and check for that
m: sub NOT-SET { state $ = Any.new }; sub a(:$a = NOT-SET) { say "not set" if $a<> =:= NOT-SET }; a(:a) 16:51
camelia ( no output ) 16:52
lizmat m: sub NOT-SET { state $ = Any.new }; sub a(:$a = NOT-SET) { say "not set" if $a<> =:= NOT-SET }; a
camelia not set
Geth rakudo/main: 70dc3c8a6b | (Elizabeth Mattijsen)++ | src/core.c/Nil.pm6
Nil.Int should coerce to 0, not to ""
17:18
gfldex m: sub foo(|c(:$named)) { dd c.hash<named>:exists; }; foo(:named);foo(); 19:19
camelia Bool::True
Bool::False
19:20
gfldex [TuxCM]: if you are willing to add a Capture (and thus a subsig), you can reason at runtime about the argument list. 19:20
Geth rakudo/main: 14fed334ed | (Stefan Seifert)++ | src/Raku/ast/signature.rakumod
RakuAST: fix bound parameters being writable all the time

Makes my :($a) := \(3); $a++; die as it should.
19:22
vrurg [Tux]: It's a good advise from gfldex too, though might be somewhat slowish for an often times called routine. Yet, I don't see how an Array+{Role} type can break with other signatures? It's still is an Array, a Positional. 20:05