This one adds several new features that should be quite useful.
First of all method and field resolving should work a bit better now. Also most error messages will now print the correct class in which the method or field lookup failed.
Anonymous classes:
You can now easily define an anonymous class that extends some existing class pretty much the same way as you would do in Java :
class "SomeClass" { bar = public - function() end; } local anonymous = SomeClass() { bar = public - function() -- this overrides SomeClass.bar end; }Note that these anonymous classes are treated as objects of the class they are extending. Any new methods that are added in the anonymous class that do not exist in the superclass won't be visible
Generic classes :
You can now specify a type parameter in the head of the class definition like so:
class "SomeClass" : T { someValue = public - T - nil; } -- also works with inheritance class "SomeClass" extends "SomeOtherClass" : T { ... } local obj = SomeClass[String](...)
Properties:
The property keyword should be pretty straightforward. Instead of directly setting and getting some value, the respective getter and setter methods are called when a property is accessed.
class "SomeClass" { x = public - property - String - "Hello World"; getX = function(self) ... end; setX = function(self,value) end; }
Some other changes:
- Attributes can be given certain types again, just specify the type like any other keyword: String, Table, boolean, thread, number.
- The type of an attribute can also be an existing class. Any object that is assigned to such an attribute is treated as an object of that class. That means, that the object must be castable to the given type.
- Calling getClasss() on an object will now return an instance of the built in Class class. That class offers some helper functions:
The installer is still the same:
pastebin run fq9fwb2S