Commit bb8d876d 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 211d8813
......@@ -193,15 +193,20 @@ are at least two digits).
<section title="First use of overloading">
<p>
Consider the type <code>PhoneBook = &lt;phonebook>[PhoneItem*]</code>. If we
Consider the type declaration
</p>
<sample><![CDATA[
type PhoneBook = <phonebook>[PhoneItem*]
]]></sample>
<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"/>
<sample><![CDATA[
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)
]]></sample>
<p>
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