For global/Field:
- global variables in a type refer to the object
- field variables refer to the object instance
try this
For global variables in generale i don't have a fixed "rule"
Local variables in a function/method are variable that are deleted from the stack when the function call ends.
For starcount variable, it's the same. I like using length field for arrays because using a different variable for the same thing introduce a bit of redundancy. In C you don't know array size so you had to remember it with variables, bmax lets you know with length field or with Len() function.
- global variables in a type refer to the object
- field variables refer to the object instance
try this
SuperStrict Type foo Field fee:Int = 4 Global bar:Int = 4 Method getBar:Int() 'this should be a function IMHO Return bar EndMethod Method setBar(x:Int) 'this should be a function IMHO bar = x EndMethod Method getFee:Int() Return fee EndMethod Method setFee(x:Int) fee = x EndMethod EndType Local a:foo = New foo Local b:foo = New foo Print "a_fee: " + a.fee + "; a_bar: " + a.bar Print "b_fee: " + b.fee + "; b_bar: " + b.bar b.setBar(10) b.setFee(10) 'bar changed for a but i called only for b. 'fee is different Print "a_fee: " + a.fee + "; a_bar: " + a.bar Print "b_fee: " + b.fee + "; b_bar: " + b.bar
For global variables in generale i don't have a fixed "rule"
Local variables in a function/method are variable that are deleted from the stack when the function call ends.
For starcount variable, it's the same. I like using length field for arrays because using a different variable for the same thing introduce a bit of redundancy. In C you don't know array size so you had to remember it with variables, bmax lets you know with length field or with Len() function.