Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] raise extra arg ignored
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Fergus Henderson <fjh@c...>
Subject: Re: [Caml-list] raise extra arg ignored
On 29-Oct-2001, Xavier Leroy <xavier.leroy@inria.fr> wrote:
 > > failwith "foo" "bar"
 > > failwith "foo"
 > > 
 > > are equivalent. 
 > > 
 > > exception Foo;;
 > > raise Foo 1
 > > raise Foo
 > > 
 > > same for this.
 > 
 > Yes.  For additional fun, you could do
 >         print_string (raise Foo);;
 >         print_int (raise Foo);;
 >         raise Foo + 2;;
 > 
 > Notice that this also works for certain non-terminating functions:
[...]
 > > I understand why it typechecks, but couldn't there be a special
 > > check for this since it can't be useful (or can it??)
 > 
 > Possibly, but that would not be easy to do: we'd have to wait until
 > type inference for the phrase is completed, remember the principal
 > types inferred for each sub-expression, and apply ad-hoc checks such as
 > "warn if an expression of principal type 'a ('a being generalizable in
 > the context) is applied as if it were a function".  This really
 > doesn't fit well in the current OCaml type inference technology.

How about ignoring the types, and instead issuing a warning whenever
any expression which always raises an exception is used as a function
argument, or as the function term in a function application?

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr