Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Polymorphism and the "for" loop
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Robert M. Solovay <solovay@M...>
Subject: Re: [Caml-list] Polymorphism and the "for" loop
How does one define a function f of type int -> void? I looked in the
OCaml manual and couldn't find any reference to "void". {It is, of course,
a familiar concept in C.}

	--Bob Solovay




On 22 Oct 2004, skaller wrote:

> On Fri, 2004-10-22 at 05:11, David Brown wrote:
> > On Thu, Oct 21, 2004 at 07:50:43PM +0100, Jon Harrop wrote:
>
> > Because its only a warning, not an error.  g is allowed to return any type.
> > It could be argued that the loop expression must be of type unit, then this
> > could also be inferred by type inference.
>
> It can also be argued chosing unit for non-returning function
> is the wrong choice and that correct choice is void.
>
> In particular given
>
> f: unit -> unit
>
> you can write
>
> f ( f () )
>
> which is silly. Given
>
> f: unit -> void
>
> that expression won't type check. The result is to force
> 'commands' with side effects and no return values
> be 'top level' (or at least arguments of for, ';', etc).
>
> This seems to work well in Felix.
>
> --
> John Skaller, mailto:skaller@users.sf.net
> voice: 061-2-9660-0850,
> snail: PO BOX 401 Glebe NSW 2037 Australia
> Checkout the Felix programming language http://felix.sf.net
>
>
>
> -------------------
> 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
>

-------------------
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