Noob Q&A

BlitzMax Forums/BlitzMax Beginners Area/Noob Q&A

MGE(Posted 2007) [#1]
Long coding session, any help is appreciated, thanks!

1) What's faster to use, Float or Double?

2) What's the difference when calling a function:

DoThis(a,b,c)
DoThis a,b,c

3) When removing an object from a TList using Remove or RemoveLink, is the object gone or just the pointer to the object? (If I need to destroy the object after it's removed from the TList, how do I do that?)


GfK(Posted 2007) [#2]
1) Dunno - do a test of 10 million iterations or something to compare. I'd imagine Floats are faster, but less accurate.

[edit] Just did a quick test - identical results with add operations. Floats were slightly quicker for multiplication - 20ms faster over ten million iterations.

2) Clarity. That's all. However, if your function is returning a value, then you MUST use parentheses.

3) The pointer is removed. When no pointers to the object exist, garbage collection removes it.


QuietBloke(Posted 2007) [#3]
pipped to the post !

what Gfk said... though I didnt know about the returning value thing.. I always use parentheses so its never been an issue.


GfK(Posted 2007) [#4]
I always use parentheses so its never been an issue
Me too. As I said, I find it makes code easier to read.


MGE(Posted 2007) [#5]
Thanks guys, very much appreciated!


Grey Alien(Posted 2007) [#6]
Agree with GfK. didn't know floats were NOT faster though! Been avoiding doubles mostly. I know some people use bytes sometimes, what's the point! It's a 32-bit CPU!

I use parantheses all the time too.


MGE(Posted 2007) [#7]
Continuing with the noob sessions.... ;)

What's better to do?

a) Create a type that has 100 methods in it.

b) Create a type that passes (self) to 100 functions outside of the type?

I guess I'm wondering, if 1000 obejcts were created using the type, would there be 100 copies of the same routines in every object, taking up memory, etc? Thanks.


tonyg(Posted 2007) [#8]
or
c) None of the above.
If you have a type with 100 methods then you might want to consider whether that type can be split into seperate objects especially if the type has many attributes. This will make it more readable.
There's going to be no memory issues as only 1 copy of the method exists regardless of the number of instances.
I like BRL way of coding.
Standalone functions which take an object as a parm which then call the method. It seems to make more sense that way.


H&K(Posted 2007) [#9]
But if not C then A).
Cos the 100 methods will be picked up by Blide, and its code completion thing.

So you type the Type name press . and a list of these Hundred MEthods appear

Fiesld take up memory per object. Not functions or Methods


Grey Alien(Posted 2007) [#10]
methods not functions is my preference. A function that calls a method would seem extra slow.