const and Types

BlitzMax Forums/BlitzMax Beginners Area/const and Types

Jesse(Posted 2009) [#1]
anyone have an idea on how constants are handled. I am wondering if I put them in a type such as:
type TLarks
   Field x:int
   field y:int
   Const RECOVER:int = 3
end type

would it create an instace of the constant everytime I create an instance of Tlarks or would it be treated as a global and created only once no matter how many instances of Tlarks I create. my guess is that it creates only one but I just want to make shure.


Gabriel(Posted 2009) [#2]
AFAIK constants aren't "created" at all. The compiler inserts them into the compiled code directly, because they are, by name and nature - constant.


Jesse(Posted 2009) [#3]
I kind of knew that but the fact that you are able to assign a string value made me wonder. thanks.