in reply to named arguments

Regarding the style, what's wrong with just using plain lowercase words? I personally don't like the Tk style; I just do my_sub(name => 'bob', color => 'blue', flavor => 'cherry'). Can the names clash with symbols if you use the double arrow operator? I haven't had any problems; the double arrow stringifies the word on its left.

Replies are listed 'Best First'.
Re^2: named arguments
by Beechbone (Friar) on Nov 24, 2004 at 13:34 UTC
    I designed the named parameters to start with a '-' in our current project---biggest mistake I could make.

    sub foo { my ($self, $params) = __params({ -a => '...', }, \@_); ... if ($params->{a}) {
    You see the mistake above? Happend all the time, until I was forced to add this to __params():

    foreach my $key (keys %$result) { my $tkey = $key; $tkey =~ s/^-//; $result->{$tkey} = $result->{$key}; } return $result; }

    Search, Ask, Know