Touch Develop retirement postponed until June 22, 2019. Sign-in and access to cloud assets to be removed on May 23, 2018.Learn More..

extension actions

An action, which takes a user-defined record type (object, table or index entry) as the first argument can be invoked as an instance member. This also works in libraries.


We define an object type obj an action that modifies it:
date description : String
some data : Number
atomic function
set to current
obj : ⌹ obj)
obj → date description := time → now → to string
end function
We can now create an object instance and call the action on it:
var obj :=  obj → create
obj → set to current
This second line has the same effect as:
 set to current(obj)
This is particularly useful when set to current sits inside a library - instead of some library→set to current(x) we can just say x→set to current.


It is often the case that you have a pair of actions that get and set some property, for example:
atomic function
obj : ⌹ obj)
returns (
dt : DateTime)
dt := obj → date description → to datetime
end function
atomic function
set date
obj : ⌹ obj,
s : DateTime)
obj → date description := s → to string
end function
In such case you can use assignment := operator instead of calling set date:
obj → date := obj → date → add days(1)
The line above is the same as:
obj → set date(obj → date → add days(1))
Again, this is particularly useful when writing libraries.


Some restrictions apply.
  • The actions have to be called x and set x, where x is any string. get x and set x will not do
  • Both actions have to be atomic
  • The setter cannot return any value
  • The type returned by the getter and consumed by the setter need to be the same