Task

Demonstrate the different syntax and semantics provided for calling a function.



This may include:

   Calling a function that requires no arguments
   Calling a function with a fixed number of arguments
   Calling a function with optional arguments
   Calling a function with a variable number of arguments
   Calling a function with named arguments
   Using a function in statement context
   Using a function in first-class context within an expression
   Obtaining the return value of a function
   Distinguishing built-in functions and user-defined functions
   Distinguishing subroutines and functions
   Stating whether arguments are passed by value or by reference
   Is partial application possible and how


This task is not about defining functions.




/*REXX pgms demonstrates various methods/approaches of invoking/calling a REXX function.*/
 
                /*╔════════════════════════════════════════════════════════════════════╗
                  ║ Calling a function that REQUIRES no arguments.                     ║
                  ║                                                                    ║
                  ║ In the REXX language, there is no way to require the caller to not ║
                  ║ pass arguments, but the programmer can check if any arguments were ║
                  ║ (or weren't) passed.                                               ║
                  ╚════════════════════════════════════════════════════════════════════╝*/
 
yr= yearFunc()                              /*the function name is caseless if it isn't */
                                            /*enclosed in quotes (') or apostrophes (").*/
say 'year='  yr
exit                                             /*stick a fork in it,  we're all done. */
 
yearFunc: procedure                              /*function  ARG  returns the # of args.*/
          errmsg= '***error***'                  /*an error message eyecatcher string.  */
          if arg() \== 0  then say errmsg  "the YEARFUNC function won't accept arguments."
          return left( date('Sorted'), 3)