Em Ter, 2009-01-06 às 11:28 -0800, Jon Lang escreveu:
> Of course, that's only a third of the problem.  What should people
> expect with each of these:

Hmm... I think that takes the discussion to another level, and the
question is:

 "what does a capture returns when coerced to a context it doesn't
provide a value for?"

The easy answer would be undef, empty array and empty hash, but that
doesn't DWIM at all.

The hard answer is DWIM, and that can be:

 1) in item context, without an invocant
   a) if only one positional argument, return it
   b) if only one named argument, return it as a pair
   c) if several positional args, but no named args,
      return an array
   d) if several named args, but no positional args,
      return a hash
   e) if no args at all, return undefined Object
   f) return itself otherwise
 2) in list context, without positional arguments
   a) if one or more named arguments,
      return a list of pairs
   b) return an empty list otherwise
 3) in hash context, without named arguments
   a) if there are positional arguments,
      return a hash taking key,value.
      if an odd number of positional arguments,
      last key has an undef Object as the
      value and issue a warning.
   c) return an empty hash otherwise


Reply via email to