develooper Front page | perl.perl6.language | Postings from June 2005

Ignoring parameters

Thread Next
Gaal Yahas
June 16, 2005 08:56
Ignoring parameters
Message ID:
Say I have a class method in FooClass, callable as FooClass.greet():

     method greet(Class $class: ) {
     	say "Hello, FooClass!";

AFAIK, this is the only signature that would work for making &greet a
class method; but note that I'm not using $class, and I'd expect the
compiler to issue a warning in such a case.

The same problem exists with methods in classes fulfilling a role,
but which want to ignore a parameter in a required method.

What do you say about this proposed syntax?

     method greet(Class undef: ) { ... }

     # the interface calls for a "floor" as 1st arg
	 method bereaucracy(Int undef, Int $office_number) { ... }

I'm not sure how this works for named fields, but for positional ones
it should do well, and is similar to ($a, undef, $c) = LIST syntax.

Gaal Yahas <>

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About