### 3.7.2 Parameter list

`Syntax:`
  `( )`
  `(` parameter_definition `)`
`Purpose:`
  - Defines the number, type and names of the arguments of a procedure.
  - The parameter_list is optional.
  - Adding `list #` as argument to a parameter list means to allow optional parameters. Furthermore, `(list #)` is the default for a parameter list (in case no list is explicitly given). Inside the procedure body, the arguments of `list #` are referenced by `#[1], #[2]`, etc.
  - If a procedure has optional parameters, the attribute `default_arg` gives the default values for the optional arguments. This provides in particular the possibility to also change the behaviour of all procedures nested inside the given procedure.

`Example:`

      proc x0
      {
          // can be called with
      ... // any number of arguments of any type: #[1], #[2],...
          // number of arguments: size(#)
      }

      proc x1 ()
      {
      ... // can only be called without arguments
      }

      proc x2 (ideal i, int j)
      {
      ... // can only be called with 2 arguments,
          // which can be converted to ideal resp. int
      }

      proc x3 (i,j)
      {
      ... // can only be called with 2 arguments
          // of any type
          // (i,j) is the same as (def i,def j)
      }

      proc x5 (i,list #)
      {
      ... // can only be called with at least 1 argument
          // number of arguments: size(#)+1
      }

      attrib(x5,"default_arg",3);
      x5(2); // is equivalent to
      x5(2,3);

`Note:`
  The parameter_list may stretch across multiple lines.
  A parameter may have any type (including the types `proc` and `ring`).
  If a parameter is of type ring, then it can only be specified by name, but not with a type. For instance:

      proc x6 (r)
      {
      ... // this is correct, r may be of any type, even of type ring
      }

      proc x7 (ring r)
      {
      ... // this is NOT CORRECT
      }

User manual for Singular version 4.4.1, 2025, generated by texi2html.