Argument matching
Michael O'Brien
mob at mbedthis.com
Fri May 9 11:06:14 PDT 2008
There is a problem with that.
If it is an error to provide too many actual parameters to a function
with typed formal parameters, then you either must supply the correct
number of args or not type the args.
A use case that demonstrates the problem is the Array.some callback.
Usually it is supplied with only one argument -- the element. So if a
user declares this callback with type annotations, the call will fail
as the iterator must supply 3 arguments.
So you can't have a callback with just one typed argument for the
callback. You must either have one untyped arg or 3 typed arguments.
Michael
On May 9, 2008, at 10:58 AM, David Mandelin wrote:
> Lars Hansen wrote:
>> I would expect excess arguments to typed functions to be ignored
>> silently,
>> as they can be picked up by 'arguments' inside the function.
>>
>>
> Is there any possibility of making whether a function takes extra
> arguments part of its type? It seems kind of unfortunate not to be
> able
> to report an error when too many args are given, which is a pretty
> common mistake and usually indicates a bug.
>
> Dave
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
More information about the Es4-discuss
mailing list