| Sun Microsystems Laboratories Experimental Stuff | [Fortress-interest] Some observations about the 1.0a spec |
> 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
> ?
Not quite. In Section 12.1 Function Declarations, we say that "When
an argument is passed explicitly for a keyword parameter, that
argument must be passed as a keyword argument." In Section 12.2
Function Applications, we say that "..., the parameter named by the
identifier in the varargs binding is bound to a HeapSequence[\T\]
that contains, in order, all the values of the tuple that did not
correspond to plain bindings, followed by all the values in the
varargs HeapSequence of the tuple, if any."
Therefore,
calling f(1, 2, 3, 4, 5, 6) binds a=1, b=HeapSequence[\ZZ\](2,
3, 4, 5, 6), c=0, d=0
calling f(1, 2, 3, 4) binds a=1, b=HeapSequence[\ZZ\](2, 3, 4),
c=0, d=0
...
calling f(1) binds a=1, b=HeapSequence[\ZZ\](), c=0, d=0
calling f(1, 2, 3, 4, c=5, d=6) binds a=1, b=HeapSequence[\ZZ\]
(2, 3, 4), c=5, d=6
calling f(1, 2, 3, 4, c=5) binds a=1, b=HeapSequence[\ZZ\](2, 3,
4), c=5, d=0
Section 40.3 describes the trait Fortress.Core.HeapSequence.
Thank you for your comments hope this helps.
--
Sukyoung
|
This page is: http://www.experimentalstuff.com/pipermail/fortress-interest/2007-January/000066.html Last Modified: Tue, 09 Jan 2007 15:48:01 GMT copyright (c) 2000-2007, Sun Microsystems |