Added an example to the main page

This commit is contained in:
2022-10-02 12:12:19 +11:00
committed by GitHub
parent fb632b7763
commit c4e49c4679

View File

@@ -8,6 +8,24 @@ The Toy programming language is a procedural bytecode-intermediate interpreted l
The host will provide all of the extensions needed on a case-by-case basis. Script files have the `.toy` file extension, while binary files have the `.tb` file extension. The host will provide all of the extensions needed on a case-by-case basis. Script files have the `.toy` file extension, while binary files have the `.tb` file extension.
```
fn makeCounter() { //declare a function like this
var total: int = 0; //declare a variable with a type like this
fn counter(): int { //declare a return type like this
return ++total;
}
return counter; //closures are explicitly supported
}
var tally = makeCounter();
print tally(); //1
print tally(); //2
print tally(); //3
```
# Nifty Features # Nifty Features
* Simple C-like syntax * Simple C-like syntax