update dynamic 2

Documentation Version for Comments and Changes

You are invited to make any changes...add any comments.

Changes will `eventually` be merged into the offical documentation.

Leave any commnents here...


... back to index page OE documentation

include std/pretty.e

constant pretty_id = routine_id("pretty_print")

call_proc(pretty_id,{1, some_object, some_options}) </eucode>

This does the same as a straightforward

include std/pretty.e 
pretty_print(1, some_object, some_options) 

The difference with c_proc is that you can call an external function using c_proc and thus ignore its return value, like in C. Note that you cannot use call_proc to invoke a Euphoria function, only C functions.

Why Call Indirectly?

Calling functions and procedures indirectly can seem more complicated and slower than just calling the routine directly, but indirect calls can be used when the name of the routine you want to call might not be known until run-time.

integer foo_id 
function bar(integer x) 
    return call_func(foo_id,{x}) 
end function 
function foo_dev1(integer y) 
	return y + 1 
end function 
function foo_dev2(integer y) 
	return y - 1 
end function 
function foo_dev3(integer y) 
	return y * y - 3 
end function 
function user_opt(object x) 
end function 
-- Initialize foo ID 
switch user_opt("dev") do 
	case 1 then 
		foo_id = routine_id("foo_dev1") 
	case 2 then 
		foo_id = routine_id("foo_dev2") 
	case else 
		foo_id = routine_id("foo_dev3") 
end switch 

One last word: when calling a routine indirectly, its full parameter list must be passed, even if some of its parameters are defaulted. This limitation may be overcome in future versions.

Calling Euphoria Internals

A number of Euphoria routines are defined in different ways depending on the platform they will run on. It would be cumbersome, and at times downright impossible, to put such code in include files or to make the routine fully builtin.

A solution to this is provided by machine_func and machine_proc.

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu