Plugins - qlova/ilang GitHub Wiki

Plugins are very powerful aspect oriented features of the i programming language.

In the following example, a data type can be modified with a backup on delete. Plugins always run before anything else in the original function, there can be multiple plugins and they run in the order they were imported.

Plugin file: (backup.i)

plugin delete(Data) {
    !var backup = open("backup.txt")
    backup(bytes)
    issues {
        print("Backup failed!")
    }
}

Main file:

import backup
type Data { []bytes }

method delete(Data) {
    bytes = []
}