Complete mapping between classic and natural forms. Both compile to identical AST nodes.
Classic Natural Description
let x = 5set x to 5Immutable binding
let mut x = 0set mut x to 0Mutable binding
x = 10change x to 10Reassignment
let {a, b} = objunpack {a, b} from objDestructuring
// Classic
let name = "Alice"
let mut count = 0
count = count + 1
// Natural
set name to "Alice"
set mut count to 0
change count to count + 1
Classic Natural Description
fn add(a, b) { }define add(a, b) { }Function definition
async fn fetch() { }forge fetch() { }Async function
return valuereturn valueReturn (same in both)
// Classic
fn greet(name) {
return "Hello, " + name
}
// Natural
define greet(name) {
return "Hello, " + name
}
Classic Natural Description
else { }otherwise { }Else branch
else { }nah { }Else branch (casual)
else ifotherwise ifElse-if branch
// Classic
if x > 0 {
say "positive"
} else if x == 0 {
say "zero"
} else {
say "negative"
}
// Natural
if x > 0 {
say "positive"
} otherwise if x == 0 {
say "zero"
} nah {
say "negative"
}
Classic Natural Description
println("text")say "text"Print with newline
print("text")print("text")Print without newline
– yell "text"Print uppercased
– whisper "text"Print lowercased
Classic Natural Description
struct User { }thing User { }Struct definition
impl User { }give User { }Method implementation
interface Printable { }power Printable { }Interface definition
enum Color { }craft Color { }Enum definition
// Classic
struct User {
name: string,
age: int
}
impl User {
fn greet(self) {
say "Hi, I'm " + self.name
}
}
// Natural
thing User {
name: string,
age: int
}
give User {
fn greet(self) {
say "Hi, I'm " + self.name
}
}
Classic Natural Description
async fn x() { }forge x() { }Async function
await exprhold exprAwait an async value
yield valueemit valueYield from a generator
fetch("url")grab resp from "url"HTTP fetch
// Classic
async fn get_data() {
let resp = await fetch("https://api.example.com/data")
return resp
}
// Natural
forge get_data() {
let resp = hold grab data from "https://api.example.com/data"
return resp
}
Classic Natural
match value { }match value { }
when value { }when value { }
Both match and when are available; when supports guard-style syntax unique to Forge (see Innovation Keywords ).
Classic Natural Description
has InterfaceNamehas InterfaceNameInterface conformance assertion
The has keyword asserts that a type satisfies an interface at the point of declaration.