Programming in XPCE/Prolog: Section 7.4

## 7.4 Handling default arguments

The predicate default/3 provides a comfortable way to specify the meaning of default arguments. Future versions may incorporate the default value in the type object itself.

default(+Argument, +Default, -Value)
  Used to specify and compute defaults for arguments. Argument is the actual argument passed to the method implementation, Default is any valid XPCE object description (reference, integer, real, atom or compound ground term describing an object, see send/[2-12]). Default can also be the term

      resource(<Object>, <Name>)

  In which case the `<-`resource_value: <Name> from <Object> will be used as default value. Value is unified with Argument if Argument is not @default and with Default otherwise.

  The following is an example that sets the volume to a specified value or the value of the resource `volume' if @default is passed as an argument.

      resource(volume, 0..130,  75, "Volume in decibels").

      volume(X, Vol:[0..130]) :->
              default(Vol, resource(X, volume), V),
              <set the volume here>.