You are turning a question into a statement, which in my mind is far less idiomatic. Using an English usage based naming convention, your recomendation would look like this to me:
##
# contact_is_male( contact_id => $contact_id )
# requires contact_id, makes contact male
sub contact_is_male {
my ( $self, %arg ) = @_;
die "contact_id required\n"; unless $arg{contact_id};
$self->{contacts}{$arg{$contact_id}}{sex}{male};
}
NOTE: writing subs after beer in an environment without a Perl interpreter *grin* | [reply] [d/l] |
I disagree with your views on English Usage, I think... your sentence is declarative, but your subroutine is imperative. The statement "contact is male", like the statement "ChemBoy is human" makes an assertion, and may or may not be true--your interpretation would seem to me to be equivalent to somebody saying "ChemBoy is martian" and having it magically become true (which has not so far taken place, as far as I can tell--though I haven't hit submit, yet...). Whereas if you had a subroutine &make_martian($ChemBoy), I'd be entitled to be worried. :-)
And if you want English-like syntax, why a question mark in the first place? In standard English usage, conditionals do not have question marks: the phrase "if the customer is female, start the letter with 'Ms.'; otherwise, with 'Mr.'" yields the following code, which seems to me perfectly readable without further punctuation:
if ($customer->is_female) {
print "Dear Ms. ", $customer->surname();
} else {
print "Dear Mr. ", $customer->surname();
}
Or, of course, with punctuation (as mentioned elsewhere in this thread):
print "Dear ", ($customer->is_female?"Ms. ":"Mr. "),$customer->surname
+();
All of which, of course, are missing the final comma of the salutation, but that's a separate issue. :-)
If God had meant us to fly, he would *never* have given us the railroads. --Michael Flanders | [reply] [d/l] [select] |
is_contact_female?; # interogative, expect yes or no.
contact_is_female; # declarative, assume the contact is female.
contact_become_female; # imperative, make contact female.
The reason I don't like $contact->is_female is that I read it as "the contact is female". However, if I were able to say $contact->is_female?, well, that is a piece of sugar that I'd eat. | [reply] [d/l] [select] |