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 QAA19888; Fri, 22 Oct 2004 16:07:26 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA21058 for ; Fri, 22 Oct 2004 16:07:25 +0200 (MET DST) Received: from hermes.jf.intel.com (fmr05.intel.com [134.134.136.6]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i9ME7O2H014216 for ; Fri, 22 Oct 2004 16:07:25 +0200 Received: from talaria.jf.intel.com (talaria.jf.intel.com [10.7.209.7]) by hermes.jf.intel.com (8.12.9-20030918-01/8.12.9/d: major-outer.mc,v 1.15 2004/01/30 18:16:28 root Exp $) with ESMTP id i9MEBFMH026888 for ; Fri, 22 Oct 2004 14:11:15 GMT Received: from orsmsxvs040.jf.intel.com (orsmsxvs040.jf.intel.com [192.168.65.206]) by talaria.jf.intel.com (8.12.9-20030918-01/8.12.9/d: major-inner.mc,v 1.11 2004/07/29 22:51:53 root Exp $) with SMTP id i9ME0tJ4008141 for ; Fri, 22 Oct 2004 14:01:01 GMT Received: from orsmsx331.amr.corp.intel.com ([192.168.65.56]) by orsmsxvs040.jf.intel.com (SAVSMTP 3.1.2.35) with SMTP id M2004102207072205552 for ; Fri, 22 Oct 2004 07:07:22 -0700 Received: from orsmsx407.amr.corp.intel.com ([192.168.65.50]) by orsmsx331.amr.corp.intel.com with Microsoft SMTPSVC(6.0.3790.0); Fri, 22 Oct 2004 07:07:22 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] Polymorphism and the "for" loop Date: Fri, 22 Oct 2004 07:07:21 -0700 Message-ID: <012676D607FCF54E986746512C22CE7D0FE7C8@orsmsx407> Thread-Topic: [Caml-list] Polymorphism and the "for" loop Thread-Index: AcS4D7A+U3EYbiHWQTOAM2kGXxY+XAAL3Png From: "Harrison, John R" To: "caml-list" X-OriginalArrivalTime: 22 Oct 2004 14:07:22.0257 (UTC) FILETIME=[73270010:01C4B840] X-Scanned-By: MIMEDefang 2.31 (www . roaringpenguin . com / mimedefang) X-Miltered: at nez-perce with ID 4179141C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 johnh:01 type-safe:01 constr:01 constr:01 int-:01 val:01 int-:01 failwith:01 val:01 model:01 ocaml:01 int:01 int:01 rec:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk | (Incidentally, O'Caml doesn't really need a type "void" since it can convey | a similar semantic notion using polymorphism. Consider the function raise, | which has type "exn -> 'a" -- in other words, given an exception, it | produces an arbitrary value of any type. Since such a thing is impossible | (using the type-safe core language), we must conclude that raise does not | return to its call site when it executes.) That's true. In any case I assume (given that a recursive type is some kind of least fixed point) that you can define an empty type in OCaml like this: # type void =3D Constr of void;;=20 type void =3D Constr of void So the only functions into such a type are those that never terminate and return a value, e.g. # let rec f x =3D (f:int->void) x;; val f : int -> void =3D or # let (g:int->void) =3D fun x -> failwith "void function";; val g : int -> void =3D or # let (h:int->void) =3D fun x -> if x =3D 0 then f x else g x;; val h : int -> void =3D Perhaps the name "void" in C is a bit poorly chosen. It's probably meant to say that an element of the type imparts no information, rather than imply a semantic model based on an empty type. John. ------------------- 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