>>> 2020-08-13 telephone numbers A tangent: One aspect of many messaging systems is addressing. You need to have some way to indicate who you want the message to go to, some sort of unique identifier. In the case of email, it is a username and a hostname, user@host. In the case of many instant messaging systems, it is an alphanumeric username. Some kind of formalized addressing system is not a new idea, and both mail and telegraphy used more or less formalized addressing schemes. In the case of telegrams these were often very compact alphanumeric codes to save time in transmitting. One common formal addressing scheme we deal with today, though, is particularly restrictive: telephone numbers. I will avoid straying too much into the details of telephone switching technology, but telephone numbers alone are interesting to think about. To start, why are telephone numbers, well, numeric? It's hard to know for sure why numbers were selected to formalize switchboard operations, but it must have simply been the obvious way. Labeling switchboards by name would have taken up a lot of space and likely not been practical, labeling them by number was natural and allowed operators to find lines very quickly, since locating a number in a list is something we're well practiced in. Phone numbers became more constrained, though, with the introduction of automatic switching. To avoid a long discussion of the operation of early mechanical telephone switches, I will lay out a few rules about phone numbers which come from the design of these switches: a) Phone numbers must be parsed from left to right (from first digit to last). It is not generally possible to "backtrack" to previous digits in the decision making process. For example, all telephone numbers starting with 9 must be processed in the same way. b) Phone numbers must have a more or less fixed length, or must comply to a relatively limited number of lengths. c) It must be possible to differentiate phone numbers requiring different processing based on digits in fixed positions from the start, generally the first digits. This is basically a summation of the first two. Neither of these rules are quite absolute and real exceptions exist to both, but by far the most exceptions exist for rule B. Let's take a look at the structure of a phone number and see how these apply, though. In the United States we live under a system called the North American Numbering Plan or NANP, which was extended from the Bell system to standardize telephone numbering the US, Canada, various Central American nations, and formerly, Mexico---basically the list of countries which had been served by the Bell system. NANP telephone numbers are often described using the notation +1 (NPA) NXX-XXXX. This syntax is common but a bit confusing. +1 is the country code which is conventionally prefixed with a + when written to avoid confusion, 1 is the country code for all NANP countries. NPA, or Numbering Plan Area, is the more formal term for what we typically call an area code. NXX, now, is quite different. It is a sort of mask, the N indicates the digits 2-9, and the X digits 0-9. This is the three digit prefix on all phone numbers that people will occasionally refer to as an exchange number or exchange code, as it had formerly indicated an individual telephone exchange. Note that the first digit must be 2-9, it cannot be 0 or 1. Why is this? Because the digits 0 and 1 indicate a special dialing code or an out-of-area call, respectively. This reflects the first rule that digits must be processed from left to right, each digit indicating future processing steps. Typically you can dial seven digits on your phone, which will be interpreted as NXX-XXXX within the same NPA as your own telephone. If you instead dial ten digits, (NPA) NXX-XXXX, the telephone switch must interpret the first three digits that you dial differently. It cannot backtrack to do this. For this reason, classically, 10-digit telephone numbers had to be prefixed with the digit 1, which signaled to the telephone switch that it should interpret the following three digits as an NPA, then NXX-XXXX. 0 is used for various purposes, but perhaps the most common today is international calling. Telephone switches must handle international calls completely differently from domestic. To indicate to a telephone switch that such special processing is necessary, you first dial 011. The reason for this exact code comes down to history, but 0 had historically been used to call the operator and so 0 still generally prefixes calls which require special handling. Another case of 0 and 1 having special meanings at the beginning of telephone calls is the "dial-around" prefix 1010, which allowed long-distance calls (normally prefixed with 1) to be placed using an alternate provider. The exact history of dial-around calling is somewhat complicated and it has been obsoleted by telephone plans with unlimited long distance, but it is another case of 1 having a special meaning. Of course, you can infer from this that 010 cannot be an NPA. Otherwise, dialing 1010 would be ambiguous between the dial-around prefix and placing a normal long distance call to NPA 010. Quite a few constraints appear in telephone numbers because of this requirement to avoid any ambiguity in parsing subsequent digits. Consider, as another example, the NANP proposal for extending the length of NANP telephone numbers should it become required. If we were to run out of telephone numbers, we could extend 10 digit dialing to 12 digits, by suffixing a 0 to the NPA and prefixing a 0 to the NXX. Thus the telephone number, say, (234) 567-8901 would become (2340) 0567-8901. This would be done because the NXX part already cannot begin with zero, so a zero in that position unambiguously indicates to the switch that the number being dialed is a "new-style" number. In the future other digits could be used in that position, but only once use of 10-digit numbers is completely eliminated. Incidentally, this change is not expected to occur for quite some time as the rate of new phone number issuance is actually pretty low. Another very simple example of the need to determine processing based on the first digit available is the common use of a "dial-out" prefix on PBXs, where you have to dial for example "9" to reach an outside line. Internal extensions are typically 3 or 4 (or less often 5) digits, so clearly the PBX could determine whether a telephone number is inside our outside based on the length. However, early telephone switches were simply not capable of this kind of retrospection on the dialed number, they needed to determine the processing path immediately. Therefore, much like the prefix 1 for out-of-area dialing, the prefix 9 was used for outside dialing (and no extensions could begin with 9). This is all largely just an interesting aside, but there is something which motivated me to write about it: UK phone numbers. The UK telephone system, as operated by the General Post Office, used the same mechanical switching technology as the Bell system and was so subject to the same constraints. However, the GPO did not allocate a system of telephone numbers in advance which was sufficient to meet the needs of the kingdom. As a result, additional digits were added to various processing paths over time. This leads to a vexing result: UK telephone numbers are of varying lengths. However, it is possible to predict the length of the telephone number based on the first several digits. 020 is a regional prefix indicating London. 01865 is the regional prefix indicating Oxford. These are not the same length! However, there is no regional prefix 018, and so after parsing (or in the term of the art, consuming) the digits 018 the switch knows that the next digit will also be part of the regional prefix. Incidentally, the leading 0 in these is really a special digit that is somewhat similar to the leading 1 used in the US for out-of-area dialing---it signals the switch to process the call as being to another region, but in the UK it is treated as a digit of the area code rather than as a dialing prefix. If this sounds more complicated, it is, and the UK telephone numbering scheme often feels like a mess, but it is really only by luck that the NANP scheme ended up being highly consistent over an extended period of time---and of course it has its own problems as well, such as not clearly mapping to countries. Today, most of these constraints are only historic. Cellular phones, which connect to a generally much newer switching infrastructure, usually allow all kinds of formerly invalid dialing, such as out-of-area dialing without a 1 prefix. There have also been a few curious constraints coming out of specific situations. For example, when overlaying area codes (adding a second area code to an existing area to increase capacity), some carriers decide to disable 7-digit dialing and force everyone to dial area code, hopefully reducing area code confusion. All of this comes down to the fact that call processing is today implemented in software, where a flexible scheme often called a "dial plan" is used to configure equipment to understand a variety of dialing methods. That said, landline phones are often connected to much older switches (dating back to e.g. the '70s), and so tend to be much stricter about correct dialing format. I once worked in an environment with a legacy 5ESS switch (I suspect originally installed and maintained under service contract with AT&T, but via a telecoms contractor at that point), which outright refused dialing in any format but ten-digit-one-prefixed for external calls and five digits for internal calls. Employees periodically mentioned the phones being "touchy," but no one ever seemed to think that much about why---they were probably habitually dialing only seven digits on first try, which is normally acceptable in this area. But does anyone even, like, use phone numbers these days anyway? I'm pretty lost to remember any of them.  Mexico had been a NANP country but decided to switch to using its own country code, in part to step "out of the shadow" of the United States. This change occurred relatively recently and so Mexican phone numbers are usually, but not always, compliant with NANP, in that they do not overlap with other NANP area codes.  Such cross-national telephone numbering schemes are not very common. It had been a very common issue with NANP that people would rack up excessive phone bills calling Panama, not realizing that it was an international call, since a Panama is just a set of area codes in NANP. This problem was largely eliminated by making changes to switches that required users to dial their international calling prefix when calling foreign countries, even if they are NANP countries. This represents an exception to the general NANP hierarchy concept in which a number can be dialed from within a region using only the digits within the scope of that region.