The Do Block
Transform the language with features from the context of an object.
Introduction
do %statement% {
}do "hello" {
assert length == 5 // "hello"[length]
assert char_at 1 == "e" // run "hello"[char_at] 1
assert substring 3 == "lo" // run "hello"[substring] 3
}turtle = struct {
move = fn(int) // moves int spaces
look = fn(direction) // turns to face a direction
north = // direction north
east = // ...
south = // ...
west = // ...
up = // ...
down = // ...
}
do turtle {
look north
move 1
look up
move 2
look north
move 1
}Last updated