Io Programming/Pitfalls

Object initialization
A := Object clone do( ...  init := method( ... ) )

Now, you can use the  object, but the   object is not yet initialized (by the  method). The  method is only called when the  object is cloned. This can for instance "bite" you if you implement your own  method for an object.

Reading variables/slots that contains activable objects
If a variable/slot is assigned with an activable object, you need to use getSlot("varname") to get the same object. Otherwise, the object will be activated and you will get the result of the activation instead. One such activable object is a method.

For example, if you want to do some introspection, and inspect the methods of an object:

method_to_inspect := Object getSlot("asString") getSlot("method_to_inspect") code println method_to_inspect code println
 * 1) print the code of this method
 * 1) error, (Object asString), a String, doesn't understand the code message

Self Referential Prototype
Trying to set the prototype of an object to the object being contained by that object like this:

A := Object clone do( B := Object clone  B appendProto(A) )

Can cause IoVM to die with. You need to replace that code with something that looks like this:

A := Object clone A do( B := Object clone  B appendProto(A) )

A is known to the parser but has no sane value in memory in the first use, so it tries to append invalid memory to the list of prototypes. In the second form the slot is both known to the parser and also filled with a valid object, so it works.