D - possible doc bug?
- Lewis (4/4) Dec 18 2003 in docs for Slice it says
- Matthew (9/13) Dec 18 2003 Looks correct to me.
- Lewis (8/11) Dec 18 2003 i can understand the 0 - 9 part, it makes sense , as thats how most 0 ba...
- Matthew (13/24) Dec 18 2003 Neither is more "right" than the other in an absolute sense. It's the sa...
- Lewis (5/17) Dec 18 2003 Your probably right :) I just need to adapt my way of thinking is all, w...
- J Anderson (2/23) Dec 18 2003 Funny, I had this same problem!
- Felix (4/15) Dec 19 2003 Maybe arrays should be inedexed starting with 1... I know it is not the ...
- Lewis (8/11) Dec 19 2003 I have no problems with arrays being 0 indexed, its just the slice opera...
- Sean L. Palmer (17/28) Dec 19 2003 We had a huge debate about this a very long time ago and Walter won. ;)
- Lewis (14/26) Dec 19 2003 that walter he always wins aye ? ;)
- Felix (13/43) Dec 19 2003 Thanks for your advice. It is nice, as any Christmas present should be.....
- Sean L. Palmer (8/13) Dec 19 2003 people on
- Felix (13/43) Dec 19 2003 Thanks for your advice. It is nice, as any Christmas present should be.....
- Matthew (14/17) Dec 19 2003 You too, and to all the other D-programmers.
-
Carlos Santander B.
(38/38)
Dec 19 2003
"Matthew"
wrote in message - Matthew (15/35) Dec 19 2003 To whom?
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] anda[3]
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.i can understand the 0 - 9 part, it makes sense , as thats how most 0 based array index's work, which is why it makes no sense then to slice the array with a[8 .. 10] (to get the last 2 index's) it should be [8 .. 9] i say this is something that should be changed... (just my opinion). it does make the syntax [3 .. arr.length] easier but it should be [3 .. arr.length - 1] to be correct ;)
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 sameinsituation as we know in C with array dimensions, e.g. the valid indexesbasedint ar[10] are 0 - 9.i can understand the 0 - 9 part, it makes sense , as thats how most 0array index's work, which is why it makes no sense then to slice the arraywitha[8 .. 10] (to get the last 2 index's) it should be [8 .. 9] i say this is something that should be changed... (just my opinion). it does make the syntax [3 .. arr.length] easier but it should be [3 .. arr.length - 1] to be correct ;)
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. ;) MatthewYour probably right :) I just need to adapt my way of thinking is all, when i see the slice operator my brain wants to see "To" as in: a[] = Slice(3 To 9); or ('LowerBound' To 'UpperBound') when its really: a[] = Slice( StartIndex To 'Index + 1' )
Dec 18 2003
Lewis wrote:Matthew wrote:Funny, I had this same problem!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. ;) MatthewYour probably right :) I just need to adapt my way of thinking is all, when i see the slice operator my brain wants to see "To" as in: a[] = Slice(3 To 9); or ('LowerBound' To 'UpperBound') when its really: a[] = Slice( StartIndex To 'Index + 1' )
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.i can understand the 0 - 9 part, it makes sense , as thats how most 0 based array index's work, which is why it makes no sense then to slice the array with a[8 .. 10] (to get the last 2 index's) it should be [8 .. 9] i say this is something that should be changed... (just my opinion). it does make the syntax [3 .. arr.length] easier but it should be [3 .. arr.length - 1] to be correct ;)
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.I have no problems with arrays being 0 indexed, its just the slice operator doesnt follow the same philosophy. To grab the first two elements should be a[] = b[0 .. 1] or b[lbound .. ubound] but not a[] = b[0 .. 2] ... its unintuitive to me because the start index is 0 based but the ending index is 0 + 1 based ( or something like that), But as was stated, it seems for compatibility reasons an such it wouldnt be wise to be changed. (no global religion for us! :) )
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, 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:C/C++Maybe arrays should be inedexed starting with 1... I know it is not theis moreway, neither one of mathematics (almost every array begins with a0) butoperatorintuitive.I have no problems with arrays being 0 indexed, its just the slicedoesnt follow the same philosophy. To grab the first two elements should be a[] = b[0 .. 1] or b[lbound .. ubound] but not a[] = b[0 .. 2]...its unintuitive to me because the start index is 0 based but the endingindex is0 + 1 based ( or something like that), But as was stated, it seems for compatibility reasons an such it wouldnt be wise to be changed. (no global religion for us! :) )
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, 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". ;) Seanthat walter he always wins aye ? ;) actually i want to clarify that i definetly would *hate* to see arrays 1 based note the following quote: "I have no problems with arrays being 0 indexed" this should have said "i have no problems with arrays being 0 based" would have been better way to state it... In vb the collections are almost all 1 based [1 to count] and the arrays are 0 based [0 to count - 1] by default (what i always used) but you could cause all arrays to be 1 based with a compiler flag... in fact they are the same as COM safearray's. But all that aside, i would lobby hard against 1 based arrays, but the slice operator should follow the same philosophy of 0 based arrays in my opinion, But again that is easier to get used to [startindex .. endindex + 1] than a 1 based array would be *shudders*
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, 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:C/C++Maybe arrays should be inedexed starting with 1... I know it is not theis moreway, neither one of mathematics (almost every array begins with a0) butoperatorintuitive.I have no problems with arrays being 0 indexed, its just the slicedoesnt follow the same philosophy. To grab the first two elements should be a[] = b[0 .. 1] or b[lbound .. ubound] but not a[] = b[0 .. 2]...its unintuitive to me because the start index is 0 based but the endingindex is0 + 1 based ( or something like that), But as was stated, it seems for compatibility reasons an such it wouldnt be wise to be changed. (no global religion for us! :) )
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 otherpeople onthe forum) Merry Christmas! and Happy New Year! A 2004-index based "Longlivethe humankind!"Yeah, I get two weeks off, with nothing to do! Woohoo! Maybe I'll get the latest DMD and play around.;) No harm.No harm, no foul! ;) 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 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, 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:C/C++Maybe arrays should be inedexed starting with 1... I know it is not theis moreway, neither one of mathematics (almost every array begins with a0) butoperatorintuitive.I have no problems with arrays being 0 indexed, its just the slicedoesnt follow the same philosophy. To grab the first two elements should be a[] = b[0 .. 1] or b[lbound .. ubound] but not a[] = b[0 .. 2]...its unintuitive to me because the start index is 0 based but the endingindex is0 + 1 based ( or something like that), But as was stated, it seems for compatibility reasons an such it wouldnt be wise to be changed. (no global religion for us! :) )
Dec 19 2003
Anyway (i start my hollyday) I wold like to wish you (and to all otherpeople onthe forum) Merry Christmas! and Happy New Year! A 2004-index based "Longlivethe 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 ---------------------------------------------------------------------------- ---
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 theC/C++way, neither one of mathematics (almost every array begins with a0) but ismoreintuitive.To whom? Once again, this is something that you need to be careful not to colour with your own opinion/experience. In reality, arrays aren't intuitive to anyone, any more than English, French, Spanish, treble clefs, C++, mathematics, or any of the other wonderful but arbitrary creations of man. You're far better to play with it, get used to it, and forget the days when it seemed foreign. :) MatthewIn article <brt5l5$1h9l$1 digitaldaemon.com>, Lewis says...inMatthew wrote: It's pretty much the samesituation as we know in C with array dimensions, e.g. the valid indexesbasedint ar[10] are 0 - 9.i can understand the 0 - 9 part, it makes sense , as thats how most 0array witharray index's work, which is why it makes no sense then to slice thea[8 .. 10] (to get the last 2 index's) it should be [8 .. 9] i say this is something that should be changed... (just my opinion). it does make the syntax [3 .. arr.length] easier but it should be [3 .. arr.length - 1] to be correct ;)
Dec 19 2003