It's a great day for AngelScript. WIP 5 has been released with first ever support for native arrays, which I'll describe in detail further down. First the list of changes in this WIP: * The C++ VM was optimized using the ideas introduced with the ASM VM. Because of the optimizing features of the MSVC compiler the C++ VM is now even faster than the ASM VM (about 10%). Later on the ASM VM will be optimized further as it is possible to remove quite a few instructions from each bytecode implementation even after the C++ compilers optimization. The ASM VM has potential to become twice as fast as the C++ VM, but 25% faster ought to be a realistic number. * The message "Invalid configuration" is now written to the output stream again if some of the registration functions failed. People kept forgetting to check the return codes, and got confused as to why the scripts didn't work. This might help pointing them in the right direction. * The operator 'xor' has been added for boolean types. An alias '^^' is also available. The operator does the exact same thing as '!=' does for boolean types, but it might be easier to understand in complex boolean expressions. * Native support for single dimensional arrays of any type has been added. They work perfectly for scripts, but cannot be passed to or from the application yet. The next WIP will complete this support. That's what has changed. Now here is the detailed explanation for how the arrays work. An array variable is declared as followed: int[] a; // empty array of integers object[] b(5); // 5 objects initialized with the default constructor The array's elements must be initialized manually at the moment: b[0] = GetObject("mace"); b[1] = GetObject("hammer"); ... An array can be passed by value or by reference to functions, but the internal array buffer is shared so it doesn't really make a difference except for a slight overhead of initializing the other array object when passed by value. void TestArray() { int[] a(1); a[0] = 1; ModifyArray(a); // a[0] will now be 0, even though the array object was passed by value } void ModifyArray(int[] a) { a[0] = 0; } The arrays have a default method length() that returns the number of elements in the array. int[] array; uint a = array.length(); The element access is out-of-bounds checked, so an exception is thrown if the script tries to access elements outside the allocated array. int[] array(10); array[10] = 3; // Throws "out of bounds" exception Let's see what more is needed to explain. The array indices are 0 based. You can declare an array of pointers, but you can't declare a pointer to an array. The object's registered destructor and assignment operator can't be virtual methods on GNUC based compilers, yet. MSVC should be able to handle virtual methods. The object's constructor can not be a virtual method on any compiler as one of it's task is to initialize the virtual function table for the object. What is still missing in the support for arrays: * Multi dimensional arrays. The script compiler may crash if you try to declare these at the moment. If the compiler doesn't crash the VM will. It hasn't been tested. I will probably not include support for multi dimensional arrays in version 1.10.0, maybe in 1.10.1. If I don't I will at least make sure the compiler gives the proper error messages, instead of crashing without warning. * Automatic initialization of arrays in declarations: int[] a = {23, 23, 4, 12, 5}; * Temporary array objects in expressions: Function(int[](10)); * Cleaning up the code * A C++ interface that allow the application to interact with script arrays * I will try to allow the application to extend the native array object with more methods and operators, e.g. resize(), copy(), push_back(), +, etc. * Support virtual destructor and assignment operators for the contained objects on all compilers In the future I will also allow the application to register specialized array objects that will override the built-in array. The benefit of this is that the application can have a much cleaner interface with the script when working with a specialized array object, it would for example be possible to register std::vector. The script writer wouldn't know the difference. I think that is all for now. Please let me know if you find any problems, or have any suggestions on how to improve the array support. Regards, Andreas Jönsson Author of AngelScript www.AngelCode.com AngelScript - AngelCode Scripting Library http://www.angelcode.com/angelscript/ http://www.angelcode.com/forums/