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

Ignoring parameters

Thread Next
From:
Gaal Yahas
Date:
June 16, 2005 08:56
Subject:
Ignoring parameters
Message ID:
20050616155552.GK14133@sike.forum2.org
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 <gaal@forum2.org>
http://gaal.livejournal.com/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About