Delegates: Difference between revisions

Content added Content deleted
Line 1,360: Line 1,360:
=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
<lang M2000 Interpreter>
<lang M2000 Interpreter>
Module Version2 {
Module Version3 {
\\ Third version including using the object without delegate.
\\ Second version
\\ the delegate is a pointer to group
\\ the delegate is a pointer to group
\\ 1. We pass parameters to function operations$(), $ means that this function return string value
\\ 1. We pass parameters to function operations$(), $ means that this function return string value
Line 1,411: Line 1,411:
\\ Normal Group ' no logging to doc$
\\ Normal Group ' no logging to doc$
N=Thing()
N=Thing()
Print N.operation$(2,5)
Print N.operation$(10,20)
CallbyReference &N
CallbyValue N
N1->N ' N1 is a pointer to a named group
N1->N ' N1 is a pointer to a named group
Print N1=>operation$(2,5)
Print N1=>operation$(10,20)
CallbyReference2 &N1
CallbyValue2 N1
N1->(N) ' N1 now is a pointer to a float group (a copy of N)
N1->(N) ' N1 now is a pointer to a float group (a copy of N)
Print N1=>operation$(2,5)
Print N1=>operation$(10,20)
CallbyReference2 &N1
CallbyValue2 N1
\\ using named groups (A is a group, erased when this module exit)
\\ using named groups (A is a group, erased when this module exit)
A=Delegator()
A=Delegator()
Line 1,449: Line 1,455:
Clipboard Doc$
Clipboard Doc$
}
}
Version3
Version2



</lang>
</lang>
Line 1,455: Line 1,462:
<pre>
<pre>
Output:
Output:
10
200
10
150
10
60
200
150
60
200
150
60
Default implementation
Default implementation
Delegate implementation: 200
Delegate implementation: 200