in reply to Re: Question Marks in Subroutine Names
in thread Question Marks in Subroutine Names

It's not legal now, but it may well become so in perl 6 since ?: is becoming ??:: in order to free up the colon (Larry hasn't told us what's going to happen to the question mark, but I wouldn't have a problem with making it a valid character in an identifier. I'd love to be able to write
given $employee { when male? {...} when female? {...} default { "Ooh... neuter"; ... } }
I tend to think that 'question form' methods/functions sit best in a functional or objective programming style; they seem to jar slightly when you're writing procedural stuff. But that could just be me.

Probably what will really happen is that Larry will show us some utterly clear and really useful trick that can be done with '?' as an operator and we'll gleefully use that and forget about using ?s in our identifiers.

Replies are listed 'Best First'.
Re: Re: Re: Question Marks in Subroutine Names
by Molt (Chaplain) on May 08, 2002 at 10:12 UTC

    Eep. This style of subroutine naming would do my head in, I see the 'when male?' and the natural-language part of my brain takes that as a stand-alone sentance and asks something like "I don't know, when are they male?".

    It's the different between 'When raining, put on a coat' and 'When raining? Put on a coat'. The first sounds natural to me, and the second like a bad translation.

    Maybe my brain's wired wrongly though.