Author Topic: Duality  (Read 3630 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Duality
« on: October 05, 2013, 05:29:24 AM »
Deleted
« Last Edit: May 07, 2015, 11:04:15 AM by Peter »

Charles Pegge

  • Guest
Re: Duality
« Reply #1 on: October 05, 2013, 08:00:41 AM »
Hi Peter,

When dimensioning an array, the index specified is the highest element, using the indexbase.

This is a legacy of PB & also FB (I have not checked)

I could change it so that it specifies the number of elements in the array instead. I think that might be preferable. What do you think?

Charles Pegge

  • Guest
Re: Duality
« Reply #2 on: October 05, 2013, 09:09:42 AM »
To clarify: I was referring to the dim index rather than spanof()

Thus:

Indexbase 0
sys a[100]


currently a contains 101 elements

I am proposing that it should be 100 elements regardless of indexbase.

erosolmi

  • Guest
Re: Duality
« Reply #3 on: October 05, 2013, 11:36:41 AM »
eheh  ;D

I discussed this situation so many times with other programmers especially C programmers.
You dimension whatever to X and you get X+1 elements.
If you want X elements you need to dimension it X-1
In thinBasic I decided to FIX base to 1. No other options.
Yes, I was quite drastic.

JRS

  • Guest
Re: Duality
« Reply #4 on: October 05, 2013, 12:02:35 PM »
I typically like to use the zero element as a status like element in code I write. The real data starts at one.

Aurel

  • Guest
Re: Duality
« Reply #5 on: October 05, 2013, 01:25:14 PM »
Quote
This isn't possible due to 1000 programs which base on  IndexBase  0.
Eros is too fast with his decisions!

Yeah...old Eros 'hate' zero base option...and i am not sure why because most of standard windows
controls are zero based
edit - first line 0
richedit - 0
listbox - 0
combobox 0
tabcontrol 0
uff i have some freakin problems with tab control and not to use 0 based first tab
etc...etc....
Of course that this thing can be avoided....
and when we looking from human-logical side it is far logical to
start from 1-100 than from 0-99 ...i agree with that ;D

JRS

  • Guest
Re: Duality
« Reply #6 on: October 05, 2013, 02:28:05 PM »
I would like to stay with traditional BASIC syntax as a core and extend the feature set from there. Making arrays not start at zero breaks too much code. IMHO

Trying to get rid of GOTO/GOSUB is another battle traditional BASIC fights.

 

Aurel

  • Guest
Re: Duality
« Reply #7 on: October 05, 2013, 02:35:13 PM »
Yes,...Charles why is default indexbase 1 ?
i just ask....

Charles Pegge

  • Guest
Re: Duality
« Reply #8 on: October 05, 2013, 03:02:52 PM »
Indexbase 1: This is the easiest to understand, and most convenient for simple programs. It is also compatible with character indexing in strings.

The pros who work with the sdk or pixel arrays will naturally prefer IndexBase 0.

You can change the indexbase at any point in the program, or alter it locally in a function. It only affects the frame of reference.

PS: goto will always be supported since it is essential for low level programming.

kryton9

  • Guest
Re: Duality
« Reply #9 on: October 05, 2013, 04:47:26 PM »
I like the option of 1 or 0 as in OxygenBasic, only because as many stated lots of other languages use 0.
It is nice to have the flexibility.
If the earlier programming languages were from a perfect world, I think using 1 would have been better as Eros chose
in thinBasic.

But for the size, I think saying array[10] would be 10 elements total and not 11.
indexbase 0  that would be 0-9
indexbase 1  that would be 1-10

Aurel

  • Guest
Re: Duality
« Reply #10 on: October 05, 2013, 09:58:13 PM »
Quote
goto will always be supported since it is essential for low level programming.
yes GOTO is fine.... ;)
« Last Edit: October 06, 2013, 12:54:30 AM by Aurel »