Expand/Shrink

Dynamic Calls

These routines let you call Phix procedures and functions using a unique integer known as a routine_id, rather than by specifying the name of the routine.

Since 0.8.3, a plain xxx, not followed by '(', is equivalent to/treated by the compiler as routine_id("xxx"), and in a similar vein, after integer rid = xxx the compiler will treat rid(a,b,c) as call_func/proc[depending on context](rid,{a,b,c}). In other words routine(id)s became first class citizens in 0.8.3, and while much of what follows is strictly speaking OTT, it is probably still helpful to understand the basic mechanisms, which are all still at work, and occasionally can be more flexible, for instance call_func(rid,args) might cope with 3, 4, or 5 parameters in args, whereas rid(a,b,c) is quite obviously 3 and only 3 parameters, full stop. (OK, not quite full stop, should you be looking for the equivalent of (say) JavaScript’s "..." spread operator, that is when calling a routine, then call_func/proc implicitly achieves that).

routine_id (deprecated, as above) get a unique identifying number for a Phix routine
call_proc call a Phix procedure using a routine id
call_func call a Phix function using a routine id