[Gambas-user] DIMing Arrays

Eilert eilert-sprachen at ...221...
Wed May 4 09:50:05 CEST 2005


Bonjour Benoit,

Benoit Minisini schrieb:
> On Tuesday 03 May 2005 17:25, nando wrote:
> 
>>Note that
>>
>>PRIVATE my_array AS NEW String[]
>>
>>will not compile/run if a space exists
>>between String and the [
>>
> 
> 
> Yes, this is a syntax error :-)
> 

Is this wanted or just "something we cannot make better":

In practice, there are many cases where something counts from 0 but is 
interpreted like 1, i. e. you will have to write a "- 1" here and there.

If you leave out the space, it is interpreted as a "-1" value, thus 
leading to error messages. From its context, one might expect the 
interpreter to interprete it as "x - 1", but even the editor doesn't as 
the colors will tell you when you leave the line.

You know what I mean?

For j = 0 to my_array.Count-1

won't do as it's interpreted as a "-1", and a "-1" doesn't belong there.

Or

t$ = Mid$(x$, i-1, 1)

won't do either.

In both cases (and from my vague understanding of the mechanisms) the 
parser will detect a "-1" because it's token-orientated and does not see 
the context.

Rolf





More information about the User mailing list