Difference between revisions of "Talk:Agents in SCOOP"
Colin-adams (Talk | contribs) (New page: I use the first parameter in ROUTINE as a documentation hint in deferred classes with a single routine. --~~~~) |
Colin-adams (Talk | contribs) |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | I use the first parameter in ROUTINE as a documentation hint in | + | I use the first parameter in ROUTINE as a documentation hint, to specify the contract an agent is expected to fulfill. |
| + | |||
| + | That is, I declare the callback agent as having type ROUTINE [MY_CLASS, TUPLE [....]] | ||
| + | |||
| + | Then in MY_CLASS I declare a single deferred routine that conforms to the expected signature of the callback. | ||
| + | This routine is then equipped with contracts. | ||
| + | |||
| + | This serves as a hint to the user as to what the requirements of the callback actually are. If the user follows the hint by inheriting from MY_CLASS to implement the call back, then the contract is actually checked at runtime, and so provides an early warning of what the bug is. | ||
| + | |||
| + | So I find it usefull. | ||
--[[User:Colin-adams|Colin-adams]] 07:37, 21 March 2013 (UTC) | --[[User:Colin-adams|Colin-adams]] 07:37, 21 March 2013 (UTC) | ||
| + | |||
| + | ''[[User:Alexander Kogtenkov|Alexander Kogtenkov]] 07:45, 21 March 2013 (UTC):'' Could you provide an example? Isn't it too restrictive to require an agent to be based on a specific target? | ||
| + | |||
| + | It isn't restrictive, because a deferred class with a single deferred routine can be inherited as many times as you need, renaming the routine. | ||
| + | |||
| + | I don't have an example that I can post publicly, but I'll send one by email. | ||
| + | --[[User:Colin-adams|Colin-adams]] 07:02, 22 March 2013 (UTC) | ||
Latest revision as of 23:02, 21 March 2013
I use the first parameter in ROUTINE as a documentation hint, to specify the contract an agent is expected to fulfill.
That is, I declare the callback agent as having type ROUTINE [MY_CLASS, TUPLE [....]]
Then in MY_CLASS I declare a single deferred routine that conforms to the expected signature of the callback. This routine is then equipped with contracts.
This serves as a hint to the user as to what the requirements of the callback actually are. If the user follows the hint by inheriting from MY_CLASS to implement the call back, then the contract is actually checked at runtime, and so provides an early warning of what the bug is.
So I find it usefull.
--Colin-adams 07:37, 21 March 2013 (UTC)
Alexander Kogtenkov 07:45, 21 March 2013 (UTC): Could you provide an example? Isn't it too restrictive to require an agent to be based on a specific target?
It isn't restrictive, because a deferred class with a single deferred routine can be inherited as many times as you need, renaming the routine.
I don't have an example that I can post publicly, but I'll send one by email. --Colin-adams 07:02, 22 March 2013 (UTC)

