The Object Network

ONR - Object Network Rules

ONR, Object Network Rules, is a Functional Observer programming language for the Object Network.

Here's a quick intro to ONR. Start with this object:

{ is: notice
  text: "Welcome to ONR"
}

This is a notice (it says so!). It has the text shown.

Now suppose you wanted to write a ONR program to transform this object so it looks like the following:

{ is: notice
  text: "You can program!"
}

Here's a ONR rewrite rule that'll do it:

{ is: notice rule
  text: "Welcome to ONR"
        =>
        "You can program!"
}

ONR rules are themselves objects: they have "is: (something) rule" saying what kind of thing they're a rule for. The rest of the rule looks like the objects they are intended to work on - they try to match up, and if they match, their rewrites are activated. The rewrite is indicated by the symbol "=>" - pronounced "becomes". So this rule does match the first object, and rewrites it how we want.


Here's a simple Internet of Things example:

{ UID: uid-1
  Rules: uid-3
  is: light
  colour: 1 1 0
  light: 0.5.0.5 0
  dimmer: http://../uid-2
}

{ UID: uid-2
  is: dimmer
  setting: 0.5
}

{ UID: uid-3
  is: light rule
  light: => @colour × @dimmer:setting
}

This illustrates how the state of an object (uid-1's "light" property) depends on a pure function of its own state (the "colour" property) plus the state of another object (uid-2's "setting" property) observed through a link (uid-1's "dimmer" property).


For more real ONR code, have a look at this file on GitHub, which shows various other things in ONR that you'll need to write real-world programs, including how to link objects up and how to pick out bits of an object to build up a rewrite.

Duncan Cragg, 2016

Contact me and/or subscribe to my blog and/or follow me on Twitter.