Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] function overloading
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-11-05 (17:51)
From: Dustin Sallings <dustin@s...>
Subject: Re: [Caml-list] function overloading

On Nov 5, 2003, at 2:13, Issac Trotts wrote:

> You can do this:
> type bool_or_int = Bool of bool | Int of int;;
> let print_bool b = print_string (if b then "true" else "false");;
> let print_poly x = match x with
>     Bool b -> print_bool b
>   | Int i -> print_int i;;
> let x = Bool true;;
> print_poly x;;

	This doesn't really solve my problem, I still have to know what the 
type was at some point.  Thanks for the help, though.

	It is good news that your print_bool and mine look identical, though 
(well, you have a space I don't have).  I must be understanding 
something here.  :)

	What I was hoping to do here was print out the termios structure from 
tcgetattr without having to create separate print functions for the 
boolean types, int types, and char types.  It just means I've got to 
pay slightly closer attention.

	Thanks again.

Dustin Sallings

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: