Skip to content

Commit f01cb30

Browse files
committed
[S06] remove fossil
this complements 25eb879: we no longer map named arguments to positional parameters.
1 parent fe8d383 commit f01cb30

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

S06-routines.pod

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,60 +1091,6 @@ Bindings logically happen in declaration order, not call order, so
10911091
any default may reliably depend on formal parameters to its left in
10921092
the signature.
10931093

1094-
Another benefit of this policy is that, for routines that allow it,
1095-
named arguments may be bound to positional parameters. (This is
1096-
allowed only on routines that are I<explicitly> declared with either
1097-
the C<proto> or the C<only> declarator.) If the first positional
1098-
parameter is named C<$a>, for example, it will bind to a C<:a()>
1099-
argument in preference to the first positional argument.
1100-
1101-
The restriction to explicit C<proto> and C<only> declarations is
1102-
motivated by the desire for both API purity and efficiency. Normal
1103-
C<multi> or C<sub> declarations and normal method declarations do not
1104-
attempt to look for named bindings to positionals. At most there is
1105-
one such binding for any dispatch, when it initially calls the C<proto>
1106-
(or explicit C<only>). The C<proto> binder (for either sub or method)
1107-
must automatically remap such named parameters to positionals before
1108-
calling its internal multi dispatcher (the one represented by C<{*}>).
1109-
In the case of a C<proto> sub, this mapping can be done at the point
1110-
of the call, since there can only be one possible set of positional
1111-
names, and the proto to be called can be known at compile time (in
1112-
the absence of CANDO declarations in the outer scopes). So after
1113-
1114-
proto foo ($x, $y, :$bar, :$baz) {*}
1115-
multi foo ($a, $b, :$bar, :$baz) {...}
1116-
multi foo ($n, $m, :$bar, :$baz) {...}
1117-
1118-
foo :y(2), :x(1); # can turn into foo(1,2)
1119-
1120-
the call to C<foo> can be turned into a pure positional call to
1121-
the C<proto> (which can in turn be inlined because it's using the
1122-
standard C<{*}> dispatcher--and likewise for methods, when the class
1123-
containing the C<proto> is known to be finalizable). Note also that
1124-
multi definitions are never required to use the same parameter names
1125-
for positional parameters, since after the C<proto> binding is done,
1126-
the names (if any) are never used again for positionals.
1127-
1128-
The C<$x> and C<$y> names above are part of the public API only
1129-
because they are named in the C<proto>. Positional parameter names
1130-
are never part of the advertised API unless explicitly enabled.
1131-
An explicit C<proto> may easily refrain from advertising names by
1132-
declaring positionals with bare sigils:
1133-
1134-
proto foo ($, $, :$bar, :$baz) {*}
1135-
multi foo ($x, $y, :$bar, :$baz) {...}
1136-
1137-
foo :x(1), :y(2); # illegal
1138-
1139-
(And an C<only> routine may control the positional API simply by
1140-
using C<sub> instead, or by defining a C<proto> with a single C<multi>
1141-
if finer control is desired.)
1142-
1143-
It follows from all this that an intuited proto never has to worry
1144-
about supplying the API names of positional parameters. And no proto
1145-
ever has to worry about conflicting names in the positionals of the
1146-
multis they dispatch to, since any remapping is handled before that.
1147-
11481094
=head2 List parameters
11491095

11501096
List parameters capture a variable length list of data. They're used

0 commit comments

Comments
 (0)