On a related note:

Suppose I have a function with a non-obvious arity: I might, in a desperate attempt to find billable hours, describe the arity as a trait:

 sub sandwich($bread, $meat, $cheese, $condiment1, $qty1, ...)
     does arity ({ 3 + 2 * any(1..Inf); });

That's <cough>easy enough for trivial cases like this, but is there a way to use C<assuming> for the more difficult cases?

Specifically, and obviously, printf-and-friends:

 my &example := &printf.assuming(format => "%s %s %n\n");
 say &example.arity();

The obvious output is any(1..Inf), since who's going to code the arity function?

But:

1. Is it possible to code an arity trait as a run-time block? (I assume yes)

2. Could this, or any, trait take advantage of assumed parameters? If so, how?

(Of course, after the arity function is written, it seems obvious to die unless the current function's arity is le the number of arguments...)

=Austin



Reply via email to