Iik

From IokeWiki
Jump to: navigation, search

IIk is the interactive Ioke prompt, which will run if you give no arguments to the ioke script. At the IIk prompt you can execute mostly all the same kind of code that could execute inside of an Ioke script file. The main difference is that this code will not be assigned to Ground, but instead will run in another context that is specific for the purposes of IIk.

IIk provides the possibility to exit using either "exit" or "close". Both of these will in fact signal a condition of kind "IIk Exit".

IIk will use readline if possible. That means that you can do the regular shell editing most other REPLs have support for, including using the up and down keys to scroll through earlier executed code.

IIk has a simple debugger that will be invoked when a condition is not handled. This debugger allows you to execute any kind of code and also to invoke restarts. As an example, the code below refers to a cell that doesn't exist. A condition is signalled and the debugger invoked. I choose to invoke the restart named useValue and provide the value 42. That value is returned and I'm back at the IIk prompt. In the next line I do the same thing again with the same name. This time I choose the storeValue restart and provide the value 43. And after that there exists a cell with the name foo and the value 43.

Iik> foo
*** - couldn't find cell 'foo' on 'Ground_0x26E9F9' (Condition Error NoSuchCell)

 foo                                              [<init>:1:0]

The following restarts are available:
 0: storeValue           (Store value for: foo)
 1: useValue             (Use value for: foo)
 2: abort                (restart: abort)
 3: quit                 (restart: quit)

 dbg:> 1
  dbg::newValue> 42
  +> 42


+> 42

iik> foo
*** - couldn't find cell 'foo' on 'Ground_0x26E9F9' (Condition Error NoSuchCell)

 foo                                              [<init>:1:0]

The following restarts are available:
 0: storeValue           (Store value for: foo)
 1: useValue             (Use value for: foo)
 2: abort                (restart: abort)
 3: quit                 (restart: quit)

 dbg:> 0
  dbg::newValue> 43
  +> 43


+> 43

iik> foo
+> 43

The Ioke debugger is quite powerful. If you were to execute any other Ioke code, that code will actually be executed in the context of the place where the condition was signalled. So it is possible to fix more complicated things in this manner too.