Syntax

Syntax & Basic Types

Comments


         x = 10; # Inline comment
    

Data Types

Variables & Constants


# Variables
x = 10;

# Constants
constant PI = 3.14;
    

Scope & Visibility

Fahrenheit uses block scoping. Modifiers control visibility:

Operators

Standard arithmetic (+, -, *, /, %), comparison (==, !=, >, <, >=, <=), and logical (&&, ||, !) operators are supported.

Compound Assignment: +=, -=, *=, /=

Ternary Operator: condition ? val1 : val2

Strings

Interpolation: "Hello ${name}!"

Multiline: Use triple quotes """ or '''. Multiline strings preserve whitespaces and newlines.

Enumerations

Use the enumerated keyword for fixed sets of constants.


enumerated Status { PENDING, ACTIVE, INACTIVE }

status = Status.ACTIVE;
if (status == Status.ACTIVE) {
    print("User is active");
}
    

Control Flow

If-Else


if (x > 5) {
    print("High");
} else {
    print("Low");
}
    

Loops


# While
while (i < 5) { i = i + 1; }

# For
for (i = 0; i < 10; i++) { print(i); }

# Foreach (Arrays & Strings)
foreach (item : list) { print(item); }
    

Switch


switch (val) {
    case 1: print("One"); break;
    default: print("Other");
}
    

Exception Handling


try {
    throw "Error";
} catch (e) {
    print("Caught: " + e);
} finally {
    print("Cleanup");
}