Sun Microsystems Laboratories Experimental Stuff [Fortress-interest] Some observations about the 1.0a spec

[Fortress-interest] Some observations about the 1.0a spec

Guy Steele Guy.Steele@sun.com
Thu, 04 Jan 2007 11:21:00 -0500


On Jan 3, 2007, at 1:45 PM, Jan-Willem Maessen wrote:
>
> On Jan 3, 2007, at 7:10 AM, Mike Atkinson wrote:
>
>> With a function defined as  f(a:ZZ, b:ZZ..., c:ZZ=0, d:ZZ=0)
>>
>> am I right in thinking that
>>     calling f(1,2,3,4,5,6) binds a=1, b=(2,3,4), c=5, d=6
>>     calling f(1,2,3,4) binds a=1, b=(2), c=3, d=4
>>     calling f(1,2,3) binds a=1, b=(2), c=3, d=0
>>     calling f(1,2) binds a=1, b=(2), c=0, d=0
>>     calling f(1) binds b=(), c=0, d=0
>
> Hmm, we don't give an example of mixing keywords and varargs in  
> section 12.2 of the spec, and we probably ought to fix that.

Yes, we should.  To address this particular question, though,
let me note that a plain (unlabeled) argument cannot be used
to satisfy a keyword parameter; it can only match a plain parameter
or be part of the sequence for a varargs parameter.  Therefore:

     calling f(1,2,3,4,5,6) binds a=1, b=(2,3,4,5,6), c=0, d=0
     calling f(1,2,3,4,c=5,d=6) binds a=1, b=(2,3,4), c=5, d=6
     calling f(1,2,3,4,d=5,c=6) binds a=1, b=(2,3,4), c=6, d=5
     calling f(1,2,3,4,5,d=6) binds a=1, b=(2,3,4,5), c=0, d=6
     calling f(1,2,3,4,5,c=6) binds a=1, b=(2,3,4,5), c=6, d=0

     calling f(1,2,3,4) binds a=1, b=(2,3,4), c=0, d=0
     calling f(1,2,c=3,d=4) binds a=1, b=(2), c=3, d=4

     calling f(1,2,3) binds a=1, b=(2,3), c=0, d=0
     calling f(1,2,c=3) binds a=1, b=(2), c=3, d=0
     calling f(1,2,d=3) binds a=1, b=(2), c=0, d=3

These two cases are as you said:

     calling f(1,2) binds a=1, b=(2), c=0, d=0

     calling f(1) binds b=(), c=0, d=0

Thanks for your questions, Mike!  We need to explain this
stuff better.

--Guy Steele



This page is: http://www.experimentalstuff.com/pipermail/fortress-interest/2007-January/000067.html
Last Modified: Fri, 05 Jan 2007 03:00:01 GMT
copyright (c) 2000-2007, Sun Microsystems