Function Calls: specifying 'Returning' vs 'Non-Returning' functions?

 

In the following MQ info, I don't see any difference in the Functions other than the last variable/argument is different. Other than that the Format and Structure are EXACTLY the same are they not? I know that one can use the void Non-ReturnFunction (a,b,c) Likewise returning: return() [and return(empty)?] are for all intents and purposes are ''Non-Returning' functions' are they not?

As for 'calling' a function(), the 'calling' part and usage of 'calling' a function() is a moot point and superfluous is it not? It the same thing as just 'using' a function isn't it?

====================================================================================

The called functions are divided into two groups: those that return a certain value of a predefined type and those that don't return any value.

Format of Non-Return Function Call


A call for a function that does not return any value can only be composed as a separate operator. The call function operator is ended in ";" (semicolon):

Function_name  (Parameter_list);       // Operator of non-return function call
Func_no_ret (Alpha, Beta, Gamma);             // Example of a function call operator..
                                             //.. for a function that does not return any value

No other format (technique) is provided to call to functions that don't return any values. <<=-This is definitely NOT true: void Non-ReturningFunction();

Format of Return Function Call


A call to a function that returns a value can be composed as a separate operator or it can be used in the program code at places where a value of a certain type is implied.

If the function call is composed as a separate operator, it ends in ";" (semicolon): <<=- Just like the Non-ReturningFunction(); So ???

Function_name  (Parameter_list);       // Operator of return function call
Func_yes_ret (Alpha, Beta, Delta);           // Example of a function call operator..
                                             //.. for a function that returns a value

Execution Rule of Function Call

A function call calls the function of the same name for execution. If the function call is composed as a separate operator, after the function has been executed, the control is passed to the operator that follows the function call. If the function call is used in an expression, after the function has been executed, the control is passed to the location in the expression, where the function call is specified; the further calculations in the expression will be performed using the value returned by the called function.

The use of function calls in other operators is determined by the format of these operators.

====================================================================================

This is a very important programming distinction to have to know and use!

So what am I missing here?

 

I think that is just saying, you can have parameters in both kinds of functions, and that a non value returning function returns like this

return;

as for calling a function, that is just the correct terminology for as you said, using a function, because to use a function you make a function call.

When it says no other format is provided to call to a function that doesnt return values, you are confusing calling a function with defining a function.

void Non-ReturningFunction()

that is to define a function:

void non_returning_function()
{
  Print("all this function does is print this");
  return;
}

the function call looks like this:

non_returning_function();

so everytime you make that function call it will do the Print()

 

void Non-ReturningFunction()

that is to define a function:

void non_returning_function()
{
  Print("all this function does is print this");
  return;
}

Hi SDC,

This is just a matter of semantics then.

However in the example above that is a 'non_returning_function' you have a 'return()' statement ending the function. This is a void function, so...??? Does one have to use a return() statement (to end the function?) even for a void function?

Thanks and well explained. (< 8)

 
FourX:

However in the example above that is a 'non_returning_function' you have a 'return()' statement ending the function. This is a void function, so...??? Does one have to use a return() statement (to end the function?) even for a void function?

No, return; is not needed at the end of a void type function . . but if you want to exit the function early then you can use a return; to do that.
 

an example of that in practice:

void lazy_wednesday_function()
{
  if(DayOfWeek() == 3)
   {
    Alert("Today is Wednesday so you can go back to bed :)  ");
    return;  //you could exit function here when no further processing is neccessary
   }
  else
   {
    Alert("Today is not Wednesday so get to work !!  ");
   }
  return;  //as Raptor said you dont need this final return.
}         //because the same thing will happen either way
I usually put the final return; there just because it clearly shows the logical end to the function but thats just personal preference.