GNU bug report logs - #36772
feature request: checked variant of "substitute*"

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix; Severity: wishlist; Reported by: Robert Vollmert <rob@HIDDEN>; dated Tue, 23 Jul 2019 12:51:01 UTC; Maintainer for guix is bug-guix@HIDDEN.

Message received at 36772 <at> debbugs.gnu.org:


Received: (at 36772) by debbugs.gnu.org; 25 Jul 2019 17:40:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jul 25 13:40:57 2019
Received: from localhost ([127.0.0.1]:40407 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hqhjd-0004cK-1S
	for submit <at> debbugs.gnu.org; Thu, 25 Jul 2019 13:40:57 -0400
Received: from eggs.gnu.org ([209.51.188.92]:33915)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1hqhjb-0004c3-LX
 for 36772 <at> debbugs.gnu.org; Thu, 25 Jul 2019 13:40:55 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:47811)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1hqhjW-0002wA-GW; Thu, 25 Jul 2019 13:40:50 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=49616 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1hqhjW-0002vv-2u; Thu, 25 Jul 2019 13:40:50 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Ricardo Wurmus <rekado@HIDDEN>
Subject: Re: bug#36772: feature request: checked variant of "substitute*"
References: <E8613602-3151-405B-AC42-20D0A2CAD299@HIDDEN>
 <87zhl4c1rc.fsf@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 7 Thermidor an 227 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: Thu, 25 Jul 2019 19:40:48 +0200
In-Reply-To: <87zhl4c1rc.fsf@HIDDEN> (Ricardo Wurmus's message of "Tue,
 23 Jul 2019 15:35:19 +0200")
Message-ID: <875znqrp0f.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 36772
Cc: 36772 <at> debbugs.gnu.org, Robert Vollmert <rob@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Ricardo Wurmus <rekado@HIDDEN> skribis:

>> I think it would be great to have the following variant of substitute*:
>>
>> (substitute*-once filename (pattern vars) body)
>>
>> which acts like the usual substitute-*, except it also asserts that the
>> substitution applies to exactly one line in the file, causing a build
>> failure otherwise.
>
> I agree that the effect of substitute* should be checked.  I think
> substitute* should fail when one of its clauses failed to match
> anything.
>
> Each clause could also accept an optional argument to make them only
> match one location.  We wouldn=E2=80=99t have to duplicate the macro for =
that
> and it=E2=80=99s a simple extension to failing on zero matches.
>
> What do you think?

That=E2=80=99d be a useful extension.

Ludo=E2=80=99.




Information forwarded to bug-guix@HIDDEN:
bug#36772; Package guix. Full text available.

Message received at 36772 <at> debbugs.gnu.org:


Received: (at 36772) by debbugs.gnu.org; 23 Jul 2019 13:42:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 23 09:42:20 2019
Received: from localhost ([127.0.0.1]:34160 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hpv3c-00077z-5S
	for submit <at> debbugs.gnu.org; Tue, 23 Jul 2019 09:42:20 -0400
Received: from mx2.mailbox.org ([80.241.60.215]:21874)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1hpv3Z-00077k-Cy
 for 36772 <at> debbugs.gnu.org; Tue, 23 Jul 2019 09:42:17 -0400
Received: from smtp2.mailbox.org (smtp2.mailbox.org
 [IPv6:2001:67c:2050:105:465:1:2:0])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mx2.mailbox.org (Postfix) with ESMTPS id 89E7AA168F;
 Tue, 23 Jul 2019 15:42:11 +0200 (CEST)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp2.mailbox.org ([80.241.60.241])
 by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de
 [80.241.56.115]) (amavisd-new, port 10030)
 with ESMTP id 9_ndptVq-2MY; Tue, 23 Jul 2019 15:42:02 +0200 (CEST)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\))
Subject: Re: bug#36772: feature request: checked variant of "substitute*"
From: Robert Vollmert <rob@HIDDEN>
In-Reply-To: <87zhl4c1rc.fsf@HIDDEN>
Date: Tue, 23 Jul 2019 15:41:58 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <15DD757F-8CCE-4092-925C-0B76824B5E47@HIDDEN>
References: <E8613602-3151-405B-AC42-20D0A2CAD299@HIDDEN>
 <87zhl4c1rc.fsf@HIDDEN>
To: Ricardo Wurmus <rekado@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 36772
Cc: 36772 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)



