Eight tiny programs that take you from "Hello, World!" to objects — each one
runs today on the release build and prints exactly what you see below. They
live in this folder as real .wfl files, so you can run them yourself:
cargo build --release
target/release/wfl TestPrograms/docs_examples/tour/01_hello.wflEvery example here was run against the release binary, and the code blocks below match each program's real output. You can re-verify them yourself with the docs harness pointed at this folder:
python3 scripts/test_docs_code_blocks.py --docs TestPrograms/docs_examples/tourRead them in order — each builds on the last, and nothing you learn early has to be unlearned later.
1. Hello, World! — 01_hello.wfl
One line, no ceremony. display prints a line of text.
display "Hello, World!"
Hello, World!
2. Variables — 02_variables.wfl
store makes a variable; change updates it. Types are inferred, and you can
join values with with. Booleans are the friendly words yes / no.
store name as "Alice"
store age as 30
store is_member as yes
display "Name: " with name
display "Age: " with age
display "Member? " with is_member
display "age is a " with typeof of age
change age to age plus 1
display "Next year: " with age
Name: Alice
Age: 30
Member? yes
age is a Number
Next year: 31
Tip:
isis a keyword, so name booleansis_member, notis member.
3. Conditionals — 03_conditionals.wfl
Comparisons are words (is greater than or equal to). To chain choices, nest
the next check inside otherwise:.
store score as 82
check if score is greater than or equal to 90:
display "Grade: A"
otherwise:
check if score is greater than or equal to 80:
display "Grade: B"
otherwise:
display "Grade: C or below"
end check
end check
Grade: B
4. Loops — 04_loops.wfl
Three shapes: count from … to … (loop variable is count), for each … in …,
and repeat while ….
display "Counting to 3:"
count from 1 to 3:
display " count is " with count
end count
store fruits as ["apple", "banana", "cherry"]
display "Fruits:"
for each fruit in fruits:
display " " with fruit
end for
store n as 3
repeat while n is greater than 0:
display " liftoff in " with n
change n to n minus 1
end repeat
display " liftoff!"
Counting to 3:
count is 1
count is 2
count is 3
Fruits:
apple
banana
cherry
liftoff in 3
liftoff in 2
liftoff in 1
liftoff!
5. Lists — 05_lists.wfl
create list …: (note the colon) or a […] literal. Append with
push with <list> and <value>. Here we collect the even numbers.
create list evens:
end list
count from 1 to 10:
store remainder as count % 2
check if remainder is equal to 0:
push with evens and count
end check
end count
display "Even numbers 1..10: " with evens
display "How many: " with length of evens
Even numbers 1..10: [2, 4, 6, 8, 10]
How many: 5
Tip: compute
count % 2into a variable first —count % 2 is equal to 0written inline currently mis-groups (see issue #571).
6. Actions — 06_actions.wfl
Define with with parameters …. Call a value-returning action with of
(area of 4 and 5); run a side-effecting one as a statement with call.
define action called area with parameters width and height:
return width times height
end action
define action called greet with parameters who:
display "Hello, " with who with "!"
end action
display "Area 4x5 = " with area of 4 and 5
call greet with "world"
Area 4x5 = 20
Hello, world!
Tip:
area with 4 and 5does not call the action —withis string concatenation. Useof.
7. Error handling — 07_errors.wfl
Wrap risky work in try: and catch it with when error:. The caught message is
available as error_message. Execution continues afterward.
try:
store result as 10 divided by 0
display "result: " with result
when error:
display "Caught an error: " with error_message
end try
display "Program continues after the error."
Caught an error: Division by zero
Program continues after the error.
8. Containers (objects) — 08_containers.wfl
Declare property name: Type and action …: … end; close the container with a
bare end. Build an instance with create new … as …: and call methods with
parentheses.
create container Dog:
property name: Text
property tricks: Number
action show_info:
display name with " knows " with tricks with " tricks."
end
end
create new Dog as rex:
name is "Rex"
tricks is 3
end
rex.show_info()
Rex knows 3 tricks.
Where to next? The full guides live in Docs/.
Start with 01 Introduction and
03 Language Basics — their runnable
examples have been executed against this same binary. A few blocks in those
sections are intentional error demos or <placeholder> templates; the current
per-file status is tracked in
DOC_CODE_AUDIT.md.