Post Reply 
Prime: defining functions in a program
12-23-2013, 01:26 AM (This post was last modified: 01-26-2014 09:46 PM by patrice.)
Post: #1
Prime: defining functions in a program
Exemple source code
Code:

Func3(Ab); // Func3 declaration
EXPORT Func4(); // Func4 declaration

EXPORT Func1() // Func1 definition
BEGIN
Func3(1); // Func3 call
Func4(); // Func4 call
...
END;

Func2() // Func2 definition
BEGIN
...
END;

Func3(Ab) // Func3 definition
BEGIN
Func2(); // Func2 call
...
END;

EXPORT Func4() // Func4 definition
BEGIN
Func3(3); // Func3 call
...
END;
Every function that is used before being defined must be declared before its use.
Respect function parameters in declaration
Func3 and Func4 are declared because they are used before being defined.
Func1 and Func2 don't need declaration.
Func1 and Func4 are visible from outside of the program.
At least 1 function must be EXPORTed
Respect the EXPORT keyword if a function need declaration.

When you declare a function, make an exact copy of the function definition followed by semi.

If your functions don't call each other, a simple ordering can avoid declarations.

EXPORTed function are visible from everywhere in the calc, including other programs. This open the interesting possibility that you can gather all your common/usual/utility functions in a single utility file and avoid duplicating in every program that use them.

Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)