Delegates: Difference between revisions

Line 1,375:
function operation$ {
if not .delegate is .null then
ret$="Delegate implementation:"+.delegate=>operation$(![]) ' [] is the stack of values (leave empty stack), ! used to place this to callee stack
else
ret$= "Default implementation"
Line 1,394:
Class Thing {
function operation$(a,b) {
="Delegate implementation:"+str$(a*b)
}
}
Line 1,409:
Print Z=>operation$(2,30)
}
\\ Normal Group ' no logging to doc$
N=Thing()
Print N.operation$(2,5)
N1->N ' N1 is a pointer to a named group
Print N1=>operation$(2,5)
N1->(N) ' N1 now is a pointer to a float group (a copy of N)
Print N1=>operation$(2,5)
\\ using named groups (A is a group, erased when this module exit)
A=Delegator()
Line 1,443 ⟶ 1,450:
}
Version2
 
</lang>
[[Output]]
<pre>
Output:
10
10
10
Default implementation
Delegate implementation: 200
404

edits