sub foo : required($$$) {
...
}
That allows more than just currying to use the attribute. Also, you can then do something like:
sub foo : required( address, city, state, zip ) {
...
}
That way, you can do both parameter validation and named-parameter currying (as per Limbic~Region's comment below). Plus, you're specifying the API, which would allow for something like doxygen to document your API.
An even nicer thing would be to combine this idea of a required() attribute to methods, meaning that you could do something like:
package Foo;
sub new
: required( attr1, attr2 )
: optional( attr3 )
{
...
}
This would behave like Class::MethodMaker and create the attr1(), attr2(), and attr3() mutators, plus require that the first two be passed in to the constructor.
It wouldn't be too hard to come up with a list of useful function/method attributes. Off the top of my head, I can see multiple uses for:
- required
- optional
- deprecated
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
|