I guess the answer is to use a truncating filter on the argument.
On 2011-05-10, at 9:27 AM, Jim Laskey wrote:
> Currently we get an "java.lang.IllegalArgumentException: Array is not of
> length n" error if the array being passed in does not match the array length
> supplied on the asSpreader call. But wouldn't a dynamic language want some
> flexibility there.
>
> ex.
>
> Suppose a language implementation chose 8 as the maximum number of args to be
> passed directly and any call over 8 arguments is passed as an array. (All in
> the name of dispatch implementation simplicity.)
>
> def f(x, y) { ...}
>
> f(1); // one short but can be padded with
> null or undef.
> f(1, 2); // correct number of args.
> f(1, 2, 3); // one too many, just truncate.
> f(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // passed as an fixed size array,
> need to spread over two args.
> f(1, 2 | x); // passed as a variable sized array,
> need to spread over two args.
>
> In the last two cases we really don't know what size may be fired at us based
> on call site info. All we really care about is the first two value and then
> discard the rest.
>
> a) Is the asSpread runtime check too restrictive?
> OR
> b) Is anyone aware of a clever little trick to spread and truncate on the fly?
>
> Cheers,
>
> -- Jim
>
> _______________________________________________
> mlvm-dev mailing list
> [email protected]
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
_______________________________________________
mlvm-dev mailing list
[email protected]
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev