From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id GNUTHVCWxmMXpQAAbAwnHQ (envelope-from ) for ; Tue, 17 Jan 2023 13:36:32 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id OBwqHVCWxmMOMwEA9RJhRA (envelope-from ) for ; Tue, 17 Jan 2023 13:36:32 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 21DF716767 for ; Tue, 17 Jan 2023 13:36:32 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHlCT-00024K-8C; Tue, 17 Jan 2023 07:36:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHlC7-00021b-73 for guix-patches@gnu.org; Tue, 17 Jan 2023 07:36:12 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHlC6-0008Sk-Jw for guix-patches@gnu.org; Tue, 17 Jan 2023 07:36:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pHlC6-0001n5-0S for guix-patches@gnu.org; Tue, 17 Jan 2023 07:36:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60802] [PATCH v3 1/2] platforms: Raise an exception when no suitable platform is found. Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 17 Jan 2023 12:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60802 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Josselin Poiret Cc: 60802@debbugs.gnu.org, Maxim Cournoyer , Mathieu Othacehe , Tobias Geerinckx-Rice , Christopher Baines , Ricardo Wurmus Received: via spool by 60802-submit@debbugs.gnu.org id=B60802.16739589156801 (code B ref 60802); Tue, 17 Jan 2023 12:36:01 +0000 Received: (at 60802) by debbugs.gnu.org; 17 Jan 2023 12:35:15 +0000 Received: from localhost ([127.0.0.1]:36028 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHlBK-0001lc-9j for submit@debbugs.gnu.org; Tue, 17 Jan 2023 07:35:14 -0500 Received: from mail-wm1-f46.google.com ([209.85.128.46]:42839) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pHlBF-0001lL-W8 for 60802@debbugs.gnu.org; Tue, 17 Jan 2023 07:35:12 -0500 Received: by mail-wm1-f46.google.com with SMTP id f25-20020a1c6a19000000b003da221fbf48so8008679wmc.1 for <60802@debbugs.gnu.org>; Tue, 17 Jan 2023 04:35:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date :disposition-notification-to:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=9G6+ppwcPgTCx/RcNox++TwHLc3OKVJdsAe8lsXqrmc=; b=iNqrcHfMQ6+VfyM1Op+hg4wyj+9oVr1hr7FjA0va1lh0siDnhNp4BzXOEOHgGGQQTt YCWB5c1jlQpJraAPUMUimQKg7LktUY9NE2PElSs6/AYAiqOs2cC3lAcU0D2dpK/Mn+r+ VMV64ZNDvWNU0mHPNdjXL6927YA6LzaJ5XfIYFc9awRlS/Zlunwb3PmlKLd3bISvFlby ngTQyyVgDxg22dguvzkc2a7Q5QEhig7HhmWNHbPbFXA6HVqrZkWFwZOBpaxy1uzbTcRl mJJUrIKvVgRJjSi2X+kIyCg0jBkwGA64I46BVfUoMwZ93+FBB0ld7awafz8uOG7RtB0C Sehw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date :disposition-notification-to:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9G6+ppwcPgTCx/RcNox++TwHLc3OKVJdsAe8lsXqrmc=; b=VzbLqdEE4IcMdXZnk4BKDiQPZ702rZPAfQOGrDSbRaDJKHVOzCJJ4OIs2fvYytX9wm VnfXaHkKQyYr66U7TMCkCsStrWvqhOnkN+imq63lVAJLt7zupAywoB4Pcuz2ufYo4Ays 2q54vVmYm45gzehMfebFm0bNydx5myEL0ARF5vKPlGbCkcvHmVl3Gp8cUhFgoRATsHLu YQb8QD/msVTR1NZmj+nW4M1jUWulowOvPv5KfP598D8h9Q93BUiT2V71xTKsLwnPtliE nVwOTgEytwEcjtFClyS3DNUtKDpeJiEHW0lkviF49vyltCl3dKQu71ZbH6RVETnzCgZt FGDA== X-Gm-Message-State: AFqh2ko2JvL+FF4kppE3S8JwsNsvLA7wybXR595QlW9+sjqmLk4KU4th rjHByRP9gtN0Sm9VqedT1L8= X-Google-Smtp-Source: AMrXdXuNqQpVu5MVVxylYAh4+r0i1NZHe3qDe4AqNHEJd0jwFOUREjmOeM+eGPBr4z8pO7iQQZM04A== X-Received: by 2002:a05:600c:1c83:b0:3da:fe74:51ff with SMTP id k3-20020a05600c1c8300b003dafe7451ffmr694637wms.2.1673958903855; Tue, 17 Jan 2023 04:35:03 -0800 (PST) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id p21-20020a7bcc95000000b003c65c9a36dfsm35830838wma.48.2023.01.17.04.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 04:35:03 -0800 (PST) From: Simon Tournier In-Reply-To: <87r0vtk03h.fsf@gnu.org> References: <20230114151457.1903-2-maxim.cournoyer@gmail.com> <87zgajkiiy.fsf@jpoiret.xyz> <87r0vtk03h.fsf@gnu.org> Date: Tue, 17 Jan 2023 13:35:00 +0100 Message-ID: <87pmbds5jf.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1673958992; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=9G6+ppwcPgTCx/RcNox++TwHLc3OKVJdsAe8lsXqrmc=; b=D9wGImKnLC420KnXO4lyoTK9QvXUcbnh6VWpBam75BfT9uLkTH1aH5bpT6EvkLrtRPl0PD HB2tB223VTnZIZoyhlbzE6OAK1me2OMvVKMclJFbY0KwzliA9pA8/SQlFBQqRlyIWVNaRM BcKSnRLuoXCr0+wajUpZfXXL4ZtwbqJOZ9epGW8JXSOZV7/B6jqlz5c/27yO2OX1wrZXLk wdYzGYd5ydYM1AKm4/WAQQ1MoIwq7n1CuXOuDKG0862EcseJJBb1N8etk1H+dVUwVS6XJt TYUetx5ihnI1Jbr6BF5NlhwCcJyuPtz5rDDvsE8Vzs9q9Xw8ym/t9MfCly8OYw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=iNqrcHfM; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1673958992; a=rsa-sha256; cv=none; b=ciQVZSbLaV2bry0ftItBDS4HKbc8BkmW9Q+NM/xzAnCwAMRoEf1lnHK/smWDCJyykSKOTx IL7bGlRaSiMLiaO+e9lQYHVxqbh0Ww1o985VbmcUlR7PupHiiFs3/MOsJTMmqVmmkb+WFu S88E8vVRmhlb9QBRMv6n+uuLtcS2yXf0YIRgyTYD6ak901Zr9td2uTnpySMBWI3NUMHLr2 old7BXdFUqsra/DhAh+2JrsUhuWPyBUSHGWKGDtkiaCTu0OxGbiCCG+T6RoA4wOb2AZz4w UpzXY9Ro4HR5E9c5OurTGOGMyjG1CNWsRmFL4TTTYqZcSnNrhi3G4sf+dHhu6Q== X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: 5.77 X-Spam-Score: 5.77 X-Migadu-Queue-Id: 21DF716767 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=iNqrcHfM; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) X-TUID: U5EsgHcWA1GL Hi, On mar., 17 janv. 2023 at 09:59, Ludovic Court=C3=A8s wrote: > Josselin Poiret skribis: > >> This looks good to me, although in the grand scheme of things I wonder >> if that change is a step forward: for those kinds of procedures, we >> could expect consumers to instead always properly handle the #f case >> themselves, rather than baby-sitting them and systematically relying on >> exceptions in the parent procedure, no? As a caricatural example: the >> SRFI-1 `find` could raise an exception instead of returning #f, but I >> don't think anyone would consider that proper behaviour. > > I share this sentiment in general (plus the fact that we should keep UI > aspects, such as error reports, separate from core logic). Here there=E2= =80=99s > a precedent with other lookup procedures though > (=E2=80=98lookup-bootloader-by-name=E2=80=99, =E2=80=98lookup-compressor= =E2=80=99, > =E2=80=98lookup-image-type-by-name=E2=80=99, etc.), so I think it=E2=80= =99s okay to keep it that > way. Well, from my small experience with other programming language, they barely do return a boolean when they fail. I think this way using a boolean is because some historical reasons when exceptions was not implemented in Scheme (or other languages). Exception allows the motto: =C2=ABask for forgiveness, not permission=C2=BB= while keeping under control the side effects. Well, IMHO exception is often a good practise for dynamically typed programming language; as Scheme (or Python). >From my point of view, exception is not related to =E2=80=9Cshould keep UI aspects, such as error reports, separated from core logic=E2=80=9D. This i= s how the exception is handled. It is often easier to propagate exception until an handler than propagate a boolean (as with =E2=80=99find=E2=80=99). And if the exception is not handled, then it just returns a backtrace, which is more informative, IMHO. For instance, Python returns an exception: --8<---------------cut here---------------start------------->8--- $ guix shell python python-ipython -- ipython Python 3.9.9 (main, Jan 1 1970, 00:00:01)=20 Type 'copyright', 'credits' or 'license' for more information IPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: lst =3D [1,2,3] lst =3D [1,2,3] In [2]: lst.index(2) Out[2]: 1 In [3]: lst.index(10) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [3], in () ----> 1 lst.index(10) ValueError: 10 is not in list --8<---------------cut here---------------end--------------->8--- For other instances, OCaml implements two =E2=80=99find=E2=80=99 [1], one u= sing an exception and another using a Maybe monad (named =E2=80=99option=E2=80=99). --8<---------------cut here---------------start------------->8--- val find : ('a -> bool) -> 'a list -> 'a Raises Not_found if there is no value that satisfies f in the list l. val find_opt : ('a -> bool) -> 'a list -> 'a option --8<---------------cut here---------------end--------------->8--- Haskell returns a Maybe monad [2]: --8<---------------cut here---------------start------------->8--- find :: Foldable t =3D> (a -> Bool) -> t a -> Maybe a=20 --8<---------------cut here---------------end--------------->8--- Well, from a signature point of view, =E2=80=99find=E2=80=99 from SRFI-1 re= turns an union type (value or boolean) which can lead to hard to detect bugs: when composing functions, the error can be incorrectly pointed by the compiler to a totally unrelated place. Instead, the exception allows to keep an expected signature (say one value as with =E2=80=99find=E2=80=99) but raises the error at the correct p= lace. If there is no handler, it just raises the backtrace. >From my point of view, code using exception cannot be worse* than without. That=E2=80=99s my general sentiment. :-) *worse: for sure, we could discuss some performance penalty depending on the context. 1: 2: Cheers, simon