Commit fc9fd876 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-01-31 02:17:37 by beppe] Empty log message

Original author: beppe
Date: 2004-01-31 02:17:37+00:00
parent 799a7182
......@@ -193,15 +193,20 @@ are at least two digits).
<section title="First use of overloading">
Consider the type <code>PhoneBook = &lt;phonebook>[PhoneItem*]</code>. If we
Consider the type declaration
type PhoneBook = <phonebook>[PhoneItem*]
<p>If we
add a new pattern matching branch in the definition of the function
<code>names</code>, we make it work both with <code>ParentBook</code> and <code>
PhoneBook</code> elements. This yields the following <i>overloaded</i> function:
</p><a name="names3"/>
let names3 (ParentBook -> [Name*] ; PhoneBook -> [String*])
| <parentbook> x -> map x with <person>[ n _* ] -> n
| <phonebook> x -> map x with { name=n } -> n
| <parentbook> x -> (map x with <person>[ n _* ] -> n)
| <phonebook> x -> (map x with { name=n } -> n)
The overloaded nature of <code>names3</code> is expressed by its interface, which
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment