Int to Object

BlitzMax Forums/BlitzMax Programming/Int to Object

MattVonFat(Posted 2006) [#1]
Hi,

I may just be suffering from sleep deprivation or something but I thought Int extends from Object which means I can pass an Int to a function parameter which is an Object?

I tried passing an Int to the extra parameter of AddGadgetItem which is an Object and it told me it couldn't convert an Int to an Object. I now have a Type which just has an Int field so I can pass that instead. Surely if I can pass my Type I can pass an Int?

I'm not completely with it today so I might just be confused but I was sure it worked before. I also did a syncmods to see fi that helped but it didn't.

Thanks for any help you can give,
Matthew


tonyg(Posted 2006) [#2]
No, Int does not extend from Object.


H&K(Posted 2006) [#3]
Hi Matt

This confused me as well. There is a fundimental difference between Base Types and Objects in the way they exist in BMax.
The difference mean
1) You can extend objects, but you cannot extend base types.
2) Every type is extended from "Object" except base types. And so if a function expects an "Object", you cannot pass it a base type
3) Objects/Types are passed by pointer to functions, but Base Types are passed by refferance. (I think)

There are probably more differences.


MattVonFat(Posted 2006) [#4]
Thanks, I can still do what I want but it's just got to be slightly more annoying :)

Thanks,
Matt


H&K(Posted 2006) [#5]
Matt if you want to change as little as possible just
Type NInt
Field Value:Int
End Type

Edit: Mind this is more trouble than its worth