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 QAA04235; Mon, 26 Nov 2001 16:13:11 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA04230; Mon, 26 Nov 2001 16:13:10 +0100 (MET) Received: from earth.cs.mu.oz.au (earth.cs.mu.OZ.AU [128.250.37.146]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id fAQFD8X13984; Mon, 26 Nov 2001 16:13:09 +0100 (MET) Received: from fjh by earth.cs.mu.oz.au with local (Exim 3.32 #1 (Debian)) id 168NR1-0004JQ-00; Tue, 27 Nov 2001 02:12:39 +1100 Date: Tue, 27 Nov 2001 02:12:39 +1100 From: Fergus Henderson To: Xavier Leroy Cc: Pixel , caml-list@pauillac.inria.fr Subject: Re: [Caml-list] raise extra arg ignored Message-ID: <20011127021238.B10358@earth.cs.mu.oz.au> References: <20011029112632.A22962@pauillac.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20011029112632.A22962@pauillac.inria.fr> User-Agent: Mutt/1.3.22i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 29-Oct-2001, Xavier Leroy 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 | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal habit" WWW: | -- 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