Version française
Home     About     Download     Resources     Contact us    
Browse thread
bottom types and threaded exits
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi VANICAT <remi.vanicat@l...>
Subject: Re: bottom types and threaded exits
Julian Assange <proff@iq.org> writes:

> Pervasives.exit is of type int -> 'a
> 
> Here we see ocaml using 'a to represent _|_. This hack is presumably
> so type unification still works in the face of potentially
> non-terminating computations, e.g:
> 
> let f a =
>         try 
>           f a
>         with
>           Failure _ -> exit(1)
> 
> How can one force 'a? For instance, Thread.exit and
> 
>         let f () = while true do () done 
> 
> has a type of unit -> unit.
> 
> One can write something such as
> 
>         let f () = while true do () done ; Pervasives.exit (1)
> 
> But this is clearly a hack.

i would use an execption :

exception Sould_never_be_here

let f () = while true do () done ; raise Sould_never_be_here

-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat