Re: RosettaCode
- Posted by jimcbrown (admin) Jan 26, 2011
- 1907 views
PeteE said...
Or instead of a routine-id, something that can be passed to call_func() that works. Here's my solution:
-- wrap the built-in call_func function function old_call_func(integer id, sequence args) return call_func(id, args) end function -- override built-in call_func to accept an object as the routine-id global function call_func(object id, sequence args={}) if sequence(id) then for i = length(id) to 1 by -1 do args = { call_func(id[i], args) } end for return args[1] end if return old_call_func(id, args) end function -- compose two routine-ids into a sequence that can be used with the above call_func global function compose(object f, object g) return {f,g} end function
The overriding call_func function here would need to be defined before including any libraries you would want to call with composed routine-ids.
This code won't work with 4.0, as you now have to use the override keyword. Even then, it's not possible to replace, override, or shadow eu:call_func().