Array of BoundedString, Declare speed

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
sturgessb
Posts: 287
Joined: 25 April 2008, 6:34 AM
Location: Norwich, UK

Array of BoundedString, Declare speed

Post 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
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Array of BoundedString, Declare speed

Post 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.
- Don Kinzer
sturgessb
Posts: 287
Joined: 25 April 2008, 6:34 AM
Location: Norwich, UK

Post 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?
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post 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.
- Don Kinzer
sturgessb
Posts: 287
Joined: 25 April 2008, 6:34 AM
Location: Norwich, UK

Post by sturgessb »

Yeah to confirm thats the same error I am getting.
Post Reply