Inheritance pre-release 2
This update took a while to come out with and involved a lot of technical challenges which had to be overcome. The previous major update (1.3.0) addressed a lot of the core internal differences between the two branches, but I feel it's necessary to do this as a pre-release first to iron out bugs and make testing more accessible to those who want to.
Feedback, suggestions and bug reports for the update are welcome! Especially if you have any issues with the language design now is a good time to voice them so we can discuss before it's committed to a full release. If so please
make an issue or contact me on discord! (@novystar) You can also leave a comment on the current inheritance PR #5 which will remain unmerged until the full release.
Fixes/Changes since last pre-release:
- Fixed the origin of anonymous methods being inaccurate, leading to access-modifiers not behaving as intended
- Fixed super not using the context class for the inheritance walk, meaning super calls on anonymous methods would call themselves.
- Methods now support keyed returns
Additions:
- Single class inheritance
- New modifiers:
- protected - Restricted to subclasses and field definitions in new Class sections
- override - In order to override a method you need to use this or you'll get an error.
- abstract - Abstract classes can be extended directly in code anonymously, they may also contain abstract methods which have no body and must be implemented by any inheritor.
- final - Final classes can't be extended, final methods can't be overridden.
- Super method calls like super::method(), for accessing the non-overridden version of a method (from the previous class).
- Anonymous classes: abstract classes can be implemented directly in the new instance section (anonymous behaviour is erased on restart)
- A dedicated 'cast' expression for upcasting in strictly typed scenarios (like using type hints): {_var} as MyClass
Changes/fixes:
- The instance of condition now supports exact instance of for direct comparisons.
- Removed the belongs to pattern for class comparisons
- Method calls now support keyed return values
See the following wiki pages for a more in depth walk through of the new features for this update:
-
Inheritance Overview
-
Abstract & Anonymous