Summary of changes implemented by the script:
- Separate data and interface: array elements and properties/methods are separated, and generic objects do not have array elements by default.
- Separate methods and properties.
- Separate static and instance members.
- New data types: Array (linear), Map (associative, type- and case-sensitive).
- Meta-functions are replaced with new meta-methods, which work more like normal methods.
- Different enumeration pattern: _NewEnum and Enumerator objects are replaced with __forin and function/closure objects (or an object with instead of ).
- Reduced multi-dimensional array support: Using multiple indices does not automatically create arrays of arrays.
- New exception type hierarchy.
- New error dialog with stack trace, formatting changes and a few shortcut buttons.
- New object model:
- Since static and instance members are separate, each class is split into the class itself (static members) and its .
- Each object (if under control of the library) ultimately inherits from .
- Each class which extends Object is actually an instance of Class (i.e. inherits from ).
- Properties and methods can be defined by calling methods on an individual object or a class's prototype.
- Methods are provided to test for the existence of a property or method.
Using the script
Read the included documentation before using the script.
For basic use of the script, #include Object.ahk (including only this file should not interfere with existing code).
To enable alterations to , , and , #include Object.Override.ahk.
To enable alterations to non-object values, #include Object.Values.ahk.
To enable the new error dialog, #include ErrorDialog.ahk (either include it in the auto-execute section or call ).
To #include any of these files, do one of the following:
- #Include by full/relative path.
- Place files directly in a Lib folder and use without .
- Place files in and use without .
- When defining a class, make sure it or a subclass of Object.
- When defining a class, do not place properties or methods directly inside the class. Instead, place them inside nested classes or as appropriate. The first time the class object is accessed or instantiated, these nested classes are automatically merged. These nested classes act as a substitute for a keyword which could hypothetically be applied to any property or method (instance members would be defined by default).
- To define a property and method with the same name (not recommended), create the property after the object is created (in __new or __initclass).
- Data/array element access should be done through instead of , except with Array, which supports both. Custom collection classes can define an property with parameter(s).
- To enumerate properties with , use . cannot accept an enumerator function/closure directly with the current implementation. Follow the same pattern for any other explicitly-called enumeration methods (for instance, if someone defines a method that returns a reverse-order enumerator).
- Replace SetCapacity, GetCapacity and GetAddress with a dedicated binary buffer type.
- Fix Array so that setting Length to a larger value does not cause the new last element to incorrectly be marked as having a value set.
- Other forgotten things.