Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Delegates/Pop11/delegates.pop11
Normal file
32
Task/Delegates/Pop11/delegates.pop11
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
uses objectclass;
|
||||
define :class Delegator;
|
||||
slot delegate = false;
|
||||
enddefine;
|
||||
|
||||
define :class Delegate;
|
||||
enddefine;
|
||||
|
||||
define :method thing(x : Delegate);
|
||||
'delegate implementation'
|
||||
enddefine;
|
||||
|
||||
define :method operation(x : Delegator);
|
||||
if delegate(x) and fail_safe(delegate(x), thing) then
|
||||
;;; Return value is on the stack
|
||||
else
|
||||
'default implementation'
|
||||
endif;
|
||||
enddefine;
|
||||
|
||||
;;; Default, without a delegate
|
||||
lvars a = newDelegator();
|
||||
operation(a) =>
|
||||
|
||||
;;; a delegating to itself (works because Delegator does not
|
||||
;;; implement thing)
|
||||
a -> delegate(a);
|
||||
operation(a) =>
|
||||
|
||||
;;; delegating to a freshly created Delegate
|
||||
newDelegate() -> delegate(a);
|
||||
operation(a) =>
|
||||
Loading…
Add table
Add a link
Reference in a new issue