From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA12308; Wed, 5 Nov 2003 18:51:39 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA11866 for ; Wed, 5 Nov 2003 18:51:37 +0100 (MET) Received: from bob.west.spy.net (mail.west.spy.net [66.149.231.226]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hA5HpZ102227 for ; Wed, 5 Nov 2003 18:51:36 +0100 (MET) Received: from [10.9.254.248] (sjc-dist3-e3.2wire.com [63.203.253.2]) by bob.west.spy.net (Postfix) with ESMTP id 95819598D; Wed, 5 Nov 2003 09:51:31 -0800 (PST) In-Reply-To: <20031105101305.GA28600@ucdavis.edu> References: <0F0B3332-0F6E-11D8-85C9-000393CFE6B8@spy.net> <20031105101305.GA28600@ucdavis.edu> Mime-Version: 1.0 (Apple Message framework v606) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit Cc: caml-list@inria.fr From: Dustin Sallings Subject: Re: [Caml-list] function overloading Date: Wed, 5 Nov 2003 09:51:31 -0800 To: ijtrotts@ucdavis.edu X-Mailer: Apple Mail (2.606) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 issac:01 trotts:01 termios:01 tcgetattr:01 char:01 bool:01 bool:01 overloading:01 int:01 int:01 nov:01 match:02 string:03 identical:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners