On Mon, Nov 07, 2005 at 09:51:39PM +0100, Juerd wrote:
: Or let's take this simple example:
:
: sub convert (:$from, :$to, :$thing) { ... }
:
: That isn't quite "my %args = @_;". Yes, that works, but the only real
: way we keep doing it is that the full solution sucks in plain Perl 5:
:
: sub convert {
: croak "..." if (@_ % 2) != 0;
: my %args = @_;
: croak "..." if not exists $args{from};
: croak "..." if not exists $args{to};
: croak "..." if not exists $args{thing};
: my $from = delete $args{from};
: my $to = delete $args{to};
: my $thing = delete $args{thing};
: croak "..." if keys %args;
: ...
: }
:
: before you shout that I'm doing something wrong, yeah, I've been out of
: this game for a while. Which only strengthens my point: it's hard to do
: it right in Perl 5!
Okay, I won't shout (not even on PerlMonks :-), but named parameters
default to optional, so you'd have to write that as
sub convert (:$from!, :$to!, :$thing!) { ... }
in the current scheme of things.
Larry