1. RE: 0-based Indexing

> I have suffered several times from Euphoria's lack of 0-based indexing.
> Adding and Subtracting 1's to make things Offset into the correct
> location.

Uh... the first item of a sequence is s[1]. How is that at all wrong?

I understand you're probably talking about poking things into memory or
something else other than arrays or sequence variables.

> 1-based indexing is a real pain in the neck.

Maybe for those who can't understand the easy-to-understand sequence
indexing, Darth. :P

---

new topic     » topic index » view message » categorize

2. RE: 0-based Indexing

Most versions of APL have an option: 0 or 1 indexing. Pascal can have any
index origin you want.
The fact is that some operations are easier (for humans) with 0 indexing,
other with 1 indexing, and still other with some arbitrary index origin.
Regards.-
----- Original Message -----
From: C. K. Lester <cklester at yahoo.com>
Subject: Re: 0-based Indexing


>
>
> Derek splained (snippage occurred):
>
> > > I don't get it. Why do some languages use 0-based indexing? It's got
to
> be
> > > the dumbest thing in programming language history. Or maybe not.
> > >
> > The index is actually an offset from an address.
>
> Okay, I get that... and that's reasonable for the behind-the-scenes data
> manipulation, but why not hide that detail and use 1-based indexing? Is it
> that much of a performance issue? Like Greg said, 1-based indexing is more
> intuitive, easier to read and understand...
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view message » categorize

3. RE: 0-based Indexing

> From: gertie at visionsix.com [mailto:gertie at visionsix.com]

> > On 16 Jul 2003, at 17:26, jbrown105 at speedymail.org wrote:

> > I have heard that the technical reason that sequences in 
> > Euphoria start at 1 is because in the C array that is used
> > internally, element 0 is used to hold the length of the
> > sequence. Not sure if this is true or not.

Not really.  A sequence is actually a structure.  It basically stores three
things:  the length of the sequence, a reference count and a pointer to the
data.  It actually used to point to the first element, so you had to convert
bases when working with a slice.  But now it pads the data with a
non-existent 0-th element.
 
> BASIC and Pascal used the first byte as length. (It feels odd 
> that RobC would use an example from Basic, and still not
> implement CASE and GOTO.) So the string storage data did
> actually start at zero offset, but not the string itself.
> Naturally my gripe with Turbo Pascal is that it began a move 
> to C strings, so one could not store a null in byte in the 
> string. But then, DOS frowned on that too.

Actually, the BSTR (basic string--as used by VB and COM and prolly others,
too) stores the length of the string in the four bytes preceding the data,
but the pointer to the string points to the data.  Also, the string is
unicode.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

4. RE: 0-based Indexing

On 17 Jul 2003, at 6:32, Matt Lewis wrote:

> 
> 
> > From: gertie at visionsix.com [mailto:gertie at visionsix.com]
> 

<snip>

> > BASIC and Pascal used the first byte as length. (It feels odd 
> > that RobC would use an example from Basic, and still not
> > implement CASE and GOTO.) So the string storage data did
> > actually start at zero offset, but not the string itself.
> > Naturally my gripe with Turbo Pascal is that it began a move 
> > to C strings, so one could not store a null in byte in the 
> > string. But then, DOS frowned on that too.
> 
> Actually, the BSTR (basic string--as used by VB and COM and prolly others,
> too) stores the length of the string in the four bytes preceding the data,
> but the pointer to the string points to the data.  Also, the string is
> unicode.

"used" , as in past tense.

Kat

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu