Tour

Zero to running a polymorphic gawk program. Real prompts, real output, copy-pastable.

1

Install gawk

$ brew install gawk        # macOS
$ sudo apt install gawk    # debian/ubuntu
2

Install the binary

$ curl -sL https://raw.githubusercontent.com/timm/awk/master/dot/dot -o dot
$ chmod +x dot
$ ./dot --demo hello
n=5 mean=30.000

One file. Bundles the preprocessor, runtime, and helpers as heredocs.

3

Write a one-line dot program

No objects yet — just the preprocessor's two rules:

$ cat > tour1.awk <<'EOF'
BEGIN { .me.name = "tim"; .me.job = "prof"
        print .me.name, .me.job }
EOF
4

See what dot rewrites it to

$ ./dot -c tour1.awk
BEGIN { HEAP[me]["name"] = "tim"; HEAP[me]["job"] = "prof"
        print HEAP[me]["name"], HEAP[me]["job"] }

Two rules: .me.nameHEAP[me]["name"]; bare .meHEAP[me].

5

Run it

$ ./dot tour1.awk
tim prof

The dot binary preprocesses the file in a tempdir, then gawk -f's it for you.

6

Add an object

A running mean using new() from dot's runtime:

$ cat > tour2.awk <<'EOF'
BEGIN { N = new("plain") }
      { .N.n++; .N.mu += ($1 - .N.mu) / .N.n }
END   { printf "n=%d mean=%.2f\n", .N.n, .N.mu }
EOF
$ printf "10\n20\n30\n40\n50\n" | ./dot tour2.awk
n=5 mean=30.00

What happened: new("plain") allocated ID 1, set HEAP[1]["is"]="plain". Each row updated .N.n and .N.mu. END printed them. No type system needed — just struct sugar over HEAP.

7

Where to go next

Examplehello.awk walkthrough with pre/post rewrite tables.
Tests — annotated test suite, doubles as 26 mini usage snippets.
Manual — preprocessor rules, runtime API, conventions, limitations.
dotcols — Num/Sym/Data column types on top of dot.
dotlearn — ML on top of dotcols: trees, naive Bayes, active learning.