From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Making substitute* throw an error if substition failed? Date: Mon, 17 Oct 2016 10:50:36 +0200 Message-ID: <874m4bfjfn.fsf@gnu.org> References: <87twceh9h7.fsf@elephly.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bw3d3-0000g8-EL for guix-devel@gnu.org; Mon, 17 Oct 2016 04:50:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bw3d0-0002pS-Oy for guix-devel@gnu.org; Mon, 17 Oct 2016 04:50:41 -0400 In-Reply-To: <87twceh9h7.fsf@elephly.net> (Ricardo Wurmus's message of "Sat, 15 Oct 2016 00:05:56 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ricardo Wurmus Cc: guix-devel Hi, Ricardo Wurmus skribis: > it happened a couple of times already that a =E2=80=9Csubstitute*=E2=80= =9D expression > silently failed and I only found out about it when investigating the > remains of a failing build (=E2=80=9Cguix build -K=E2=80=9D). This can e= asily happen > when a package is updated and substitutions =E2=80=9Canchors=E2=80=9D no = longer exist in > the updated source code. > > Would it be desirable to change =E2=80=9Csubstitute*=E2=80=9D (or replace= it) such that > it throws an error or returns a value if substitution failed? =E2=80=9CFailed=E2=80=9D as in =E2=80=9Cthere were no pattern matches=E2=80= =9D, right? > This might be helpful for the more complex packages with many > substitutions. If we make it return a value (#f for error) it would > also make our build phases a little prettier, I think. (Now we > forcefully return #t in any case and that seems wrong.) I like this idea. Like others wrote, it could return #t if one or more substitutions were made, and #f otherwise. I think it=E2=80=99s better than throwing an error, because there are cases where it doesn=E2=80=99t matter whether a substitution was made or not (e.g= ., when replacing strings en masse on a set of files.) WDYT? Thanks, Ludo=E2=80=99.