Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

euphoria
communitycreator

What is the call_proc() procedure in Euphoria?

NDUKWE CHIDERA K.

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

In Euphoria, the call_proc() method is a built-in procedure. This method calls the Euphoria procedure, defined by the user. It does this using the procedure’s routine_id.

The routine_id method is a unique identifier given to a procedure inside a program by which it can be referenced. We can find the procedure’s routine_id by passing the procedure’s name as a parameter to the routine_id() method.

Syntax

call_proc(routine_id, args())

Parameters

  • routine_id: This is an integer value. It is the id that uniquely identifies user-defined procedures in a program. We can get it by passing the procedure’s name as a parameter to the routine_id() method.

  • args : This is a sequence with all the arguments required by the procedure being called.

Note: If the provided routine_id is negative or unknown, the call_proc procedure will give an error.

Error will also occur if the args sequence parameter has a length not similar to the number of parameters required by the called procedure.

Important notes

  • The routine_id parameter must be a valid id returned by the routine_id() method.

  • The length of the args sequence must equal the number of parameters required by the procedure. Both default parameters have to be included as well.

  • If the called procedure doesn’t take an argument, then args should be an empty sequence ({}).

Return value

The call_proc is a procedure. In Euphoria, procedures have no return value. Therefore, call_proc has no return value, and it only executes the code in its execution block.

Code

procedure greetProc(sequence name)
sequence greet = "Hi " & name & " nice to meet you"
printf(1,"%s\n",{greet})
end procedure
procedure introProc(sequence coding)
sequence intro = "My favorite hobby is " & coding
printf(1,"%s",{intro})
end procedure
integer proc1 = routine_id("greetProc")
integer proc2 = routine_id("introProc")
call_proc(proc1,{"Pious"})
call_proc(proc2,{"swimming"})

Explanation

  • Line 1–10: We’ll define two procedures we want to call during the call_proc operation.

  • Line 13–15: We’ll obtain the routine_id of the earlier defined procedures.

  • Line 17–18: We’ll make indirect calls to these procedures using the call_proc() method.

RELATED TAGS

euphoria
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring