Tuesday, July 29, 2008

miliseconds breaks from milestone rush

Getting busier nowadays as two millstone are approaching. I think is good to take a short break from my tiring journey and take down some notes about my experience in the last few weeks.

Actionscript 2.0
A simple and incomplete language. i found some shortcoming in this language. 1) no "protected" declaration, this make inheritance less useful in AS. 2) no virtual functions, strange, i could believe it until now, i may need to reconfirm this. 3) no static for variable in function 4) no constant 5) no enum 6) CANNOT define array in class for instance:

class test
{
public arr:Array = new Array;
}

the "arr" is shared among the "test" class instances. it behave same as c++ static property. the correct way to define it, is define it in class member function, constructor is a good place for that.

C++
I encountered a interesting problem in c++. e.g.

int *arr[2];

arr[0] = new int;
arr[1] = new int;

delete [] arr; // <= return error, claiming should use delete instead.

the correct way to use delete [] should be

int **arr;
arr = new *int[2];
delete []arr;

and i also found at interesting coding technique. e.g.

struct Player
{
Player(int age);
};

int addToGroup(Player np);

addToGroup(11); // <= it works without error! c++ compiler will create a player instance and feed in 11 as parameter

to disable this nice feature you have to do this

struct Player
{
explicit Player(int age);
};

ok, is 1am here, i should rest now for tomorrow milestone rush...

1 comment:

Nerrad said...

for the actionscipt array initialization problem, recently i found that Object also have similar problem, all Object should initializae in constructor as well