Language Specification
Variables
Variables are declared using the let keyword and are dynamically typed.
let name = "FlowLang-Script"
let version = 1
let pi = 3.14Data Types
- Integer: Whole numbers (
42,-10) - String: Text enclosed in double quotes (
"hello") - List: Returned by built-in functions like
range() - Dictionary: Returned by JSON parsing in HTTP responses
Operators
Arithmetic Operators
| Operator | Description | Example |
|---|---|---|
+ | Addition | 5 + 3 returns 8 |
- | Subtraction | 10 - 4 returns 6 |
* | Multiplication | 3 * 4 returns 12 |
/ | Division | 15 / 3 returns 5 |
Comparison Operators
| Operator | Description | Example |
|---|---|---|
< | Less than | 5 < 10 returns true |
> | Greater than | 10 > 5 returns true |
<= | Less than or equal | 5 <= 5 returns true |
>= | Greater than or equal | 10 >= 5 returns true |
== | Equal to | 5 == 5 returns true |
!= | Not equal to | 5 != 3 returns true |
Control Flow
If Statements
let age = 18
if age >= 18 {
print "Adult"
}While Loops
let count = 5
while count > 0 {
print count
let count = count - 1
}Functions
Functions are defined using the func keyword and support parameters and return values.
func add(a, b) {
return a + b
}
let result = add(10, 20)
print resultFunction Scope
Functions have their own local scope. Variables passed as arguments are local to the function.
func increment(x) {
let x = x + 1
return x
}
let value = 5
let newValue = increment(value)
print newValue # Prints 6
print value # Prints 5 (unchanged)Comments
FlowLang currently does not support inline comments. Use descriptive variable and function names for self-documenting code.