what difference method and function?

BlitzMax Forums/BlitzMax Beginners Area/what difference method and function?

GuoQiang(Posted 2005) [#1]
what difference method and function in user defined types?


Bot Builder(Posted 2005) [#2]
A function in a type is a function associated with all of the types, in other words, there is no functionality difference. A function cannot access fields in a type without using a variable holding a type. Methods on the other hand refer to a specific type.

A popular use of functions in types is a "Create" function which creates a type from parameters and returns it.


FlameDuck(Posted 2005) [#3]
Methods apply directly to a single object, that is an instance of a type, while functions are more general, applying to the entire type.

The main difference is that methods implicitly contain a reference to the object it's being invoked on, and thus will have immediate access to all of the objects fields. A function on the other hand will only have immediate access to a types globals and constants.


GuoQiang(Posted 2005) [#4]
Thank you very much.