Globals and differences when in Types or not?
BlitzMax Forums/BlitzMax Beginners Area/Globals and differences when in Types or not?
| ||
This may sound stupid but I have noticed different behaviour between a global put in a Type and a global on its own. Is there a Difference between TYPE Globals and Globals on there own? Shoot the noob if you must :/ |
| ||
Guessing from my experiences with Java, I'ld say there's no difference between the two, except in the way you access them - I'ld imagine the only thing that determines where you place your globals depends on how you modularise your code - globals specific to a certain program would be placed outside of types, whereas globals required by a certain class should be placed within the type declaration to promote modularity. For example, a mathematical module may have the global PI in it's declaration, whereas a graphics resolution for a certain game would be made a global for the program. *Aims gun*...BANG! Ryan [EDIT] I mean constants for the above of course, but you get the idea. |
| ||
Hi, I'm Amons Sister. He cant reply now because someone shot him. |
| ||
Are you available? [EDIT] *Wonders whether he should retract the above question*. Meh, I'll let it stand. Ryan |
| ||
I'm only available on weekends when they let me out in the sunlight. I'm quite ugly looking. P.S I'm fat But me love you long time.. mwahh XXX |
| ||
This could be the start of a beautiful relationship. Ryan |
| ||
So wait, a global in a type is accessed by doing MyType.Globalvar? Wow, thats really useful - it means all members of a type can have a global register and all have access to each other, for example particles can coordinate, etc. |
| ||
You could consider it a way to set up enumerations. i.e. Type BorderStyles Const None = 0 Const Solid = 1 Const Dashed = 2 End Type You can then use BorderStyles.Solid later on in your program to reference the solid border style. By doing it this way, you can later extend your BorderStyles type to add more styles. BTW: Don't feel bad about only being let out on weekends. When I was a baby I was so ugly my parents had to tie a pork chop around my neck just to get the dog to play with me. Ba Dump Bump! -Jim |