> On 23. Jul 2019, at 15:35, Ricardo Wurmus <rekado@HIDDEN> wrote:
>=20
>=20
> Hi Robert,
>=20
>> I think it would be great to have the following variant of =
substitute*:
>>=20
>> (substitute*-once filename (pattern vars) body)
>>=20
>> which acts like the usual substitute-*, except it also asserts that =
the
>> substitution applies to exactly one line in the file, causing a build
>> failure otherwise.
>=20
> I agree that the effect of substitute* should be checked.  I think
> substitute* should fail when one of its clauses failed to match
> anything.
>=20
> Each clause could also accept an optional argument to make them only
> match one location.  We wouldn=E2=80=99t have to duplicate the macro =
for that
> and it=E2=80=99s a simple extension to failing on zero matches.
>=20
> What do you think?

That sounds like a good improvement, too. I think the important part is
ensuring the substitution matches at all, maybe we could leave out the
=E2=80=9Cat most once=E2=80=9D part. (I doubt it would be used a lot if =
it=E2=80=99s not the default.)

Cheers
Robert





Information forwarded to bug-guix@HIDDEN:
bug#36772; Package guix. Full text available.

Message received at 36772 <at> debbugs.gnu.org:


Received: (at 36772) by debbugs.gnu.org; 23 Jul 2019 13:35:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 23 09:35:30 2019
Received: from localhost ([127.0.0.1]:34156 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hpux0-0006xQ-BL
	for submit <at> debbugs.gnu.org; Tue, 23 Jul 2019 09:35:30 -0400
Received: from sender-of-o51.zoho.com ([135.84.80.216]:21212)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rekado@HIDDEN>) id 1hpuwx-0006xF-5X
 for 36772 <at> debbugs.gnu.org; Tue, 23 Jul 2019 09:35:28 -0400
ARC-Seal: i=1; a=rsa-sha256; t=1563888924; cv=none; d=zoho.com; s=zohoarc; 
 b=lMuKK2VrQIgAkgrU1x3o5txX2dMvIdAYBYmisVXH3SGV3Yha6YjMAohE7lztDKoK5+OrwDFO2lCQc5ehl+KCwjPc3ZMGD6VY+VaWK3HtDLkr8vUlLaGGh7t4r4WqE24psIrf2HKDSrzOb2mPHBozkuCdU5F6PmlXrcC7mIbaVaE=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
 s=zohoarc; t=1563888924;
 h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To:ARC-Authentication-Results;
 bh=YN5/OAPKRR4kUy/1Xf9cKGcVZamCDNHoX0JC26B10q4=; 
 b=PZEkLkCQGIIpkQDN2Mljg4BG67P9Pg9ifkezpahgKDYOqZ0S9jp/b/X0oOicoLEknX2+qHVW86fNx/gui6Ldj8QbOb+Nx3GLmJd6McLMRD2FoAmY5WrfHKKN/4Bhp3T4yDTA/rk55OGLWkmk7CH7epzgIid8Uqwr0DHdJiVbFis=
ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass  header.i=elephly.net;
 spf=pass  smtp.mailfrom=rekado@HIDDEN;
 dmarc=pass header.from=<rekado@HIDDEN> header.from=<rekado@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1563888924; 
 s=zoho; d=elephly.net; i=rekado@HIDDEN;
 h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding;
 l=718; bh=YN5/OAPKRR4kUy/1Xf9cKGcVZamCDNHoX0JC26B10q4=;
 b=Ny0gvXshBavdf7Szl7yoVtkD1iLsvXiGExsOfbPG1YfldT++mt39opk4p41nViz0
 RFnkgfcACiE/9ZMzAuwo/c/FXK9E+Z2Uzp2w3YNEAC7HZQ5k2xEzJuE8HT61E+7LdRD
 Xcc+uUjvpahiYYk/8YVTqFP9JWQQF4l3FpZFCdxA=
Received: from localhost (141.80.247.250 [141.80.247.250]) by mx.zohomail.com
 with SMTPS id 1563888922353256.1380461751379;
 Tue, 23 Jul 2019 06:35:22 -0700 (PDT)
