Type function can't see type field - Why?

BlitzMax Forums/BlitzMax Programming/Type function can't see type field - Why?

Murilo(Posted 2010) [#1]
Right... I'm still getting back into the swing of all things "BlitzMax", but I'm a bit unclear on something. So far, I'm missing the clarity/familiarity of C#.

How do functions differ to methods in BlitzMax types?

Why can't the function see the field in the type in the following code?

Are functions static? That would make sense to me, as it wouldn't be able to see the instance field.

Is it possible to have private methods in a BlitzMax type?

Type TTest

	Field winMain:TGadget

	Function CreateMainWindow()
		winMain = CreateWindow(AppTitle, Null, Null, 300, 300, Null, WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_ACCEPTFILES)
	End Function

End Type



Gabriel(Posted 2010) [#2]
Are functions static?

Yep.

Is it possible to have private methods in a BlitzMax type?

Nope, I'm afraid it's not. It's been requested many times, but working access modifiers have not been provided. Currently, access modifiers work on a per-Type basis or per-file basis. Something like that anyway.

I believe the most common convention is to prefix private method/field names with an underscore. It is, of course, purely a token gesture, but it's supposed to indicate to a programmer that he should not be using it.


GfK(Posted 2010) [#3]
I'd like private methods too, but for now I prefix the method name with an underscore. That way I'll remember anything with an underscore before it should not be directly meddled with.

Not ideal, but its an option.


Murilo(Posted 2010) [#4]
Cheers guys. Thanks for clearing that up for me.


Zakk(Posted 2010) [#5]
Field only works for an instance of a Type if you want a Function to use it make it a Global.

...ooooor make the Function a Method, either works.