|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - possible doc bug?
in docs for Slice it says b = a[1..3]; a[1..3] is a 2 element array consisting of a[1] and a[2] shouldnt it be.... b = a[1..3]; a[1..3] is a 3 element array consisting of a[1] and a[2] and a[3] Dec 18 2003
Looks correct to me. Those originating from C++ are inculcated in the STL notion of an asymmetric range, which has the syntax [f, t), which indicates that the range consists of everything from f up to, but not including t. It's pretty much the same situation as we know in C with array dimensions, e.g. the valid indexes in int ar[10] are 0 - 9. "Lewis" <dethbomb hotmail.com> wrote in message news:brt1ft$1a9b$1 digitaldaemon.com...in docs for Slice it says b = a[1..3]; a[1..3] is a 2 element array consisting of a[1] and a[2] shouldnt it be.... b = a[1..3]; a[1..3] is a 3 element array consisting of a[1] and a[2] and Dec 18 2003
Matthew wrote: It's pretty much the samesituation as we know in C with array dimensions, e.g. the valid indexes in int ar[10] are 0 - 9. Dec 18 2003
Neither is more "right" than the other in an absolute sense. It's the same argument as to whether to count from 0 or 1. It's just the case that counting from 0, and specifying 1-past-the-post range ends is more usable in most circumstances. I'd rate you having less chance of getting this changed than the world's organised religions doing a corporate merger next spring. ;) Matthew "Lewis" <dethbomb hotmail.com> wrote in message news:brt5l5$1h9l$1 digitaldaemon.com...Matthew wrote: It's pretty much the samesituation as we know in C with array dimensions, e.g. the valid indexes Dec 18 2003
Matthew wrote:Neither is more "right" than the other in an absolute sense. It's the same argument as to whether to count from 0 or 1. It's just the case that counting from 0, and specifying 1-past-the-post range ends is more usable in most circumstances. I'd rate you having less chance of getting this changed than the world's organised religions doing a corporate merger next spring. ;) Matthew Dec 18 2003
Lewis wrote:Matthew wrote:Neither is more "right" than the other in an absolute sense. It's the same argument as to whether to count from 0 or 1. It's just the case that counting from 0, and specifying 1-past-the-post range ends is more usable in most circumstances. I'd rate you having less chance of getting this changed than the world's organised religions doing a corporate merger next spring. ;) Matthew Dec 18 2003
Maybe arrays should be inedexed starting with 1... I know it is not the C/C++ way, neither one of mathematics (almost every array begins with a0) but is more intuitive. In article <brt5l5$1h9l$1 digitaldaemon.com>, Lewis says...Matthew wrote: It's pretty much the samesituation as we know in C with array dimensions, e.g. the valid indexes in int ar[10] are 0 - 9. Dec 19 2003
Felix wrote:Maybe arrays should be inedexed starting with 1... I know it is not the C/C++ way, neither one of mathematics (almost every array begins with a0) but is more intuitive. Dec 19 2003
We had a huge debate about this a very long time ago and Walter won. ;) If anything, I like your suggestion about basing arrays on one less than the current spec. You're suggesting both making slice syntax inclusive on both ends (which already lost) and to also make arrays 1-based, which is very unlikely to change since most of us (everybody with a C, C++, Pascal, Java, or C#, or assembly background) like 0-based arrays. It's all in what you were exposed to first as to what seems intuitive. It's not so terribly difficult to rewire that part of your brain. You just have to try it for a while, and after a while you "just get it". ;) Sean "Lewis" <dethbomb hotmail.com> wrote in message news:bruevq$f9l$1 digitaldaemon.com...Felix wrote:Maybe arrays should be inedexed starting with 1... I know it is not the Dec 19 2003
Sean L. Palmer wrote:We had a huge debate about this a very long time ago and Walter won. ;) If anything, I like your suggestion about basing arrays on one less than the current spec. You're suggesting both making slice syntax inclusive on both ends (which already lost) and to also make arrays 1-based, which is very unlikely to change since most of us (everybody with a C, C++, Pascal, Java, or C#, or assembly background) like 0-based arrays. It's all in what you were exposed to first as to what seems intuitive. It's not so terribly difficult to rewire that part of your brain. You just have to try it for a while, and after a while you "just get it". ;) Sean Dec 19 2003
Thanks for your advice. It is nice, as any Christmas present should be... ;) I expressed only one (very doubtful: "maybe" even for me...) I'll by another brain... Nevermind, me too used to index by zero, till starting to work seriously under Matlab (engineering). Here index is one-based... To short the debate, it was the most strightforward way to link the slicing with the definition. But I don't want to be devil's advocate... Anyway (i start my hollyday) I wold like to wish you (and to all other people on the forum) Merry Christmas! and Happy New Year! A 2004-index based "Long live the humankind!" ;) No harm. In article <brukho$nb5$1 digitaldaemon.com>, Sean L. Palmer says...We had a huge debate about this a very long time ago and Walter won. ;) If anything, I like your suggestion about basing arrays on one less than the current spec. You're suggesting both making slice syntax inclusive on both ends (which already lost) and to also make arrays 1-based, which is very unlikely to change since most of us (everybody with a C, C++, Pascal, Java, or C#, or assembly background) like 0-based arrays. It's all in what you were exposed to first as to what seems intuitive. It's not so terribly difficult to rewire that part of your brain. You just have to try it for a while, and after a while you "just get it". ;) Sean "Lewis" <dethbomb hotmail.com> wrote in message news:bruevq$f9l$1 digitaldaemon.com...Felix wrote:Maybe arrays should be inedexed starting with 1... I know it is not the Dec 19 2003
"Felix" <Felix_member pathlink.com> wrote in message news:bruqs5$10a8$1 digitaldaemon.com...Anyway (i start my hollyday) I wold like to wish you (and to all other Dec 19 2003
Thanks for your advice. It is nice, as any Christmas present should be... ;) I expressed only one (very doubtful: "maybe" even for me...) I'll bUy another brain... Nevermind, me too used to index by zero, till starting to work seriously under Matlab (engineering). Here index is one-based... To short the debate, it was the most strightforward way to link the slicing with the definition. But I don't want to be devil's advocate... Anyway (i start my hollyday) I wold like to wish you (and to all other people on the forum) Merry Christmas! and Happy New Year! A 2004-index based "Long live the humankind!" ;) No harm. In article <brukho$nb5$1 digitaldaemon.com>, Sean L. Palmer says...We had a huge debate about this a very long time ago and Walter won. ;) If anything, I like your suggestion about basing arrays on one less than the current spec. You're suggesting both making slice syntax inclusive on both ends (which already lost) and to also make arrays 1-based, which is very unlikely to change since most of us (everybody with a C, C++, Pascal, Java, or C#, or assembly background) like 0-based arrays. It's all in what you were exposed to first as to what seems intuitive. It's not so terribly difficult to rewire that part of your brain. You just have to try it for a while, and after a while you "just get it". ;) Sean "Lewis" <dethbomb hotmail.com> wrote in message news:bruevq$f9l$1 digitaldaemon.com...Felix wrote:Maybe arrays should be inedexed starting with 1... I know it is not the Dec 19 2003
Anyway (i start my hollyday) I wold like to wish you (and to all other Dec 19 2003
"Matthew" <matthew.hat stlsoft.dot.org> wrote in message news:brvs3h$2jsp$1 digitaldaemon.com... | > Anyway (i start my hollyday) I wold like to wish you (and to all other | people on | > the forum) Merry Christmas! and Happy New Year! A 2004-index based "Long | live | > the humankind!" | | You too, and to all the other D-programmers. | | I think 2004 will have some big things for D. :) | | Cheers everyone | | | | -- | Matthew Wilson | | STLSoft moderator (http://www.stlsoft.org) | Contributing editor, C/C++ Users Journal | (www.synesis.com.au/articles.html#columns) | | "An Englishman by birth, a Yorkshireman by the grace of God" -- Michael | Gibbs | | -------------------------------------------------------------------------- -- | --- | | | I was planning to do it around the 23rd, 24th, but since you guys are doing it now, me too. Happy holidays to you all, let 2004 be a very good year for all of us, and for D too ;). ----------------------- Carlos Santander Bernal Dec 19 2003
Maybe arrays should be inedexed starting with 1... I know it is not the Dec 19 2003
|