Future Features
This section covers future features of the OneScript language.
Type Inference
Instead of using a specific declaration type for a variable it will be possible to use the var
keyword if the type of the variable can be inferred by its use.
The example above show a direct inference for the variable a
and a deferred inference for the variable b
. As long as the inference can be made the compilation will be successful.
Collection Improvements
Iterators
All arrays will support the foreach
statement block.
Dictionaries
Dictionaries support an indexed array for fast searching.
Class Improvements
Properties
Support for properties like many other languages.
In the above example there are a number of new keywords to denote the getter and setter of a property. For a setter the value keyword is automatically given the inbound value.
Abstract Classes
The ability to create a template class that can be inherited by other classes to support the idea of refactoring code.
In the above example it is possible to define methods with no block. These have to be fulfilled in the classes that inherit it.
Inheritance
Class Inheritance supported in many other languages improves refactoring of code.
the above example introduces the new keyword base
. This refers to the base class that is inherited.
Interfaces
It is possible to define an interface listing the public properties and methods. This can be inherited by a class and then used as the template for that class. It's real benefit is the adoption of an interface by multiple classes so they can all be handled in a common way.
Asynchronous Programming
Whilst libraries used with OneScript support asynchronous programming the language itself does not. Methods can be made asynchronous with the async
keyword and asynchronous methods can be called asynchronously with the await
keyword.
Last updated