| This is the talk page for discussing improvements to the Zero-based numbering article. This is not a forum for general discussion of the subject of the article. |
Article policies
|
| Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
| Archives: 1Auto-archiving period: 12 months |
| This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||
I find the BCPL anecdote misleading, not only have I have multiple multiple different versions of it, but it misquotes both Hoye and Stevens. The bit about the 7094 was not something Stevens said, it was Mike's speculation based on a separate document, and the indirection operation in BCPL was always at run-time because it was completely beyond the state of the art in compiler technology in the early '60s to track which words used in indirection were safe to optimize in the way he suggests.
BCPL arrays were zero-origin because it fell naturally out of the unification of pointers and other values in a low level language. Stevens says as much in the comment Mike quotes:
As for BCPL and C subscripts starting at zero. BCPL was essentially designed as typeless language close to machine code. Just as in machine code registers are typically all the same size and contain values that represent almost anything, such as integers, machine addresses, truth values, characters, etc. BCPL has typeless variables just like machine registers capable of representing anything. If a BCPL variable represents a pointer, it points to one or more consecutive words of memory. These words are the same size as BCPL variables. Just as machine code allows address arithmetic so does BCPL, so if p is a pointer p+1 is a pointer to the next word after the one p points to. Naturally p+0 has the same value as p. The monodic indirection operator ! takes a pointer as it’s argument and returns the contents of the word pointed to. If v is a pointer !(v+I) will access the word pointed to by v+I. As I varies from zero upwards we access consecutive locations starting at the one pointed to by v when I is zero. The dyadic version of ! is defined so that v!i = !(v+I). v!i behaves like a subscripted expression with v being a one dimensional array and I being an integer subscript. It is entirely natural for the first element of the array to have subscript zero. C copied BCPL’s approach using * for monodic ! and [ ] for array subscription. Note that, in BCPL v!5 = !(v+5) = !(5+v) = 5!v. The same happens in C, v[5] = 5[v]. I can see no sensible reason why the first element of a BCPL array should have subscript one. Note that 5!v is rather like a field selector accessing a field in a structure pointed to by v.
— Richard Stephens
But the speculation about performance considerations on the 7094, and especially the idea that it was precalculating indirection at compile time, are not supported by the original documentation. When you allocate a vector in BCPL, like "LET V = VEC 5", you actually allocated 6 words, the first of which contained the address of the second. Most if not all of the time you *created* it on the stack, at runtime. You could freely initialize words with addresses calculated at runtime, such as this example taken from the BCPL manual:
LET IOV = VEC 650
LET IOVP, IOVT = IOV, IOV + 650
quote
With zero-based numbering, a range can be expressed as the half-open interval, [0, n), as opposed to the closed interval, [1, n].
Who says 1-based numbering couldn't use the half-open interval of (0, n] ??? How is [0, n) any superior compared to (0, n] ??? 2603:7000:3C3D:4840:0:0:0:1D7 (talk) 07:33, 20 June 2025 (UTC)
Notes
How is one integer more natural than another? The article Natural number says not everyone agrees on including zero, so how is zero "the most natural number"? —Tamfang (talk) 21:19, 1 October 2025 (UTC)
In 1982 Edsger W. Dijkstra in his pertinent note Why numbering should start at zero[1] argued that arrays subscripts should start at zero as that's the most natural number., what matters is which usage Dijkstra used, and any reference to the quote should be consistent with his zero as a most natural number.
(3) It's the only integer that you can raise to another finite integer power and end up with infinity.
<del>...</del> and <ins>...</ins> in LaTeX? -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 13:11, 3 June 2026 (UTC)References
When dealing with a sequence of length N, the elements of which we wish to distinguish by subscript, the next vexing question is what subscript value to assign to its starting element. Adhering to convention a) yields, when starting with subscript 1, the subscript range 1 ≤ i < N+1; starting with 0, however, gives the nicer range 0 ≤ i < N. So let us let our ordinals start at zero: an element's ordinal (subscript) equals the number of elements preceding it in the sequence. And the moral of the story is that we had better regard —after all those centuries!— zero as a most natural number.
The lead states Numbering sequences starting at 0 is quite common in mathematics notation,
, but the norm is to number sequences starting at 1, combinatorics notwithstanding. The major exception is transfinite induction, where the indexing ordinals normally start at . -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 15:32, 3 July 2026 (UTC)
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.