Well in fact we do have delegates in Quest 5. It's currently only implemented for object properties but could easily be expanded to variables as well.
It's basically an extension of the fact that an object property or variable can be a script. So you can have an apple's "eat" property as a script, and that's what runs when you eat the apple - exactly the same as you can do in Quest 4.
In Quest 5 you can declare that these script properties are delegate implementations. So far we're only using this for "adding to a container" functionality - take a look at the references to "AddScript" in the core libraries.
The declaration of the delegate is at the top of Core.aslx:
<delegate name="AddScript" parameters="object" />
Then the container_limited type has the following for its "addscript" property. Instead of type="script", we have type="AddScript":
<addscript type="AddScript">
children = GetDirectChildren(this)
if (listcount(children) >= this.maxobjects) {
msg (DynamicTemplate("ContainerFull", this))
}
else {
object.parent = this
msg (Template("Done"))
}
</addscript>
We're using a delegate here so that we can pass an object into the script. But the delegate declaration lets you specify a return value as well, just like any "normal" function, so you can return values from a delegate too.
To run a delegate, you can use the "rundelegate" script command (if it doesn't return a value) or the "RunDelegateFunction" function (if it does return a value).
At the moment, running a delegate with rundelegate/RunDelegateFunction requires you to pass in an object name and property name, but there's no reason why we couldn't overload these to allow you to pass in a variable instead.