Arrays in User-Types

BlitzMax Forums/BlitzMax Programming/Arrays in User-Types

Id disagree that BlitzMax works like C++, its quite a bit different. Allocating even a struct in C is totally different to a Type in BlitzMax. BlitzMax, as you pointed out, only allocates pointers on the heap, its is expected that the user must provide all allocations - but this is counter intuitive, because BlitzMax uses a smart pointer and garbage collection system, yet it requires the user to alloc?

A simple example of why BlitzMax isnt even close to C.

struct Point2D { int x, y; }
struct Box2D { Point2D tl, br; }

In C if I declare an instance of Box2D, the members and the parent is created in its entirity. like so:

Box2D abox;

In Blitz:
Type Point2D
Field x:Int
Field y:Int
End Type
Type Box2D
Field tl:Point2D
Field br:Point2D
End Type

Now an instance of Box2D:

Global abox:Box2D

That only creates a pointer to abox, its not even an object, so lets build an object

abox = New Box2D

Now, all that has been created is an object with two pointers in it. We still need to allocate them.

abox.tl = New Point2D
abox.br = New Point2D

Now Im pretty sure you can see why it is nothing like C++ or even C for that matter. All the inheretence, polymorphism and overriding in the world cant help there. So, the best solution is to implement a New method in every user-defined type. Even in a small project (game) this increases the amount of extra code to write, and certainly I think has also lead to alot of users not being able to follow why they are getting 'null field' errors.

It actually irks me a little that people keep calling Type's class like, when quite obviously they are nothing of the sort. And also, the term references for objects, when clearly they are not references (since a reference is an address of an already allocated object) but pointers?

I have managed to get what I wanted working in BlitzMax, but I am left wondering why a Basic has so much extra workload especially when they have a memory managed system running?