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?

simbabque
  • 133

3 Answers3

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.

Paul L
  • 35
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

GEdgar
  • 25,177
  • 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 07 '17 at 11:01
  • Good point. I'll add pronunciations for '&'. – GEdgar Apr 07 '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.