From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: bug#24450: [PATCHv2] Re: pypi importer outputs strange character series in optional dependency case. Date: Mon, 10 Jun 2019 11:23:10 +0200 Message-ID: <87blz5dcap.fsf@mdc-berlin.de> References: <87pnod7ot4.fsf@gmail.com> <87muiq5d7c.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:42506) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1haGX5-0004hc-RC for bug-guix@gnu.org; Mon, 10 Jun 2019 05:24:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1haGX4-0006aX-NG for bug-guix@gnu.org; Mon, 10 Jun 2019 05:24:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42458) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1haGX4-0006aJ-Iw for bug-guix@gnu.org; Mon, 10 Jun 2019 05:24:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1haGX4-0006o8-DX for bug-guix@gnu.org; Mon, 10 Jun 2019 05:24:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87muiq5d7c.fsf@gmail.com> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Maxim Cournoyer Cc: 24450@debbugs.gnu.org Maxim Cournoyer writes: >>> + ;; (extra) requirements. Non-optional requirements must app= ear >>> + ;; before any section is defined. >>> + (if (or (eof-object? line) (section-header? line)) >>> + (reverse result) >>> + (cond >>> + ((or (string-null? line) (comment? line)) >>> + (loop result)) >>> + (else >>> + (loop (cons (clean-requirement line) >>> + result)))))))))) >>> + >> >> I think it would be better to use =E2=80=9Cmatch=E2=80=9D here instead o= f nested =E2=80=9Clet=E2=80=9D, >> =E2=80=9Cif=E2=80=9D and =E2=80=9Ccond=E2=80=9D. At least you can drop = the =E2=80=9Cif=E2=80=9D and just use cond. >> >> The loop let and the inner let can be merged. > > I'm not sure I understand; wouldn't merging the named let with the plain > let mean adding an extra LINE argument to my LOOP procedure? I don't > want that. Let=E2=80=99s forget about merging the nested =E2=80=9Clet=E2=80=9D, becaus= e you would indeed need to change a few more things. It=E2=80=99s fine to keep that as it is.= But (if =E2=80=A6 (cond =E2=80=A6)) is not pretty. At least it could be done i= n one =E2=80=9Ccond=E2=80=9D: (cond ((or (eof-object? line) (section-header? line)) (reverse result)) ((or (string-null? line) (comment? line)) (loop result)) (else (loop (cons (clean-requirement line) result)))) > Also, how could the above code be expressed using "match"? I'm using > predicates which tests for (special) characters in a string; I don't see > how the more primitive pattern language of "match" will enable me to do > the same. =E2=80=9Cmatch=E2=80=9D has support for predicates, so you could do somethi= ng like this: (match line ((or (eof-object) (? section-header?)) (reverse result)) ((or '() (? comment?)) (loop result)) (_ (loop (cons (clean-requirement line) result)))) This allows you to match =E2=80=9Ceof-object=E2=80=9D and '() directly. Wh= enever I see =E2=80=9Cstring-null?=E2=80=9D I think it might be better to =E2=80=9Cmatch= =E2=80=9D on the empty list directly. But really, that=E2=80=99s up to you. I only feel strongly about avoiding = =E2=80=9C(if =E2=80=A6 (cond =E2=80=A6))=E2=80=9D. -- Ricardo