1functions [ {+|-}UXkmtTuz ] [ name ... ]
2functions -M mathfn [ min [ max [ shellfn ] ] ]
3functions -M [ -m pattern ... ]
4functions +M [ -m ] mathfn
5       Equivalent to typeset -f, with the exception of the  -M  option.
6       Use of the -M option may not be combined with any of the options
7       handled by typeset -f.
8
9       functions -M mathfn defines mathfn as the name of a mathematical
10       function  recognised  in  all forms of arithmetical expressions;
11       see the  section  `Arithmetic  Evaluation'  in  zshmisc(1).   By
12       default mathfn may take any number of comma-separated arguments.
13       If min is given, it must have exactly min args; if min  and  max
14       are  both given, it must have at least min and at most max args.
15       max may be -1 to indicate that there is no upper limit.
16
17       By default the function is implemented by a  shell  function  of
18       the  same name; if shellfn is specified it gives the name of the
19       corresponding shell function while mathfn remains the name  used
20       in  arithmetical expressions.  The name of the function in $0 is
21       mathfn (not shellfn as would usually be the case), provided  the
22       option FUNCTION ARGZERO is in effect.  The positional parameters
23                      -
24       in the shell function correspond to the arguments of the  mathe-
25       matical  function  call.   The  result  of the last arithmetical
26       expression evaluated inside the shell function (even if it is  a
27       form  that  normally  only returns a status) gives the result of
28       the mathematical function.
29
30       functions -M with no arguments lists all such user-defined func-
31       tions  in  the  same  form as a definition.  With the additional
32       option -m and a list of arguments, all  functions  whose  mathfn
33       matches one of the pattern arguments are listed.
34
35       function +M removes the list of mathematical functions; with the
36       additional option -m the arguments are treated as  patterns  and
37       all  functions  whose  mathfn  matches  the pattern are removed.
38       Note that the shell function implementing the behaviour  is  not
39       removed (regardless of whether its name coincides with mathfn).
40
41       For example, the following prints the cube of 3:
42
43              zmath cube() { (( $1 * $1 * $1 )) }
44                   -
45              functions -M cube 1 1 zmath cube
46                                         -
47              print $(( cube(3) ))
48
49autoload [ {+|-}UXkmtz ] [ -w ] [ name ... ]
50       Equivalent to functions -u, with the exception of -X/+X and -w.
51
52       The flag -X may be used only inside a shell  function,  and  may
53       not be followed by a name.  It causes the calling function to be
54       marked for autoloading and then immediately loaded and executed,
55       with  the  current  array of positional parameters as arguments.
56       This replaces the previous definition of the  function.   If  no
57       function  definition is found, an error is printed and the func-
58       tion remains undefined and marked for autoloading.
59
60       The flag +X attempts to load each name as  an  autoloaded  func-
61       tion,  but  does  not execute it.  The exit status is zero (suc-
62       cess) if the function was not previously defined and  a  defini-
63       tion for it was found.  This does not replace any existing defi-
64       nition of the function.  The exit status is nonzero (failure) if
65       the  function  was  already  defined  or  when no definition was
66       found.  In the latter case the function  remains  undefined  and
67       marked  for  autoloading.   If ksh-style autoloading is enabled,
68       the function created will contain the contents of the file  plus
69       a call to the function itself appended to it, thus giving normal
70       ksh autoloading behaviour on the first call to the function.  If
71       the  -m flag is also given each name is treated as a pattern and
72       all functions already marked for autoload that match the pattern
73       are loaded.
74
75       With the -w flag, the names are taken as names of files compiled
76       with the zcompile builtin, and all functions defined in them are
77       marked for autoloading.
78
79       The flags -z and -k mark the function to be autoloaded using the
80       zsh or ksh style, as if the option KSH AUTOLOAD  were  unset  or
81                                             -
82       were  set,  respectively.  The flags override the setting of the
83       option at the time the function is loaded.
84
85       Note that the autoload command makes no attempt  to  ensure  the
86       shell  options  set  during the loading or execution of the file
87       have any particular value.  For this, the emulate command can be
88       used:
89
90              emulate zsh -c 'autoload -Uz func'
91
92       arranges  that  when  func  is loaded the shell is in native zsh
93       emulation, and this emulation is also applied when func is run.
94