gawk: Functions Summary

1 
1 9.4 Summary
1 ===========
1 
1    * 'awk' provides built-in functions and lets you define your own
1      functions.
1 
1    * POSIX 'awk' provides three kinds of built-in functions: numeric,
1      string, and I/O. 'gawk' provides functions that sort arrays, work
1      with values representing time, do bit manipulation, determine
1      variable type (array versus scalar), and internationalize and
1      localize programs.  'gawk' also provides several extensions to some
1      of standard functions, typically in the form of additional
1      arguments.
1 
1    * Functions accept zero or more arguments and return a value.  The
1      expressions that provide the argument values are completely
1      evaluated before the function is called.  Order of evaluation is
1      not defined.  The return value can be ignored.
1 
1    * The handling of backslash in 'sub()' and 'gsub()' is not simple.
1      It is more straightforward in 'gawk''s 'gensub()' function, but
1      that function still requires care in its use.
1 
1    * User-defined functions provide important capabilities but come with
1      some syntactic inelegancies.  In a function call, there cannot be
1      any space between the function name and the opening left
1      parenthesis of the argument list.  Also, there is no provision for
1      local variables, so the convention is to add extra parameters, and
1      to separate them visually from the real parameters by extra
1      whitespace.
1 
1    * User-defined functions may call other user-defined (and built-in)
1      functions and may call themselves recursively.  Function parameters
1      "hide" any global variables of the same names.  You cannot use the
1      name of a reserved variable (such as 'ARGC') as the name of a
1      parameter in user-defined functions.
1 
1    * Scalar values are passed to user-defined functions by value.  Array
1      parameters are passed by reference; any changes made by the
1      function to array parameters are thus visible after the function
1      has returned.
1 
1    * Use the 'return' statement to return from a user-defined function.
1      An optional expression becomes the function's return value.  Only
1      scalar values may be returned by a function.
1 
1    * If a variable that has never been used is passed to a user-defined
1      function, how that function treats the variable can set its nature:
1      either scalar or array.
1 
1    * 'gawk' provides indirect function calls using a special syntax.  By
1      setting a variable to the name of a function, you can determine at
1      runtime what function will be called at that point in the program.
1      This is equivalent to function pointers in C and C++.
1