On Jan 13, 2006, at 14:29, Leopold Toetsch wrote:
Below are some thoughts, syntax mainly, how it could look like.
And now a bit of named arguments passing semantics.
0. Call and return are symmetric, I'll use function call here, because
it's more commonly used with named. (Arguments are passed to the
function,
which receives params)
1. Call arguments can have two zones: positional and named
1.1 Both argument zones are optional, but the order matters
1.2. Positional arguments is that what is currently specced in pdd03
i.e. a sequence of 'normal' args or :flat'tened args
1.3. Named arguments are either a pair ('name' => arg) or are flattened
out from an Hash
1.4. Arguments are strictly processed as they appear in the call
2. Function parameters can be in 4 zones: positional, positional_slurpy,
named, and named_slurpy
2.1. All 4 param zones are optional, order matters
2.2. All positional arguments are processed first, filling up:
- first all positional params
- if a slurpy array is present it gets the rest
- else if there are named params, these are filled
- if there are unprocessed positionals, an exception is thrown
- if there are unfilled positional params, which are not marked with
:optional, a param count mismatch exception is thrown
2.4. named arguments can only fill named param slots, but the procedure
is
the same
- fill all named params, or course according to their name
- if there are excess args, and a named_slurpy is present, fill it
with a Hash of unprocessed named arguments
- else if there are unprocessed args throw exception
- if there are unfilled, non-optional named params throw exception
Comments welcome,
leo