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 KAA07113; Fri, 22 Oct 2004 10:13:30 +0200 (MET DST) 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 KAA06386 for ; Fri, 22 Oct 2004 10:13:29 +0200 (MET DST) Received: from nexus.stwing.upenn.edu (NEXUS.STWING.UPENN.EDU [165.123.132.61]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i9M8DRQl007194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 22 Oct 2004 10:13:28 +0200 Received: from force.stwing.upenn.edu (force.stwing.upenn.edu [165.123.132.65]) by nexus.stwing.upenn.edu (8.12.10/8.12.9) with ESMTP id i9M8DQHA029242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 22 Oct 2004 04:13:27 -0400 (EDT) Received: from force.stwing.upenn.edu (localhost [127.0.0.1]) by force.stwing.upenn.edu (8.12.10/8.12.9) with ESMTP id i9M8DKh4007156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 22 Oct 2004 04:13:26 -0400 (EDT) Received: (from wlovas@localhost) by force.stwing.upenn.edu (8.12.10/8.12.9/Submit) id i9M8DKuc007102 for caml-list@inria.fr; Fri, 22 Oct 2004 04:13:20 -0400 (EDT) Date: Fri, 22 Oct 2004 04:13:19 -0400 From: William Lovas To: caml-list Subject: Re: [Caml-list] Polymorphism and the "for" loop Message-ID: <20041022081318.GA17842@force.stwing.upenn.edu> Mail-Followup-To: caml-list References: <1098425963.7584.9.camel@pelican.wigram> <200410220838.49340.jon@jdh30.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200410220838.49340.jon@jdh30.plus.com> User-Agent: Mutt/1.5.4i X-Miltered: at concorde with ID 4178C127.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; lovas:01 wlovas:01 stwing:01 caml-list:01 2004:99 2004:99 bug:01 assertion:01 type-safe:01 trivial:01 precisely:02 exception:02 implicit:02 arbitrary:02 o'caml:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Oct 22, 2004 at 08:38:49AM +0100, Jon Harrop wrote: > On Friday 22 October 2004 07:19, skaller wrote: > > type void = [] > > Why not "`void"? "unit" and "void" do not denote the same type -- the former is the type containing one element, whereas the latter is the type containing *no* elements *at all*. To emphasize this intuition, the types "unit" and "void" are often written as "1" and "0" in the literature. > > ...I consider that a bug... > > I'd have to go right ahead and disagree with you there. Surely a "procedure" > returns no information, which can be achieved by returning the only value > from a type representing a singleton set, i.e. _the_ value of the type unit. Well, a "procedure" *does* return some information -- the implicit assertion that it completed! (And in doing so, carried out any side effects that it might have had.) The only way to do this in O'Caml is to return some value. In the case of a function executed solely for its effects, we conventionally choose the trivial value (), but any value would serve as well. "void" would be another story altogether: Since there are no elements of type "void", a function returning that type can never return at all, so it's not really the right idea for "procedures" (or, more precisely, functions executed solely for their effects). I don't see the value in hijacking the type "void" and imbuing it with a new meaning when we have an appropriate "procedure" return type already... (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.) cheers, William ------------------- 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