V2.2.x Feature Proposal: Additional Language Constructs
V2.2.x feature proposal for additional language constructs:
Here are few proposal for new language features. The definition is not fully formal, and not just high level.
Feature: Consts
Declare a struct/scenario/modifier member as const and give it a value.
For example:
struct jojo:
const five: int = 5
Main Execution Starting Point and container: top , top.main
The language today does not define the main entry point for execution. It is proposed to add a "top.main" scenario for that. The initial scenario that is run is always the scenario type top.main that has a single instance in the system that is called top.main.
In addition, we can discuss the relation between this container and global data.
Global Modifiers
One can define a modifier with the syntax: global modifier <modifier-name>. The modifier is instantiated automatically for every actor of that type.
Native methods !!!
One can define native methods in osc and write their code in osc:
def m() is:
...native-method-code...
And the relevant native method code items
List library expressions
A list of methods like elements that access/change and operate on lists.
Some examples:
var x: list of int
x.map(it.as(string)) #returns a list of strings with the same elements as strings
x.has(it > 5) #returns true iff x has an item greater than 5
String library expressions
A list of methods like elements that operate on strings. Some examples:
var x: string = "r, g, b"
x.split(",") #returns a list of strings ["r", " g", " b"]
x.replace(", ", "-") # replaces every occurrence of ", " with "-" result: "r-g-b"