G.3.1.2 Naming conventions for function parameters

In the functions documentation some parameters have established meaning:

ARRY

Every parameter named ARRY represents the data variable of an indexed array; we should declare arrays with mbfl_declare_index_array_varref(), Declaring arrays as data variables.

mbfl_declare_index_array_varref(ARRY, (a b c))

array_func _(ARRY)
ARRYS

Every parameter named ARRYS represents the data variable of an indexed array whose values are themselves data variables of indexed arrays. When such parameter is used in an iteration: unless othewise stated, all the referenced indexed arrays must have the same number of slots, all starting with slot ‘0’; otherwise the function’s behaviour is undefined.

mbfl_declare_index_array_varref(ARRY1, (a b c))
mbfl_declare_index_array_varref(ARRY2, (d e f))
mbfl_declare_index_array_varref(ARRY3, (g h i))
mbfl_declare_index_array_varref(ARRYS, (_(ARRY1) _(ARRY2) _(ARRY3)))

multi_array_func _(ARRYS)
IDX

Every parameter named IDX represents a zero–based index into an indexed array; we should declare indexes using declare -i IDX.

OPERATOR

Every parameter named OPERATOR must be an “applicable identifier”, bound to a function or command or alias, accepting some number of parameters. It is used in command lines like:

OPERATOR PARAMETER0 ...

Unless otherwise stated: if the return status of OPERATOR is false, the ongoing iteration is stopped and its function returns with the same status of OPERATOR.

PRED

Every parameter named PRED must be an “applicable identifier”, bound to a function or command or alias, accepting the following parameters:

PRED VALUE

where VALUE is a value from an array; PRED is meant to test some condition against VALUE and return true or false.

ISEQUAL

Every parameter named ISEQUAL must be an “applicable identifier”, bound to a function or command or alias, accepting the following parameters:

ISEQUAL VALUE1 VALUE2

where VALUE1 and VALUE2 are values from arrays; ISEQUAL must return true if VALUE1 and VALUE2 are “equal” according to some definition of equality, otherwise it must return false. ISEQUAL is usually an optional parameter, when not given: ISEQUAL defaults to mbfl_string_equal().

ISLESS

Every parameter named ISLESS must be an “applicable identifier”, bound to a function or command or alias, accepting the following parameters:

ISLESS VALUE1 VALUE2

where VALUE1 and VALUE2 are values from arrays; ISLESS must return true if VALUE1 is “less than” VALUE2 according to some definition of ordering; otherwise it must return false. ISLESS is usually an optional parameter, when not given: ISLESS defaults to mbfl_string_less().

ISGREATER

Every parameter named ISGREATER must be an “applicable identifier”, bound to a function or command or alias, accepting the following parameters:

ISGREATER VALUE1 VALUE2

where VALUE1 and VALUE2 are values from arrays; ISGREATER must return true if VALUE1 is “greater than” VALUE2 according to some definition of ordering; otherwise it must return false. ISGREATER is usually an optional parameter, when not given: ISGREATER defaults to mbfl_string_greater().

COMPAR

Every parameter named COMPAR must be an “applicable identifier”, bound to a function or command or alias, accepting the following parameters:

COMPAR VALUE1 VALUE2

where VALUE1 and VALUE2 are values from arrays; COMPAR must compare its parameters and:

  • if VALUE1 = VALUE2 return 0;
  • if VALUE1 < VALUE2 return 1;
  • if VALUE1 > VALUE2 return 2;

COMPAR is usually an optional parameter, when not given: COMPAR defaults to mbfl_string_compar().


This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.