[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: A common base exception object for Perl - RFC
Larry Wall wrote:
> The trouble is that the - is really redundant with the =>. I've been
> thinking for a long time that there ought to be a way to determine
> whether a given argument in a list was followed by a => rather than a
> comma. Then you could write a subroutine that processes an arbitrary
> list of single arguments followed by an arbitrary list of paired
> arguments. Or a prototype of % could guarantee that you don't get out
> of sync. (At the moment, a prototype of % is treated just like @.)
This would be a good usage for the % template. How would the separation
between initial-list and trailing-key-value-pair-list be implemented in
the called subroutine? The latter could end up in C<%_>, I suppose, if I
actually /want/ a hash in my subroutine, but what if I wish to avoid
that overhead? How could a key-value pair be identified in C<@_>?
Especially as whatever is done must be backwards compatible.
I suppose a single-initial-optional-scalar could be an indirect object:
sub foo ($?%) {
my ($text, @options)=@_; # or ($text, %options)
}
foo bar=>'baz'; # $text undefined in foo
foo 'plinth' architrave=>1, elf=>'split';
Pete
--
use Disclaimer::Standard;
my $phone='+44 1793 564450'; # "THIS IS THE COMPATIBILITY
my $fax='+44 1793 566918'; # POLICE. RESTORE YOUR ORIGINAL
my $mobile='+44 7973 725120'; # TOKE.C AND BACK AWAY SLOWLY."
- References to:
-
Larry Wall <larry@wall.org>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]