YAPC::EU 2018 Glasgow Update!

This commit is contained in:
Ingy döt Net 2018-08-17 15:15:24 +01:00
parent 22f33d4004
commit 4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions

View file

@ -0,0 +1,30 @@
enum METHODS
function invoke(object o, string name, sequence args={})
--(this works on any class, for any function, with any number or type of parameters)
integer mdict = o[METHODS]
integer node = getd_index(name,mdict)
if node!=0 then
return call_func(getd_by_index(node,mdict),args)
end if
return "no such method" -- or throw(), fatal(), etc
end function
--class X: Xmethods emulates a vtable
constant Xmethods = new_dict()
function exists()
return "exists"
end function
setd("exists",routine_id("exists"),Xmethods)
--class X: create new instances
function newX()
return {Xmethods}
end function
object x = newX()
?invoke(x,"exists")
?invoke(x,"non_existent_method")