Nithin Bekal About

Notes / Io

Io is a prototype based language created by Steve Dekorte in 2002.

Animal := Object clone
Animal slotNames

Animal description := "not a plant"

Mouse := Animal clone
jerry := Mouse clone

Anything that starts with uppercase has a “type” slot. The jerry object doesn’t have this.

Animal type
Mouse type
mouse type

Animal slotNames
Mouse slotNames
jerry favoriteFood := "Cheese"

Mouse slotNames
jerry slotNames

Io calls parent object if a slot doesn’t exist.

jerry description
==> Not a plant
jerry description = "Super mouse"


Mouse hello := method("Scampers away" println)
jerry hello := method("Hello yourself" println)

jerry getSlot("hello")
==> method(...)

Get prototype of the object

jerry proto
==> Mouse
Mouse proto
==> Animal

The master namespace is called Lobby.

Basic rules

  • everything is an object
  • you send messages to objects
  • objects are created by cloning prototypes
  • objects remember their prototype
  • objects have slots (which are hashes/dicts)
  • slots can contain other objects or methods
  • a message returns value in a slot or invokes the method there
  • if the method is not present, the object passes it to prototype


ls := list(2, 4, 1, 3)
ls sort
ls sum
ls average
ls pop


capitals = Map clone
capitals atPut("India", "New Delhi")
capitals keys
capitals values
capitals at("India")


  • true, false, nil are singletons
  • Everything except false and nil are true
true clone
==> true
false clone
==> false

We can make our own objects singletons

Duck := Object clone
Duck clone := Duck
d1 := Duck clone
d2 := Duck clone
d1 == d2
==> true


if(cond, "true", "false")
i := 1
while(i <= 5, i println; i = i+1)

for(i, 1, 5, i println)

Operator table

==> ...

OperatorTable addOperator("xor", 11)
true xor := method(bool, if(bool, false, true))
false xor := method(bool, if(bool, true, false))