🦋 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.
xinming !pastebin 10:28
Any pastebin recommended?
l.perl.bot/p/pd97cl <--- In this script 10:31
When I do `raku script.raku test 5` It'll raise error 10:32
Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏test' (indicated by ⏏) in block <unit> at raku-main-to-clarify.raku line 3
But it works fine in multi sub calls. 10:33
Xliff xinming: That's because "test" is not a number 11:05
And this is the problem. The coercive multi is used when there is a better option available. 11:06
The 2nd multi is getting chosen, instead of the first.
And Real() wants to convert "test" to a number. 11:07
librasteve so I guess Real() [shorthand for Real(Any)] checks for Any at dispatch time and this multi is chosen as Any is less restrictive than the literal Str 'test' [shorthand for Str $ where * ~~ 'test'] ... 12:22
anyway, you can see from 12:28
dd $arg; #NumStr.new(15e0, "15e0") 12:29
you are getting a Real anyway since Allomorph NumStr ~~ Real (so no need to use a coercion type) 12:30
it takes a bit of getting used to that raku has all three tools in the box (i) operators just coerce anyway (1 + '2') = 3, (ii) Allomorphs are bridged types that are both Real and Stringy and (iii) there are now (since a year or two) coercion types to ring all the changes in your signatures and declarations. 12:34
Xliff librasteve: But isn't it supposed to move from most -> less restrictive? 13:22
librasteve dang my theory falls to the ground! 13:45
so the questions remains why is the Real()coercion type preferred over the Str literal 'test' 13:46
lizmat the problem is the implicit Any in the Real() coercion 13:47
this means that "test" is not immediately disqualified as a value to match the second candidate
so it tries to coerce the value to a Real, and that fails 13:48
one could argue that that should disqualify the candidate
and it wouldn't need to coerce, where it not for the "where" clause 13:49
the <= forces the coercion 13:50
Real() $arg where { try 10 <= $_ < 20 } 13:51
fixes that execution error 13:52
and make the script DWIM
xinming ^^
so it's not actually the "And Real() wants to convert "test" to a number.", but the where clause that causes the error 13:53
librasteve so presumably, the dispatch logic doesn't know if one where clause will beat another, so the first where that matches wins?? 13:54
(after getting trapped at the type check)
lizmat that is basically the gist, yes
there is no way to see which "where" clause would be tighter than aother 13:55
librasteve til
lizmat at least, not currently
librasteve (good luck with that)
;-)
lizmat well, you could envision a where block returning some special "Tightness" indicator 13:56
librasteve think I prefer it as first one checked wins 13:57
lizmat and that follows the order of the candidates in source, so you can tweak stuff that way as well 13:58
afk& 14:00
Xliff librasteve: Actually, I thought the candidates were sorted by "tightness" and first-one-wins was the law of the land. 14:55
librasteve i guess i am thinking of a case like where 0 < $_ < 10 vs. where 2 < $_ < 8 ... since this has ambiguity coded in (and I can imagine far more convoluted variants with eg runtime variables, iterated values as comparisons) then I am mentally separating the type check as a guard (where you are right, tightness wins) vs. running the where clause and backtracking if the where result is False (where the where clauses 14:59
(for the same type) are run in source code order)
melezhik o/ 18:18
What’s up 18:19
coleman hello there 18:29
jdv cna zef install stuff in parallel? 19:33
*can
ugexe It could but CURI holds a lock on install so there isn’t a point 19:38
it does fetch and extract in parallel though
There is —test-degree which defaults to 1 but can be set higher for parallel testing as well 19:39
tonyo is there no longer an issue with the precomp race? 21:05