Projects/IoProgrammingWithPiranhas

edit
revisions

what's new
search
help

kiwi


Io programming with Piranhas

This document is a small introduction to using Io as a scripting language for Piranhas. By default, Piranhas applications should be written in Io, though you can if you want, use Piranhas as an Objective-C library and use either Objective-C or Io, or both.

Piranhas primitives in Io

The Io interpreter embedded in Piranhas comes with a set of new keywords, that allow to easily interface with Piranhas kernel:

  • kernel is a reference to the actively running Piranhas kernel
  • Execution is a reference to the current execution service
  • SIP is a reference to the current SIP service
  • Behaving is a reference to the current beahving service
  • action is a primitive that can be used as the block primitive is used, excepted that it will create a Io block wrapped into a Piranhas executable. The action is not executed until you give it to either call or delay (see below).
  • action1 is equivalent to action execpt that the action will take an argument when executed.
  • call directly submits an action to the Piranhas execution engine. This operation is asynchronous, which means that it won't return any value and won't execute directly.
  • delay is the same as call, but takes a decimal value expressing the delay (in seconds) before the action gets executed

Apart from these specific primitives and objects, any Objective-C class and instance is directly accessible in Io.

For instance, you could call the [PKernel? kernel] method in Io by doing PKernel? kernel.

Io and Objective-C

Io is really well integrated with Objective-C, however there are a number of things that should be taken care of:

  • Objective-C objects created directly from Io code (either from alloc or by class-level factory methods) are all retained. This means that newly allocated objects must be release to avoid memory leaks.
last modified on September 27, 2005, at 03:35 PM

© type-z.org and its contributing authors, 2001-2004.
Content is licensed under a Creative Commons License.