References: <E8613602-3151-405B-AC42-20D0A2CAD299@HIDDEN>
User-agent: mu4e 1.2.0; emacs 26.2
From: Ricardo Wurmus <rekado@HIDDEN>
To: Robert Vollmert <rob@HIDDEN>
Subject: Re: bug#36772: feature request: checked variant of "substitute*"
In-reply-to: <E8613602-3151-405B-AC42-20D0A2CAD299@HIDDEN>
X-URL: https://elephly.net
X-PGP-Key: https://elephly.net/rekado.pubkey
X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
Date: Tue, 23 Jul 2019 15:35:19 +0200
Message-ID: <87zhl4c1rc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-ZohoMailClient: External
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 36772
Cc: 36772 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Hi Robert,

> I think it would be great to have the following variant of substitute*:
>
> (substitute*-once filename (pattern vars) body)
>
> which acts like the usual substitute-*, except it also asserts that the
> substitution applies to exactly one line in the file, causing a build
> failure otherwise.

I agree that the effect of substitute* should be checked.  I think
substitute* should fail when one of its clauses failed to match
anything.

Each clause could also accept an optional argument to make them only
match one location.  We wouldn=E2=80=99t have to duplicate the macro for th=
at
and it=E2=80=99s a simple extension to failing on zero matches.

What do you think?

--
Ricardo





Information forwarded to bug-guix@HIDDEN:
bug#36772; Package guix. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 Jul 2019 12:50:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 23 08:50:13 2019
Received: from localhost ([127.0.0.1]:34136 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hpuFB-0001dE-6h
	for submit <at> debbugs.gnu.org; Tue, 23 Jul 2019 08:50:13 -0400
Received: from lists.gnu.org ([209.51.188.17]:50792)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1hpuF9-0001d4-Mr
 for submit <at> debbugs.gnu.org; Tue, 23 Jul 2019 08:50:12 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:46726)
 by lists.gnu.org with esmtp (Exim 4.86_2)
 (envelope-from <rob@HIDDEN>) id 1hpuF8-0001JJ-OC
 for bug-guix@HIDDEN; Tue, 23 Jul 2019 08:50:11 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rob@HIDDEN>) id 1hpuF7-0007DG-SW
 for bug-guix@HIDDEN; Tue, 23 Jul 2019 08:50:10 -0400
Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]:19642)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <rob@HIDDEN>) id 1hpuF7-0007Bg-M4
 for bug-guix@HIDDEN; Tue, 23 Jul 2019 08:50:09 -0400
Received: from smtp1.mailbox.org (smtp1.mailbox.org
 [IPv6:2001:67c:2050:105:465:1:1:0])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mx1.mailbox.org (Postfix) with ESMTPS id E8876509FD
 for <bug-guix@HIDDEN>; Tue, 23 Jul 2019 14:50:04 +0200 (CEST)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de
 [80.241.56.115]) (amavisd-new, port 10030)
 with ESMTP id 2b-YWzYIE7zN for <bug-guix@HIDDEN>;
 Tue, 23 Jul 2019 14:50:01 +0200 (CEST)
From: Robert Vollmert <rob@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\))
Subject: feature request: checked variant of "substitute*"
Message-Id: <E8613602-3151-405B-AC42-20D0A2CAD299@HIDDEN>
Date: Tue, 23 Jul 2019 14:49:46 +0200
To: bug-guix@HIDDEN
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2001:67c:2050:104:0:1:25:1
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

I think it would be great to have the following variant of substitute*:

(substitute*-once filename (pattern vars) body)

which acts like the usual substitute-*, except it also asserts that the
substitution applies to exactly one line in the file, causing a build
failure otherwise.

In the cases where this is sufficient (I believe most), it would make
substitution work quite a bit more reliably, making it both easier to
debug substitution when first packaging, and noticing more easily when
they need to be adapted on upgrades.

(It would be possible to make the signature a bit more flexible and to
allow multiple files or patterns as in substitute*, but that would
make the meaning of =E2=80=9Capplies exactly once=E2=80=9D a bit =
unclear, so I=E2=80=99d prefer
to not do that. Similarly, I find it cleaner to potentially call
substitute*-once several times in a row with different substitutions to
make the ordering of effects explicit.)

(I=E2=80=99d be happy to supply a patch myself eventually, but the =
syntax rule
business is a bit out of reach at this point.)





Acknowledgement sent to Robert Vollmert <rob@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guix@HIDDEN. Full text available.
Report forwarded to bug-guix@HIDDEN:
bug#36772; Package guix. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.