Difference between a method and a function

BlitzMax Forums/BlitzMax Beginners Area/Difference between a method and a function

bstripp(Posted 2005) [#1]
Serrious coolness being able to assign functions to types. I can see lots of uses for that. However, I am trying to figure out what is the difference between a method and a function inside of a type...

I would use the search function to see if this has been asked before, but the search engine is down :(


Gabriel(Posted 2005) [#2]
This thread should answer your question :

http://www.codersworkshop.com/viewpost.php?id=16366


Bot Builder(Posted 2005) [#3]
Well, Global and Function can be placed into a type. There is no real difference between having them in the type and outside of the type. Its just these are sort of associated with a type itself, and not an instance of it. Methods are associated with a specific type because they can use fields of the type without using a handle in the syntax.

popular usage:
Type Car
 Global List:TList=new TList
 Field Speed#

 Method Gas()
  Speed=Speed+1
 End Method

 Function Create:Car(StartingSpeed#)
  local C:car=new car
  c.speed=startingspeed
  list.addlast(c)
  return c
 end function
end type

local c:car=car.create(5)
c.gas(5)



Cajun17(Posted 2005) [#4]
Having the function in a type lets you have functions of the same name within different types. They're just to help organize code as far as I can tell, which is a good enough reason for me.


SillyPutty(Posted 2005) [#5]
Arent Functions is a Type like Static functions in C/C++ ?


Dreamora(Posted 2005) [#6]
yes they are ... they are on Class level instead instance level