From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 5BC9A7F7B4 for ; Wed, 12 Feb 2014 11:43:23 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of daniel.buenzli@erratique.ch) identity=pra; client-ip=74.55.86.74; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="daniel.buenzli@erratique.ch"; x-sender="daniel.buenzli@erratique.ch"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of daniel.buenzli@erratique.ch) identity=mailfrom; client-ip=74.55.86.74; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="daniel.buenzli@erratique.ch"; x-sender="daniel.buenzli@erratique.ch"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp.webfaction.com) identity=helo; client-ip=74.55.86.74; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="daniel.buenzli@erratique.ch"; x-sender="postmaster@smtp.webfaction.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApIHAF1P+1JKN1ZKm2dsb2JhbABahXuBIbwkgScOAQEBAQEGCwsJFCiCJgEFIwRiCxoCJgICRxAGG4d9BKZFoisXgSmNHTqCbzWBFASeWhePCA X-IPAS-Result: ApIHAF1P+1JKN1ZKm2dsb2JhbABahXuBIbwkgScOAQEBAQEGCwsJFCiCJgEFIwRiCxoCJgICRxAGG4d9BKZFoisXgSmNHTqCbzWBFASeWhePCA X-IronPort-AV: E=Sophos;i="4.95,832,1384297200"; d="scan'208";a="48763146" Received: from mail6.webfaction.com (HELO smtp.webfaction.com) ([74.55.86.74]) by mail3-smtp-sop.national.inria.fr with ESMTP; 12 Feb 2014 11:43:22 +0100 Received: from [172.20.10.2] (226-236.197-178.cust.bluewin.ch [178.197.236.226]) by smtp.webfaction.com (Postfix) with ESMTP id D7364223F9DF for ; Wed, 12 Feb 2014 10:43:19 +0000 (UTC) Date: Wed, 12 Feb 2014 11:43:17 +0100 From: =?utf-8?Q?Daniel_B=C3=BCnzli?= To: caml list Message-ID: In-Reply-To: <4DDEBB7487B641C0834F09D522EA9918@erratique.ch> References: <4DDEBB7487B641C0834F09D522EA9918@erratique.ch> X-Mailer: sparrow 1.6.4 (build 1178) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: [Caml-list] SDL2 bindings, testers and feedback welcome Le mardi, 17 d=C3=A9cembre 2013 =C3=A0 07:11, Daniel B=C3=BCnzli a =C3=A9cr= it : > * I used an 'a result =3D [ `Error | `Ok of 'a ] rather than an exception > for functions that return error codes/null is error. I tend to lean > on exceptionless designs but I'm still unsure whether it is a good > idea that case. One of the problems is that SDL doesn't make a clear > distinction (at the signature level *and* in the documentation) > between programming errors (invalid_arg), exceptional errors > (e.g. out of memory) and non-exceptional errors (e.g. could not > access/setup a resource). I found that in practice directly returning the string you get by SDL_GetEr= ror () in the `Error case is much more convenient. E.g. with the above type= your bind looks like this: let ( >>=3D ) x f =3D match x with=20=20 | `Error -> `Error_msg (Sdl.get_error ())=20=20 | `Error_msg _ as e -> e | `Ok v -> f v which is needlessly unconvenient. So I'm changing that type to=20=20 'a result =3D [ `Error of string | `Ok of 'a ] and you always directly get the result of Sdl.get_error () in the `Error ca= se.=20=20 Best, Daniel