You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's the purpose of specifying something like &foo:($ --> Int) as a parameter in signatures? My understanding is so that I can specify that I only take a particular kind of routines, this way if I write &foo:($ --> Int), I know I can invoke the routine given to me as an argument with a single argument and use the result as an Int.
However, such purpose is currently not served completely. If you pass a multi routine as a Callable, even if there is a candidate that matches the specified signature, the constraint still fails:
Zoffix | m: multi foo ($) {}; multi foo () {}; -> &:() { }( &foo )
camelia | rakudo-moar 08a54212e: OUTPUT: «Constraint type check failed in binding to parameter '<anon>';
expected anonymous constraint to be met but got Sub (proto sub foo (;; Mu ...) in block <unit> at <tmp> line 1»
The text was updated successfully, but these errors were encountered:
Oh, nm, I just realized why it's not implemented this way:
m: multi foo (Int) { "fail" }; multi foo ($ --> Int) {}; multi foo () {}; -> &bar:($ --> Int) { say "{bar 42} is an Int?" }( &foo )
Above, the multi would get accepted because there is a matched sig, but there also exists an unmatched candidate and THAT candidate would actually get called inside my block, and give me a Str instead of an Int I was expecting, making the constraint pointless.
And if one does want to accept a multi with any matching candidate, a simple where .candidates».signature.any ~~ :(&bar:($ --> Int)) would do the job.
What's the purpose of specifying something like
&foo:($ --> Int)as a parameter in signatures? My understanding is so that I can specify that I only take a particular kind of routines, this way if I write&foo:($ --> Int), I know I can invoke the routine given to me as an argument with a single argument and use the result as anInt.However, such purpose is currently not served completely. If you pass a
multiroutine as aCallable, even if there is a candidate that matches the specified signature, the constraint still fails:The text was updated successfully, but these errors were encountered: