From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id CKNUDxqMNmXn9AAAauVa8A:P1 (envelope-from ) for ; Mon, 23 Oct 2023 17:07:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id CKNUDxqMNmXn9AAAauVa8A (envelope-from ) for ; Mon, 23 Oct 2023 17:07:06 +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 7B1B458461 for ; Mon, 23 Oct 2023 17:07:05 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=ev0LxHc3; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1698073626; a=rsa-sha256; cv=none; b=lRu0tObnv1MKQcGoYnbUTxj/GUWCsd0OKn7QBg2+4xVkIiVzJHJPPswxSEWZcAmIGtDquv 7m/j0/DMboW/I+2UN6XAbJEFeZDqbJugPIWuu3dSurBOuJWY/Uf8PBqJ6xzfWjXcV3sALc cWqCnR0VuwMyDWYP/oc9KQ2Cd29sANo4xDN6YOuPE3wRVXWdb54uNF/cXyL9hM2vIaAns8 tt15/jtxdkD9xJ5W34lagMX8+gnSakcebIfdDgG6YHU2UqBOfkdfkebnN/OpXK4fNJLk74 eSgj+U+wGZ3Jwog5Hj/C2q5rqHg/vNb1MPL2GHZe3Q/sOHOPyiOveXiJkabaAQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=ev0LxHc3; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1698073626; 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=eaOTKh+CB2aYwrkDIwK3OvCeIs8CkONstXhdWY/ZlKA=; b=mtG+xQJ7BJlCgrIliyHyzPqepsMHck095kwqcpE1QRPODgakmJUZtIBcAztkTBuuKOG7qT AexDxfJM6AUaz81PljIMPYkZt0jS2BPndwDSV8GWZbOqWil5ECQRx/SXaxrrMk2gSKMH8a oqSUbJDL32Yh47NNKUTGkP+NUxjhaTOKY+iXpdmnd6FcSdGqgJCgnJqW0OwUWy3IAKcbzL fah2ZcJn/ojwUA+wLvkoaRSvGkkq9ZJaO+UiMCCJUGRgcv6FYtxgB/crKsGGibTdOcS4Ai xL3hbtqTWTt/gT92LejKUT8P2+FVFNcaREifTtdT/R7BPfVDt4if5jgg/PwANA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quwVo-0003Sl-Ul; Mon, 23 Oct 2023 11:06:37 -0400 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 1quwVl-0003SX-Br for guix-patches@gnu.org; Mon, 23 Oct 2023 11:06:34 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quwVl-0005fL-2W for guix-patches@gnu.org; Mon, 23 Oct 2023 11:06:33 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1quwWE-0000gF-1z for guix-patches@gnu.org; Mon, 23 Oct 2023 11:07:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42146] [PATCH core-updates 1/?] build: substitute: Don't fail silently. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 23 Oct 2023 15:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42146 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= , 42146@debbugs.gnu.org Received: via spool by 42146-submit@debbugs.gnu.org id=B42146.16980735692549 (code B ref 42146); Mon, 23 Oct 2023 15:07:02 +0000 Received: (at 42146) by debbugs.gnu.org; 23 Oct 2023 15:06:09 +0000 Received: from localhost ([127.0.0.1]:51346 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quwVN-0000f3-3B for submit@debbugs.gnu.org; Mon, 23 Oct 2023 11:06:09 -0400 Received: from mail-qv1-xf32.google.com ([2607:f8b0:4864:20::f32]:49558) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quwVL-0000ep-IP for 42146@debbugs.gnu.org; Mon, 23 Oct 2023 11:06:08 -0400 Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-66cfc96f475so20294246d6.3 for <42146@debbugs.gnu.org>; Mon, 23 Oct 2023 08:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698073533; x=1698678333; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eaOTKh+CB2aYwrkDIwK3OvCeIs8CkONstXhdWY/ZlKA=; b=ev0LxHc3lMHaFWsXQji5T+1TZZfO83LMyst5Hyy6h+dcfKQFZrkqmn1NOmpMIkOrt+ hzhbptvrZtxcML9hOaKWNYBzBtNzPMf4jGScsCY3iF1YQzo4iimeGjb3ZGDCJ50B5kyr B/Jtl1/aaji4PIVACj3ZmvxpRLdsVKkfm8gQ/nbIq/0xMKXqbci+vddZ+A4f9yWgX1xD 17CFu0bykJMF02AQSqjm1aIP2mW8ENnXxGHUtiuVpfkJkrvuXvdQpzmbPJBWVDfHhReV TxVEj8VaYijw2JjKOiKlu7Bo23HfVEzc2xGnrlJnSzjHCfY+Hgt8pK5BCf2xYmiJemdd wxsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698073533; x=1698678333; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eaOTKh+CB2aYwrkDIwK3OvCeIs8CkONstXhdWY/ZlKA=; b=EC2DUY/JJmar24UiXBzuHZKo/WKMjrkCBFf61cmc1YOjrWHledSVWLltKCGs3t7YIy 0OteGS4OyiU6ZfoK7ptmZaCy37FDh2hVW4ooZlvtSFfaBGnzjbK5zwFXY+jeRYeGuV1H tfKI9Vdfg/qp94Hs7n93HGnbWs3HDcY42nKuO23kGvtrAHFHuLtc4X1CmOjqpDXtclmj OVB0gdgxKQCzrm41DsWwa6RBRlRc6KdW3v8uxN3ceKtzjtp7/lzu8hm96LDp4Leo0Ngt cmS6dVI4jsc+q1zuGe/XE2xv81QTyQjrSZIcgWqAIWxl7ZeoS8XkBDoSl/MKzRLPGmOW Mg+w== X-Gm-Message-State: AOJu0YwlscsWR8BekTx++0EHlM7Ph0MQWdEVUGKMc01R+6HO6j1Tgyoz rlt9V/Zdlz3/6dkRc1RRIo15iC23ehTYsQ== X-Google-Smtp-Source: AGHT+IEVZRtkx2o4xJ+RU+OSt9Qc7HESqer2moKVumZkzgaBXoEH86CJDHN4dAS3i9Z0NvqYOxDFQg== X-Received: by 2002:ad4:4eea:0:b0:66d:6406:1301 with SMTP id dv10-20020ad44eea000000b0066d64061301mr11100250qvb.20.1698073532607; Mon, 23 Oct 2023 08:05:32 -0700 (PDT) Received: from hurd (dsl-10-148-194.b2b2c.ca. [72.10.148.194]) by smtp.gmail.com with ESMTPSA id pz6-20020ad45506000000b0065b24c08994sm2924213qvb.128.2023.10.23.08.05.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 08:05:32 -0700 (PDT) From: Maxim Cournoyer In-Reply-To: <875y2xivbz.fsf_-_@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Mon, 23 Oct 2023 10:42:08 +0200") References: <20200630220913.14665-1-kuba@kadziolka.net> <87lebyxs4y.fsf_-_@gnu.org> <87pm1anp6a.fsf_-_@gmail.com> <875y2xivbz.fsf_-_@gnu.org> Date: Mon, 23 Oct 2023 11:05:31 -0400 Message-ID: <87ttqh751g.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) 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 X-Migadu-Scanner: mx1.migadu.com X-Migadu-Spam-Score: 2.87 X-Spam-Score: 2.87 X-Migadu-Queue-Id: 7B1B458461 X-TUID: mvGLlRzPM1es Hi Ludovic, Ludovic Court=C3=A8s writes: > Hi Maxim, > > Maxim Cournoyer skribis: > >> Ludovic Court=C3=A8s writes: > > [...] > >>>> +;;; Extend regexp objects with a pattern field. >>>> +;;; >>>> +(define-record-type >>>> + (%make-regexp* pat flag rx) >>>> + regexp*? >>>> + (pat regexp*-pattern) ;the regexp pattern, a string >>>> + (flag regexp*-flag) ;regexp flags >>>> + (rx regexp*-rx)) ;the compiled regexp object >>>> + >>>> +;;; Work around regexp implementation. >>>> +;;; This record allows to track the regexp pattern and then display i= t. >>>> +(define* (make-regexp* pat #:optional (flag regexp/extended)) >>> >>> I=E2=80=99m skeptical about the concrete benefits. I would not include= it in >>> (guix build utils), or at least not in this patch series. > > [...] > >> The benefit is concrete: it makes it possible to show which regexp >> pattern failed to match (its textual representation), instead of >> something much less useful such as a generic placeholder such as >> " (regexp)". > > Yes, okay. > > Can we keep the interface private, then? To me it=E2=80=99s an > implementation detail and perhaps a bit of a hack that I=E2=80=99d rather= not > commit to maintaining. If you can think of a more elegant way to define it, I'm all ears. Ideally, as Simon pointed out, that's something that Guile would support natively (the ability to pull back the raw pattern from a regexp object). In Python for example, the re.Pattern object has a 'pattern' property [0] [0] https://docs.python.org/3/library/re.html?highlight=3Dregex#re.Pattern= .pattern Otherwise I don't think "the bit of a hack" is substantiated enough :-). > The cost might be to duplicate it in teams.scm, but that=E2=80=99s an acc= eptable > cost IMO. I dislike copying bits around just to "hide" them from the "official" interface, and have no fear maintaining that simple piece of code, so I'd rather keep it at one place and expose it as a public API. >> It's in actual use if you look at the definition of substitute: >> >> >> (let ((rx+proc (map (match-lambda >> (((or (? regexp? pattern) (? regexp*? pattern)) = . proc) >> (cons pattern proc)) >> ((pattern . proc) >> (cons (make-regexp* pattern regexp/extended) pr= oc))) >> pattern+procs))) >> >> The previous version followed a different approach, annotating the >> rx+proc list with the raw pattern; I think the approach here is a bit >> cleaner, and it should also enable users to pass pre-computed regexp* >> objects to substitute* and have useful error messages produced. > > Note that =E2=80=98substitute*=E2=80=99 only takes string literals as pat= terns, not > regexp objects. The pattern part of clauses has sometimes been abused > to pass code, typically =E2=80=98string-append=E2=80=99 calls, but that= =E2=80=99s definitely not > the spirit. > It's true that 'substitute*' only accepts literal patterns, but that's not the case with 'substitute' itself, which is also exposed in the API of (guix build utils): it accepts regexp objects as well, and thus there's value in this change -- users could in theory use make-regexp* objects and pass that to 'substitute' and benefit from more precises error messages. > Another approach would have been, in =E2=80=98substitute*=E2=80=99, to ca= pture the > regexp-as-string as well as other useful debugging info, such as its > source location. That'd be a nice solution, but it doesn't take into account 'substitute', as mentioned above. As it has exactly zero (!) users outside of substitute*, perhaps it could be yanked from the public API and then we could consider doing the above for substitute* ? --=20 Thanks, Maxim