What is the call_func() method in Euphoria?

Overview

The call_func is an inbuilt method in Euphoria. We call the euphoria function using its routine_id(). We can easily pass the method’s arguments into the call_func, which will call the user-defined Euphoria function defined by routine id.

Syntax

call_func(routine_id,args)
  • routine_id: This is an integer value representing the id of the called function. We can get the routine_id by using the routine_id().
  • args: This is the argument to be passed to the function whose routine_id must be returned.

Return value

The return value of the called function will be returned.

Code

function my_function(sequence name)
return "You are welcome to the" & name
end function
function my_favorite(sequence coding)
return "My favorite Learning is" & coding
end function
integer func1 = routine_id("my_function")
integer func2 = routine_id("my_favorite")
printf(1, "%s\n", {call_func(func1,{"Educative"})})
printf(1,"%s",{call_func(func2,{"Educative"})})

Explanation

  • Lines 1–6: We’ll use the call_func method to start and end two function blocks.

  • Lines 10–12: We’ll use the routine_id() method to get the id of the methods involved.

  • Lines 14–15: We display the outcome from the call_func() method.

Free Resources