Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Element 0 in arrays
#7
(09-18-2023, 01:40 PM)a740g Wrote: This can become problematic if you pass the address of the arrays to C functions IMO.

A safer and better way to declare arrays is by always using the `TO` keyword.

Like `DIM myArray(1 TO 1024) AS DOUBLE`.

That way the arrays aways have the exact number of elements regardless of the `OPTION BASE` setting.

That's definitly true, especially if you make a library where you never know if the people using your library have OPTION BASE 1 in effect or not.

However, my point was that as a programmer its generally better to start counting at zero rather than one, cause that't the natural way in most programming languages where eg. array indices are nothing else than memory offsets.
Reply


Messages In This Thread
Element 0 in arrays - by PhilOfPerth - 09-18-2023, 06:35 AM
RE: Element 0 in arrays - by RhoSigma - 09-18-2023, 07:14 AM
RE: Element 0 in arrays - by PhilOfPerth - 09-18-2023, 11:17 AM
RE: Element 0 in arrays - by SMcNeill - 09-18-2023, 07:40 AM
RE: Element 0 in arrays - by RhoSigma - 09-18-2023, 12:58 PM
RE: Element 0 in arrays - by a740g - 09-18-2023, 01:40 PM
RE: Element 0 in arrays - by RhoSigma - 09-18-2023, 02:05 PM
RE: Element 0 in arrays - by mnrvovrfc - 09-18-2023, 02:31 PM
RE: Element 0 in arrays - by PhilOfPerth - 09-19-2023, 06:36 AM



Users browsing this thread: 1 Guest(s)