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: Pierre Weis <weis@p...>
Subject: Re: [Caml-list] raise extra arg ignored
> > 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:
>         let rec f() = f();;
>         f () "bar";;
>         print_string (f());;
>         print_int (f());;
>         f() + 2;;
> 
> > 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.

Absolutely. This is particularly difficult if you consider that none
of those expressions can be generalized according to the current type
discipline (since, being applications, those expressions are
``expansive'' or equivalently they are not ``syntactic values''). So
the criterion to emit the warning would be even more complex and
unclear ...

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/
-------------------
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