Recherche Google
OpenMusic 6 – User ManualVisual Programming > Boxes and Patch Components > Function Boxes > Additional Inputs
previous pagenext page

Additional Inputs : Optional and Keyword Arguments

Arguments can be added to Lisp and OM functions. Indeed, for practical issues, function boxes don't always show all possible inlets. Additional arguments can be either optional or keyword arguments.

Getting Information About Arguments
This function shows two default arguments, and twelve additional arguments...
This function shows two default arguments, and twelve additional arguments...

To know which types of arguments are accepted by a function :

  1. select it

  2. press d to get the function documentation.

The arguments type, that is default, optional and key arguments – the prototype of the function – is indicated at teh beginning of the documentation.

Optional Arguments : &optional

Optional arguments are identified by the &optional prefix. The order of optional arguments cannot be modified.

  • To add optional arguments, select the box and press Alt + or SHIFT + > .
  • To delete them, press Alt + or <.
Example : the sort. function
Sort. puts numbers from a list in increasing order.
Sort. puts numbers from a list in increasing order.

This function has one default argument, and two optional arguments, as shownat the beginning of the documentation :

The online documentation of the sort. gives information about the behaviour of the function, and its optional arguments.
The online documentation of the sort. gives information about the behaviour of the function, and its optional arguments.
  • "lst" is a single default argument that stands for "list". It has no prefix.

  • The &optional prefix referes to optional arguments.

    • The first optional argument is " test ", an optional predicate allowing the comparison of values.
    • The second optional argument is called " key ". It is a potential connection used for applying a function to the elements of "lst", before they are compared with each other. Do not confuse with the &key prefix of keyword arguments!
Online Documentation

In some cases, recent upgrades provides an online reference documentation instead of the internal documentation. This documentation is also accessed by pressing d.

Keyword Arguments : &key

Keyword arguments are identified by the &key prefix and shown by dark blue inlets.

These arguments are not sorted, which is very convenient when a function has numerous additional arguments : a user might want to use the last of a twelve arguments list without having to display all the preceding arguments.

  1. Select the box and type k to add a keyword argument.

    Type SHIFT + k to remove it.

  2. The name and value of a keyword argument must then be specified, as described in the following procedures.

Setting the Name of a Keyword Argument

Before it is defined by the user, its default name is the name of the first argument in the list. This name is visible by hovering the mouse over the box inlet. Note that keyword names are always preceded by " : "

To change the argument :

  1. click on the inlet

  2. type a new – existing – keyword name.

List of Available Keyword Arguments

The list of available keyword arguments is displayed by a tooltip or in the documentation of the function.

  • To display the list, hold Cmd while hovering the mouse over the inlet.
  • To open the documentation of the function, select a box and press d
Setting the Value of a Keyword Argument

The value of a keyword argument is set like the value of a standard argument by connecting a box to the keyword input.

This box can be

  • a data box
  • another type of box.
previous pagenext page
About...(c) Ircam - Centre PompidouMade with Scenari