From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA28763; Tue, 30 Oct 2001 22:46:03 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA29253 for caml-list@pauillac.inria.fr; Tue, 30 Oct 2001 22:46:02 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA29040; Tue, 30 Oct 2001 22:29:03 +0100 (MET) From: Pierre Weis Message-Id: <200110302129.WAA29040@pauillac.inria.fr> Subject: Re: [Caml-list] raise extra arg ignored In-Reply-To: <20011029112632.A22962@pauillac.inria.fr> from Xavier Leroy at "Oct 29, 101 11:26:32 am" To: xavier.leroy@inria.fr (Xavier Leroy) Date: Tue, 30 Oct 2001 22:29:03 +0100 (MET) Cc: pixel@mandrakesoft.com, caml-list@pauillac.inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > 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