Open main menu

Wikibooks β

Io Programming/Pitfalls

< Io Programming

Contents

Subtle Io pitfallsEdit

Object initializEdit

 )
)

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

Reading variables/slots that contains activable objectsEdit

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")

# print the cod

BugsEdit

Self Referential PrototypeEdit

Trying to set the prototype of an object to the object being contained by that object lik


Can cause IoV Fault. You need to replace that code with something that looks like this:


 B := Object cl
)

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.