>>>>> "NC" == Nicholas Clark <[EMAIL PROTECTED]> writes:

  NC> If I've understood A6 correctly there are 6 types of argument to
  NC> subroutines: invocant, mandatory positional parameters, optional
  NC> positional parameters, optional named parameters, slurpy hash and
  NC> slurpy array.

  NC> How come there seems to be no way to specify mandatory named
  NC> parameters?  I'm not sure that *I*'d ever want to write
  NC> subroutines that insist that they are called with named
  NC> parameters, and that 1 or more named parameters are present, but
  NC> it seems slightly strange to me that there seems to be no built in
  NC> way to specify this. If people find they do want to do this,
  NC> without a built in way, surely they're either each going to roll
  NC> their own (different) ways of extending the compile time syntax,
  NC> or do it at run time and so not benefit from compile time error
  NC> detection.

apoc6:

        A hash declaration like *%named indicates that the %named hash
        should slurp up all the remaining named arguments (that is,
        those that aren't bound explicitly to a specific formal
        parameter).

that tells me that you can use named arguments to fill in the required
positional (formal) params.

and in the calling section it says:

        After the positional argument part, you may pass as many named
        pairs as you like. These may bind to any formal parameter named
        in the declaration, whether declared as positional or
        named. However, it is erroneous to simultaneously bind a
        parameter both by position and by name. Perl may (but is not
        required to) give you a warning or error about this.

so it seems you can pass only named args and if you don't pass in enough
to fill all the required positional args, it can be an error. it could
even be a compile time one since the named args canbe checked against
the names of the positional params.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class

Reply via email to