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 TAA28941; Wed, 19 Nov 2003 19:03:34 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA28745 for ; Wed, 19 Nov 2003 19:03:33 +0100 (MET) Received: from mail.dcs.qmul.ac.uk (vicar.dcs.qmul.ac.uk [138.37.88.163]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hAJI3W114038 for ; Wed, 19 Nov 2003 19:03:32 +0100 (MET) Received: from xenografia.plus.com ([212.159.85.26] helo=dcs.qmul.ac.uk) by mail.dcs.qmul.ac.uk with asmtp (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.24) id 1AMWfr-0000wU-Dh for caml-list@inria.fr; Wed, 19 Nov 2003 18:03:31 +0000 Message-ID: <3FBBB054.6000001@dcs.qmul.ac.uk> Date: Wed, 19 Nov 2003 18:03:00 +0000 From: Martin Berger User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031009 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Caml Mailing List Subject: Re: [Caml-list] GC and file descriptors References: <1069168323.18363.83.camel@pelican> <3FBA4D97.9060309@dcs.qmul.ac.uk> <1069177584.18363.204.camel@pelican> <3FBAC862.7010603@dcs.qmul.ac.uk> <20031119165408.GA16427@redhat.com> In-Reply-To: <20031119165408.GA16427@redhat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Auth-User: martinb X-DCS-Spam-Score: -2.5 X-clamav-result: clean (1AMWfr-0000wU-Dh) X-uvscan-result: clean (1AMWfr-0000wU-Dh) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 forall:01 mli:01 typable:01 nat:01 nat:01 api:01 descriptors:01 declaring:01 exception:02 modules:02 explicit:03 wrote:03 library:03 library:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Richard Jones wrote: >> forall A B E: (A -> B throws E) -> list[A] -> list[B] throws E. > Yes, all well and good, but I *do not* want have to go and change all > .mli files to support checked exceptions, and then go and change them > all again when I decide to put a SQL database behind some persistence > library deep in the code. for a start, the universal quantification above (for a map function) deals with this just fine. it can handle whatevery you throw. i do think however, that there is a problem with declaring the exceptions a function can throw. i think what the type should really declare is something like the exceptions the synax of the function body *adds*. eg a function let f n = let g = send_to_network n in let h = write_do_DB g in if n > 17 then throw Micky_Mouse else 666 should be typable as f : nat -> nat adds Micky_Mouse and not *just* as f : nat -> nat throws E, Micky_Mouse where E is whatever send_to_network and write_to_DB throw. one compromise may be to add an explicit exception spec grabbing operator so we can write f : nat -> nat throws ex(send_to_network), ex(write_to_DB), Micky_Mouse or f : nat -> nat adds ex(send_to_network), ex(write_to_DB), Micky_Mouse where in the latter case ex( f ) gives all the exceptions f adds while in the former case it returns all exceptions f throws. note that at link time, when we put all modules together, the accumulated "adds" information determines the usual "throws" information. of course "adds" and "throws" can live harmoniously together. > This is the problem with checked exceptions in Java: the set of > exceptions that can be thrown is an implementation detail which is > exposed unnecessarily through the API. again, i don't think this is an implementation detail. if you are a library vendor, i as a customer want to know if your library throws SQL exceptions or not. martin ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners