How well will BlitzPlus code drop into BlitzMax?

BlitzPlus Forums/BlitzPlus Programming/How well will BlitzPlus code drop into BlitzMax?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

No problem, I can explain. This is simply a "automaticmemory allocation" vs "dynamic memory allocation". In C++ you have both.

Here you are doing automatic memory allocation (the object is allocated on the stack if you're in a function, and "statically" allocated once for all if it's outside any function). If you prefer, here p is treated as a "value object", ie a bit like primitive types (int, float, string) but if you'd allocated it on the heap (that is, dynamically), it would be an whole different story.

If I want to inherit things, then I guess the declaration needs to be more advanced than a simple "Player p;"
No, that's not that. It would very well work if Player was a derived classe. BUT, if you'd wanted to have "Player p" point to an "Enemy", you couldn't do it that way, at all. you'd have to allocate id dynamically (which will permit to have virtual methods working. With automatic allocation, it just doesn't work). So all in all, NO, it's not simpler in C++ (more powerfull, but you have to pay this power) as you have to
understand the differences between automatic and dynamic allocation and all the subtil implications.

In Blitz (like in Java btw) you only have dynamic allocation which is probably a good thing for such a language IMHO.


That said, there could very well be some kind of shortcut, a bit like you get an integer variable when you don't specify '%'. I'm not suer this would be any clearer though, and you still have to provide some proposition of good syntax for such a shortcut.