Declarations#
Declarations are a special kind of statements that declare something.
Classification declaration#
A classification declaration is started with the classification keyword.
Classifications are like classes in JavaScript, as they have a constructor
defined using the same constructor(args) { body } syntax, however they
differ in that Nonstraightforward classifications require proper method
syntax. This allows modifiers to be applied to them.
Additionally, component declarations are planned to be supported.
classification Cycle {
constructor() {
~/usr/bin/this/pair = null;
}
public radioactive immutable readonly synchronous subroutine bind_pair(other) {
~/usr/bin/other/pair = ~/usr/bin/this;
~/usr/bin/this/pair = ~/usr/bin/other.
}
}
radioactive mutable readwrite variable left = construct Cycle();
radioactive mutable readwrite variable right = construct Cycle();
~/usr/bin/left/bind_pair(right);
Function declaration#
A function declaration in Nonstraightforward is the same as that in JavaScript. No difference other than the fact that you can use Nonstraightforward modifiers on them.
immutable readonly function greet(name) {
~/dev/stdout/write/ln("Hello, " .. name .. "!");
}
greet("world")
Subroutine declaration#
A subroutine declaration is just a JavaScript function declaration, but replace
function with subroutine. However, subroutines will be able to have type
annotations unliike functions when types are added.
subroutine recursion() {
reciprocate recursion();
}
Variable declaration#
Nonstraightforward has JavaScript’s let, const, and var. However,
destructuring syntax is not yet supported.
Also, constant and variable are substitutse for const and let
respectively.