Version française
Home     About     Download     Resources     Contact us    
Browse thread
Type-checking and raise
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <Pierre.Weis@i...>
Subject: Re: Type-checking and raise
> Hello,
> 
> Is there any type-checking for "raise" ? Indeed, 
> raise Not_found expr
> for instance do not trigger any type error, although raise 
> is of type exn -> 'a. Any reason for such a behaviour ?
> 
> --Denis Barthou

Raise has type exn -> 'a, thus raise Not_found has type 'a, and can be
applied to any number of values (ad libitum). This polymorphic type
scheme for raise is semantically sound, since nothing will be returned
by raise Not_found. This polymorphic type scheme is also mandatory, if
we want to write programs that raise exceptions in conditionals
(remember that all the arms of a conditional must have the same type).

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis