2

In the Perl programming language, symbols in front of variable names are called a sigil. When reading code out loud, the sigil is spoken. $foo becomes dollar foo. The sigil for functions is the ampersand &, but it's mostly omitted because using it explicitly does special things that you mostly do not want.

In the following sentence, does the indefinite article in front of the &foo need to be a, or an when it is written out?

What happens if the package does not have an &foo?

The above looks weird to me, but I believe that's because I'm reading the & as und in my head (which is the colloquial name in my native language German for this symbol), but I think it is correct.

Some people might read this does not have a foo, while others might read does not have an ampersand foo.


I'm aware that I could rewrite this so it's less ambiguous and the sigil can be omitted, but I am curious.

What happens if the package does not have a method foo?

  • 1
    Related: A or an before acronyms. It may even be a duplicate if the answer to the question is "If the word following the indefinite article begins with a vowel sound, use an; if it begins with a consonant sound, use a." – Andrew Leach Feb 6 '17 at 9:11
  • @AndrewLeach that would be the obvious thing to do, yes. But the word following the article here is not a word when it's written out. – simbabque Feb 6 '17 at 9:15
  • 'A' vs 'an' most sensibly reduces to a matter of convenience in articulating. Whatever the sound read out after the article is determines the choice of article except in one or two arcane (an historian?) examples. This is almost a matter of punctuation rather than word-choice. – Edwin Ashworth Feb 6 '17 at 11:29
  • You could rewrite it to avoid the article: What happens if the package does not include &foo? – Davo Apr 7 '17 at 11:35
  • Possible duplicate of Do you use "a" or "an" before acronyms? – Hot Licks Apr 20 '17 at 21:58
3

Personally, I would stick to the rule of thumb based on how the "word" is spoken - if it is spoken with a vowel sound at the start, use "an", otherwise use "a".

In English the "&" is either "ampersand" or "and" - both starting with a vowel, so I guess "an &foo" is valid. As long as your audience would read it aloud as "and foo" or "ampersand foo", that would work. However, as a non-Perl programmer, reading this I mentally ignored the symbol - it doesn't mean anything to me - so I first read your sentence as "an foo" which felt wrong.

3

Of course, pronunciation may depend on the person. So, for example, '*' could be pronounced "star" or "asterisk". Whichever article you use will then seem strange to some of the readers.

When you write a * after a name, it means...

or

When you write an * after a name, it means...

Looking HERE I find these pronunciations for '&':

and, amper, address (C), shift-7, andpersand, snowman, bitand (C), donald duck, background (UNIX), pretzel

  • While that's true, I don't see how that helps with the &. Is that anything else but an ampersand or an and in English? In German I know a couple of different names for that & thing, but not in English. – simbabque Apr 7 '17 at 11:01
  • Good point. I'll add pronunciations for '&'. – GEdgar Apr 7 '17 at 11:04
0

Please be clear that only if this is about language in general, rather than Perl, should it live here, and then some.

Since you’re asking in detail about language, neither in Perl nor in any other language are symbols in front of variable names called a sigil. In every language, they are sigils and the difference matters.

You might and I haven’t heard $foo read as dollar foo for nearly 40 years. String foo ad nauseam; dollar foo never.

The indefinite article in front of the &foo doesn’t need to be a or an unless I missed Perl using English rules. Does it?

When some people might read this does not have a foo and others this does not have an &foo either they’re all wrong, or it doesn’t matter at all. Which do you vote for, please?

If at this late stage you’re aware that Perl would let you could rewrite this so it was less ambiguous and the sigil could be omitted, why not stick with the rules of Perl? ‘What happens if the package does not have a method foo?’ seems to indicate a choice among various versions of Perl, far more than of language in general or any other language in particular.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.