Private functions

BlitzMax Forums/BlitzMax Beginners Area/Private functions

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Yes it would be really nice. As Gfk said, most Max code circulating arraound uses the underscore prefix to identify private-like methods or functions.
There's another much more secure approach if you're working with modules you're planning to distribute and support, mixing private types with public types that internally deal with the privates one. It is a fast and a bit dirty approach but it works.
Public 
Type MyClass
    Field PrivateData:TMyPrivateClass = New TMyPrivateClass
    Method DoThis()
       PrivateData.Privatefield = 4555
       PrivateData.AnotherPrivatefield = 534
       Privatedata.PrivateFunction(34)
    End Method
End Type
Private
Type TMyPrivateClass
    Field PrivateField:int = 0
    field AnotherPrivateField:int = 0
    Function PrivateFunction(Value:int)
    ...
    ...
    ...
    End Function
End Type
Public


This example shows how to create a class that internally deals with a private class on a module. Module user's won't be able to modify the private data as the public field 'PrivateData' is seen as a 'Object' field from the programs importing the module, as the datatype of this field has been properly set as private.