Initialise a Const Array

BlitzMax Forums/BlitzMax Programming/Initialise a Const Array

Grey Alien(Posted 2008) [#1]
Pretty sure I've asked this before but can't find it using search or google.

Can anyone explain why this compiles:

Global PowerupMapping%[]=[0,1,2,3,4,5,6,7]


but this fails with "Constant initializers must be constant"

Const PowerupMapping%[]=[0,1,2,3,4,5,6,7]


So instead of [] I tried:

Const PowerupMapping%[8]=[0,1,2,3,4,5,6,7]


and it says "Constants must be initialized". hmm

It's no big deal, just perplexing as to what the correct syntax is (if any). Perhaps it's not supported.


Azathoth(Posted 2008) [#2]
Don't think you can use const arrays.


Grey Alien(Posted 2008) [#3]
Yeah I think that's what we concluded before, I just keep forgetting...


Dreamora(Posted 2008) [#4]
There is no const for objects.
An object is just a reference and is allocated at runtime so it can not be const, which is set at compile time.


Grey Alien(Posted 2008) [#5]
Fair enough.