Arguments to XPCE methods are typed and variables are dynamically typed. This combination is used for two purposes: automatic conversion and raising exceptions at the earliest possible point if conversion is not defined.
For example, the send-method `colour' on class graphical specifies accepts a single argument of type `colour'. A colour in XPCE is represented by a colour object. Colour objects may be created from their name. The natural way to specify a box should be coloured `red' is:
..., send(Box, colour(colour(red))), ...
Because the ->
colour method knows that it
expects an instance of class colour, and because class colour defines
the conversion from a name to a colour (see section
7.3.1), the following message achieves the same goal:
..., send(Box, colour(red)), ...
Some other examples of classes defining type conversion are font, image, name, string, real and the non-object data item int. The following messages are thus valid:
..., send(Box, x('10')), % atom --> int send(Box, selected(true)), % atom --> boolean send(Text, font(bold)), % atom --> font send(Text, string(10)), % int --> string ...