nitrogen
nitrogen copied to clipboard
Type Annotations
Allow functions to specify types for parameters. Types will be checked at compile time as much as possible. Types that can't be checked then will be checked at runtime. This will reduce the amount of runtime overhead as much as possible. The type checking step can be done with the AST as it specifies internal object types. Any parameter or return value not specified will default to the Any type.
The following types can be supported:
- Primitives (ints, strings, floats, etc.)
- Classes
- Interfaces
Syntax
fn example(s: string, i: int): bool {}
interface SomeInterface {
fn method(s: string): string
}
fn example2(obj: SomeInterface): void {}