September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
27
Task/Polymorphic-copy/Phix/polymorphic-copy.phix
Normal file
27
Task/Polymorphic-copy/Phix/polymorphic-copy.phix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
enum NAME, METHOD
|
||||
|
||||
procedure me_t()
|
||||
puts(1,"I is a T\n")
|
||||
end procedure
|
||||
constant r_t = routine_id("me_t")
|
||||
|
||||
procedure me_s()
|
||||
puts(1,"I is an S\n")
|
||||
end procedure
|
||||
constant r_s = routine_id("me_s")
|
||||
|
||||
type T(object o)
|
||||
-- as o[METHOD] can be overidden, don't verify it!
|
||||
return sequence(o) and length(o)=2 and string(o[NAME]) and integer(o[METHOD])
|
||||
end type
|
||||
|
||||
type S(T t)
|
||||
return t[METHOD] = r_s
|
||||
end type
|
||||
|
||||
S this = {"S",r_s}
|
||||
T that = {"T",r_t}
|
||||
|
||||
call_proc(that[METHOD],{})
|
||||
that = this
|
||||
call_proc(that[METHOD],{})
|
||||
Loading…
Add table
Add a link
Reference in a new issue