Can you create fields or variables that are local only to the user defined type? In this instance I want to create a map type that has an array that's local to the type and not exposed to the rest of the program. The rest of the program never has need to use the map[x,y,z] array and thus I don't want to expose it.
variables local only to the type instance
BlitzMax Forums/BlitzMax Programming/variables local only to the type instance I thought that the rest of the program could access any fields just by doing something like:
I was wanting something like:
Note the local declaration which would make it local to the type only. Doing a var1.map[5,5,5] = 1 would result in an error because it's not exposed to the rest of the program.
Type Blah Field x:Int End Type Var1:Blah = New Blah Var1.x = 23
I was wanting something like:
Type Blah Local map:Int[,,] Method InitializeMap(x:Int, y:Int, z:Int) map = New Int[x, y, z] End Method End Type Var1:Blah = New Blah Var1.InitializeMap 20,20,10
Note the local declaration which would make it local to the type only. Doing a var1.map[5,5,5] = 1 would result in an error because it's not exposed to the rest of the program.
Can't be done. BlitzMax doesn't let you specify the 'visibility' of parameters to other elements.
Can't be done. BlitzMax doesn't let you specify the 'visibility' of parameters to other elements.
Well smack me and call me Susan. That kinda sucks.
I know, and I'm telling you it can't be done.
Watch the lip or I'll smack YOU and call you susan. :D
How the hell did you get that reply in before mine?
magic
BM allows private stuff in a restricted way at least. It works for modules, if you make clear, that other objects must not inherit from your objects.
ParticleDreams is built up like that for example to prevent "user modification" at runtime.
ParticleDreams is built up like that for example to prevent "user modification" at runtime.
Var1:Blah = Blah.create() Var1.InitializeMap 20,20,10 End Type Blah Function create:Blah() Return Blah(Blah_Imp.create()) End Function Method InitializeMap(x:Int, y:Int, z:Int) Abstract End Type Private Type Blah_Imp Extends Blah Field map:Int[,,] Function create:Blah_Imp() Return New Blah_Imp End Function Method InitializeMap(x:Int, y:Int, z:Int) map = New Int[x, y, z] End Method End Type