Re: wikipedia draft

new topic     » goto parent     » topic index » view thread      » older message » newer message

Suggestion:

Phix uses 1-based indexes
The widespread use of 0-based indexes[8] stems from a paper[9] by Edsger W. Dijkstra and the benefits for pointer arithmetic[10], which Phix does not have.
There have been many other debates[11],[12] about the use of 0-based vs. 1-based indexing.
In 0-based indexing the first,last,length are 0,n-1,n whereas in 1-based indexing they are 1,n,n.
If the first element of an array is a[0], you cannot index the last as a[-0], whereas a[1] and a[-1] are much more reasonable.
In a language that allows negative indexes from the end of the array (such as Python[13]), having all indexes in -2,-1,0,1,2 be meaningful will obviously catch fewer errors than when a[0] is always an error (as it is in Phix).
You don't need to explain 1-based indexing to anyone and you certainly don't need a diagram.
For these reasons, Phix uses 1-based indexing, similar to Julia[14]

original of the above, wp-ready:

== Phix uses 1-based indexes == 
The widespread use of 0-based indexes<ref name=copla/> stems from a paper<ref name=EWD831/> by [[Edsger_W._Dijkstra|Edsger W. Dijkstra]] and  
the benefits for pointer arithmetic<ref name=adtio/>, which Phix does not have.<br> 
There have been many other debates<ref name=io0ah/>,<ref name=jggd/> about the use of 0-based vs. 1-based indexing.<br> 
In 0-based indexing the first,last,length are 0,n-1,n whereas in 1-based indexing they are 1,n,n.<br> 
If the first element of an array is a[0], you cannot index the last as a[-0], whereas a[1] and a[-1] are much more reasonable.<br> 
In a language that allows negative indexes from the end of the array (such as Python<ref name=python/>), having all indexes in 
-2,-1,0,1,2 be meaningful will obviously catch fewer errors than when a[0] is always an error (as it is in Phix).<br> 
You don't need to explain 1-based indexing to anyone and you certainly don't need a diagram.<br> 
For these reasons, Phix uses 1-based indexing, similar to Julia<ref name=julia/><br> 
 
<ref name=copla>{{cite web|url=https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(array)#Array_system_cross-reference_list|title=Array indexing comparison|accessdate=2021-01-09}}</ref> 
<ref name=EWD831>{{cite web|url=https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html|title=Why number should start at zero by Edsger W. Dijkstra|accessdate=2021-01-09}}</ref> 
<ref name=adtio>{{cite web|url=https://en.wikipedia.org/wiki/Array_data_type#Index_origin|title=Array datatype index origin|accessdate=2021-01-09}}</ref> 
<ref name=io0ah>{{cite web|url=https://www.jsoftware.com/papers/indexorigin.htm|title=Is Index Origin 0 a Hindrance? Roger Hui|accessdate=2021-01-09}}</ref> 
<ref name=jggd>{{cite web|url=https://groups.google.com/forum/?hl=en#!topic/julia-dev/tNN72FnYbYQ|title=Thread on Julia google groups|accessdate=2021-01-09}}</ref> 
<ref name=python>{{cite web|url=https://en.wikipedia.org/wiki/Python_(programming_language)|title=Python|accessdate=2021-01-09}}</ref> 
<ref name=julia>{{cite web|url=https://en.wikipedia.org/wiki/Julia_(programming_language)|title=Julia|accessdate=2021-01-09}}</ref> 
You might want to find more specific references for Python (-ve indexes) and Julia (1-based).

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu