Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
functions or subs?
#1
http://68.102.38.232:8080/forum/show.php...214517&u=1
url=http://www.random-seed.net][Image: asylumsig.png][/url]
Reply
#2
To be honest you can do either one. But the general idea is that if the routine returns something back to you (e.g. a calculated value, an error message, anything really) its a function. If it just does something and then comes back to the calling code, its a sub. Some languages (C for example) don't really have a difference (a sub is a function that doesn't return anything, it returns a VOID).

So for your 3d cube, my first gut thought would be to say a sub. BUT, if you want to return an error code (e.g. if it would be drawn offscreen for example) then maybe a function.

If you have to ask (because you are a beginning programmer, no insult meant) then go always go with a sub unless you KNOW you need to make a function. Why? Because its easier to go with a set rule until you understand why not to :-).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)