From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CHjzDoooRGKXfQAAgWs5BA (envelope-from ) for ; Wed, 30 Mar 2022 11:53:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id aCCUC4ooRGKgPwAAauVa8A (envelope-from ) for ; Wed, 30 Mar 2022 11:53:14 +0200 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 E5788EAF8 for ; Wed, 30 Mar 2022 11:53:13 +0200 (CEST) Received: from localhost ([::1]:56252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZV0r-0002F6-0A for larch@yhetil.org; Wed, 30 Mar 2022 05:53:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZUlR-00074b-JC for guix-devel@gnu.org; Wed, 30 Mar 2022 05:37:20 -0400 Received: from [2001:470:142:3::e] (port=58304 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZUlP-0004eE-Iw; Wed, 30 Mar 2022 05:37:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=9xKmBeXn+W9oCfe7816eM7jrZcuoXKGFgcsq+uAz0BU=; b=Ugb0ZmdDaCK5ReV6y1Xh lzFWlVrnZXewjLQZ2cFQ4gJXsQo1pv7+rGAB6HEGfmcO+3EleKZ5R0mPNIF/FwVMx50HvaHytjLoZ J06TH8rjF7RrnvOQmIbxBUWcyjUrdxCG6GjiIioiyvizRzI2UuDqoXDR0pLjb2HzdXdXjDbGmo+xH CsBWqfyZMEDL6u/j0HS8ASyFYcCK5Zy2/Kdlh1ZVhvplmcCF0GyRaUMEZVhK9Tx/oOb+cUgGBugyM ot1WSQVXo5iFTBpQmT/kbBN8dFNXA1l99THl0KGHWFST0YWg+4RZYGwSwyotSqr79XsQfo0bbb0+p J9S8if2jxL8d7A==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:54780 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZUlN-0000vt-Mq; Wed, 30 Mar 2022 05:37:14 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Philip McGrath Subject: Re: better error messages through assertions References: <87ilthoxvu.fsf@elephly.net> <87k0dv6ahq.fsf@elephly.net> <87mtibdu5l.fsf@gnu.org> <2205364.8dmU9V6fpu@bastet> <87cziy2hq0.fsf@gnu.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 10 Germinal an 230 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 30 Mar 2022 11:37:10 +0200 In-Reply-To: (Philip McGrath's message of "Mon, 28 Mar 2022 16:25:33 -0400") Message-ID: <87lewrwzll.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ricardo Wurmus , guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1648633993; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=9xKmBeXn+W9oCfe7816eM7jrZcuoXKGFgcsq+uAz0BU=; b=nlqKz8K7HumhC5Gq2+mqxzgXmHX8BqTA34SasS/GYIUuo55r++nflqx3EpewqGOWUvl55r IFRTjPaH6TtrXa5rqAWgT1prR3P2RWcn+NWbdEI7WAhOrooeB05ymqSyy4MMcTOBunIsca ZBCXRqHXYSsQkzvnDcnt8ffkUGeEyiKNycBaSRJxK8YJUxxLQJAQ55qOVBf+bydDohYC7p SBjZuPVyRQIEd5LzQVMTp/7vmg3UnXFujUKQMluGvJeI1AwLYLaa1uhfPLWEz3HQaF+Zd1 knZbsgCTEwaZ2gCMbxHuvKWISVq3SYzL6MDTwMPs3AK19VGhu3Lbuhfj4ICSCg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648633993; a=rsa-sha256; cv=none; b=coyib8zKrKduHwZwRmwbyOybe5d9BT8BjsU4Okc7N8NyzOCYdIkvns85p7Zm7qZjAiNAEO j5hxXSDt/pvKaMwzIYxyjNB/KROxAI55qlVCKwAtauAoE6Wnw0sv8VVwih+FSNmrrGRnIx I7m7NuTI5SG4LC/x5MuKZ6oHpDDu+EDT0aVdsP45jcU0NUzS1+i+toD+mbA5LlYDlthBZJ RMxIFP5d0Sq3b6/RS0YNuzWebi062qhWZKCY1iFN2AVKttYpbx6jqPC936Xn7GxmCLi52I udsqYN44mQl04aDUFbfwtQA5q5/naRLwOuG9vLYdJtVAtTuuNfDfIjyA2px+cA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=Ugb0ZmdD; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -9.57 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gnu.org header.s=fencepost-gnu-org header.b=Ugb0ZmdD; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E5788EAF8 X-Spam-Score: -9.57 X-Migadu-Scanner: scn0.migadu.com X-TUID: nZLvPTQW7FIO Hi Philip, Philip McGrath skribis: > I'm thinking that a reasonable place to start might be to implement a > `contract->sanitizer` form that would allow using contracts to create=20 > sanitizers, ideally with no changes to `(guix records)`. OK. I=E2=80=99d prefer if people who define record types could directly wr= ite: (field getter (contract integer/c)) rather than: (field getter (sanitizer (contract->sanitizer integer/c))) But that=E2=80=99s more of a detail. > What is the preferred mechanism for exceptions? For Guix code, SRFI-34/35. > Likewise, what record system should I use? SRFI-9. (Perhaps we should put answers to these questions in the =E2=80=9CCoding St= yle=E2=80=9D section of the manual.) > Also, I don't know much about how the "abi" aspect of (guix records) > works and what types of changes there would trigger rebuilds. (Though,=20 > again, I hope no changes would be needed for the proof-of-concept phase.) I don=E2=80=99t think you need to worry about that. > Another problem here seems to be the fault of (srfi srfi-9). For example: [...] > scheme@(guile-user)> (container-contents '()) > ice-9/boot-9.scm:1685:16: In procedure raise-exception: > In procedure struct-vtable: Wrong type argument in position 1 > (expecting struct): () > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user) [1]> ,bt > In current input: > 3:0 1 (_) > In ice-9/boot-9.scm: > 1685:16 0 (raise-exception _ #:continuable? _) > ``` > > It seems like `container-contents` and other field accessors ought to > check their arguments with `container?` (or the applicable predicate)=20 > and not leave error reporting to `struct-vtable`. SRFI-9 generates the smallest amount of code for the job: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(srfi srfi-9) scheme@(guile-user)> (define-record-type (make-foo x) foo? (x foo-x)) scheme@(guile-user)> ,optimize (foo-x '()) $9 =3D (if (eq? (struct-vtable '()) ) (struct-ref '() 0) (throw 'wrong-type-arg 'foo-x "Wrong type argument: ~S" (list '()) (list '()))) --8<---------------cut here---------------end--------------->8--- With Guile 3, it might be that adding an extra =E2=80=98struct?=E2=80=99 te= st would have little effect on performance; we=E2=80=99d need to check. > Perhaps this could be fixed in the (guix records) layer? Could be, yes. Thanks for looking into this! Ludo=E2=80=99.