Re: Ignoring parameters
by John Siracusa other posts by this author
Jun 16 2005 2:19PM messages near this date
Re: Ignoring parameters
|
Re: Ignoring parameters
On 6/16/05, Damian Conway <damian@[...].org> wrote:
> And I think that subs and methods *should* complain about all unused
> non-optional parameters *except* invocants.
This brings up something I've been thinking about. I sometimes write a
method in Perl 5 that does something or other and then calls the superclass
method of the same name, passing all arguments. Or sometimes I pull off an
argument or two that only make sense to my method, leaving the rest for the
superclass method. This is all easy when args are just items in the @_
array.
Here are some Perl 5 examples:
# Do something then proceed with call "as usual"
sub foo
{
$_[0]-> do_something_new(123, 'abc');
shift-> SUPER::foo(@_);
}
# Pull off some args, do something, then proceed with call "as usual"
sub foo
{
my($self, %args) = @_;
$self-> do_something_else(val => delete $args{'xyz'});
$self-> SUPER::foo(%args);
}
Note that in both cases my foo() method doesn't know or care what
SUPER::foo()'s arguments are.
Now in Perl 6 I'll want to use fancy named parameters and so on, but I don't
want to lose the abilities described above. How would those examples look
in "native" Perl 6 code? (i.e., Without forcing all methods to have a
single slurpy *@args argument, emulating the Perl 5 mechanisms.)
-John
Thread:
Gaal Yahas
Luke Palmer
John Siracusa
Damian Conway
John Siracusa
David Storrs
Matthew Zimmerman
Juerd
Matthew Zimmerman
Damian Conway
David Storrs
Juerd
Kurt
Jonathan Scott Duff
Juerd
Juerd
Kurt
Juerd
John Siracusa
John Siracusa
Adam Kennedy
Juerd
John Siracusa
Adam Kennedy
John Siracusa
Darren Duncan
John Siracusa
Juerd
Juerd
Darren Duncan
John Siracusa
John Siracusa
John Siracusa
Damian Conway
Abhijit Mahabal
Damian Conway
Patrick R. Michaud
John Siracusa
Larry Wall
Gaal Yahas
Damian Conway
Patrick R. Michaud
Damian Conway
Patrick R. Michaud
Larry Wall
Patrick R. Michaud
"TSa (Thomas Sandlaß)"
Larry Wall
|