Jump to page: 1 2
Thread overview
possible doc bug?
Dec 18, 2003
Lewis
Dec 18, 2003
Matthew
Dec 18, 2003
Lewis
Dec 18, 2003
Matthew
Dec 18, 2003
Lewis
Dec 18, 2003
J Anderson
Dec 19, 2003
Felix
Dec 19, 2003
Lewis
Dec 19, 2003
Sean L. Palmer
Dec 19, 2003
Lewis
Dec 19, 2003
Felix
Dec 19, 2003
Sean L. Palmer
Dec 19, 2003
Felix
Dec 19, 2003
Matthew
OT: happy holidays (was Re: possible doc bug?)
Dec 19, 2003
Matthew
December 18, 2003
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]

December 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
a[3]
>


December 18, 2003
Matthew wrote:

 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.
> 

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 ;)

December 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 same
> > situation 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 ;)
>


December 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
> 

Your 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' )
December 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
>>
>
> Your 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' )

Funny, I had this same problem!

December 19, 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 same
>> situation 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 ;)
>


December 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! :) )
December 19, 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.

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.

:)

Matthew

> In article <brt5l5$1h9l$1@digitaldaemon.com>, Lewis says...
> >
> >Matthew wrote:
> >
> >  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.
> >>
> >
> >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 ;)
> >
>
>


December 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
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! :) )


« First   ‹ Prev
1 2