2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,48 @@
#import system.
#import system'routines.
#class Operable
{
#method cast:verb &to:target
= target::verb eval &delegate:$self.
#method operate
= "delegate implementation".
}
#class Delegator
{
#field theDelegate.
#constructor new
[
theDelegate := nil.
]
#method set &Delegate:obj
[
($nil == obj)
? [ theDelegate := nil. ]
! [ theDelegate := obj. ].
]
#method operate
= theDelegate cast:%eval &to:
{
delegate : o = o operate.
! : o = "default implementation".
}.
}
#symbol program =
[
#var delegator := Delegator new.
($nil, Object new, Operable new) run &each: o
[
delegator set &Delegate:o.
console writeLine:(delegator operate).
].
].

View file

@ -0,0 +1,22 @@
Delegator := Object clone do(
delegate ::= nil
operation := method(
if((delegate != nil) and (delegate hasSlot("thing")),
delegate thing,
"default implementation"
)
)
)
Delegate := Object clone do(
thing := method("delegate implementation")
)
a := clone Delegator
a operation println
a setDelegate("A delegate may be any object")
a operation println
a setDelegate(Delegate clone)
a operation println