Page 1 of 1

Array of BoundedString, Declare speed

Posted: 17 March 2009, 12:54 PM
by sturgessb
Just a quick one...

What is the reason for this refusing to compile..

Code: Select all

PUBLIC sa(1 to 15) as BOUNDEDSTRING(20)
I dont see anything in the docs about not being able to use boundedstring in array, is this the case?

Also, is there any theoretical speed difference between the following two block of code..

Code: Select all

Do
    Dim tempvariable as INTEGER
Loop
and...

Code: Select all

Dim tempvariable as INTEGER
Do
    tempvariable = 0
Loop
So basically is it any quicker to set a variable value to 0 or lets say "" for a string, than declaring the variable again to reset it?


Cheers

Ben

Re: Array of BoundedString, Declare speed

Posted: 17 March 2009, 13:16 PM
by dkinzer
sturgessb wrote:I dont see anything in the docs about not being able to use boundedstring in array, is this the case?
You can define arrays of bounded string types and the ZBasic compiler proper accepts it. There appears to be a code generation issue for accessing an element of an array of bounded strings in native mode; the back-end compilation process generates an error.
sturgessb wrote:Also, is there any theoretical speed difference between the following two block of code.
For variables that don't get special initialization treatment (such as Integer, Byte, etc.) there should be no difference. For variables that do get special initialization/deinitialization treatment (such as String) having the definition outside of the loop would reduce the number of times the variable is initialized and deinitialized.

Posted: 17 March 2009, 15:02 PM
by sturgessb
Great thanks Don. So with regards the the bounded string issue, so are you saying thats a problem with the native compiler not something I'm doing?

Posted: 17 March 2009, 16:23 PM
by dkinzer
sturgessb wrote:So with regards the the bounded string issue, so are you saying thats a problem with the native compiler not something I'm doing?
That's my contention. The error message that I'm seeing indicates that one or more errors occurred during the back-end build process. That is indicative of a code generation issue. If it were something that you were doing incorrectly in your code, it would never get as far as invoking the back-end compilation process.

If you're seeing a different error message, then we're not on the same page yet. Usually, a minimal example that replicates the issue is very helpful to ensure that we understand one another.

Posted: 17 March 2009, 16:30 PM
by sturgessb
Yeah to confirm thats the same error I am getting.