* Type-checking and raise
@ 1997-02-04 12:22 Denis BARTHOU
1997-02-04 14:04 ` Pierre Weis
0 siblings, 1 reply; 2+ messages in thread
From: Denis BARTHOU @ 1997-02-04 12:22 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Type-checking and raise
1997-02-04 12:22 Type-checking and raise Denis BARTHOU
@ 1997-02-04 14:04 ` Pierre Weis
0 siblings, 0 replies; 2+ messages in thread
From: Pierre Weis @ 1997-02-04 14:04 UTC (permalink / raw)
To: Denis BARTHOU; +Cc: caml-list
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-02-04 14:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-04 12:22 Type-checking and raise Denis BARTHOU
1997-02-04 14:04 ` Pierre Weis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox