The Crow Programming Language

Variables

A variable is created by assigning to it. No keyword, no type annotation:

1
2
3
4
count = 10
name = 'crow'
ready = true
log[count]

expected output — from the book, verified by crow test --book

10

Reassignment is fine — but a variable's type cannot change:

items = [1, 2, 3]
items = 'three things'    --- error: cannot reassign from array to string

The one deliberate loosening: a variable ever assigned a float is a float for its whole scope, because numeric code mixes 10 and 3.14 constantly:

1
2
3
x = 10
x = 3.14
log[x]

expected output — from the book, verified by crow test --book

3.14

Multiple assignment and swap work as you'd hope:

1
2
3
4
a, b = 1, 2
a, b = b, a
log[a]
log[b]

expected output — from the book, verified by crow test --book

2
1

One rule you'll meet early: names you define can't collide with names the language owns. range = [1, 2] is a compile error (range is a core builtin), and after use math, so is sum = 0. The error always says what to do — rename, or import the module under an alias. Chapter 8 covers the full story.