Functions vs Methods

BlitzMax Forums/BlitzMax Beginners Area/Functions vs Methods

JBR(Posted 2009) [#1]
Hi, just got BMAX and was using Banks.

It seems there are 2 ways to do the same thing

value = PeekInt( Bank, index )

value = Bank.PeekInt( index )


I guess I should be doing the Bank.PeekInt method.

Thanks
Jim


Brucey(Posted 2009) [#2]
Depends if you like a flat (function-based) API or an OOP (method-based) one.

I prefer using methods, but many people prefer the functions :-)


plash(Posted 2009) [#3]
It's all up to the programmer.

I prefer the Object-Oriented style (Methods).


JBR(Posted 2009) [#4]
Thanks guys, I'll use the Methods. A little faster in this case.

Jim


Gabriel(Posted 2009) [#5]
I guess you mean faster in the sense of faster to type, since functionally, they're the same.


Who was John Galt?(Posted 2009) [#6]
Not sure, I think the functions wrap the methods, so dependent on the compiler, there may be a little extra overhead.


Grey Alien(Posted 2009) [#7]
Functions are more like the basics of old days inc. Blitz Basic 2. They are easier to understand but it's better to embrace OOP and methods as it yields greater flexibility once you understand it (imho).


Gabriel(Posted 2009) [#8]
Not sure, I think the functions wrap the methods, so dependent on the compiler, there may be a little extra overhead.

You're right, of course. I thought the discussion was a general discussion of functions versus methods, rather than the BRL standard modules specifically, which implement both. BlitzMax has no ability to inline functions or methods, that I know of, so the BRL standard modules would indeed be faster to call unwrapped.