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: Tue, 11 Jun 2019 13:56:46 +0200 Message-ID: <87v9xc9vy9.fsf@mdc-berlin.de> References: <87pnod7ot4.fsf@gmail.com> <874l4x550r.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]:57708) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hafOh-0006VK-Ew for bug-guix@gnu.org; Tue, 11 Jun 2019 07:57:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hafOg-0005hX-CD for bug-guix@gnu.org; Tue, 11 Jun 2019 07:57:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44570) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hafOf-0005h2-Qf for bug-guix@gnu.org; Tue, 11 Jun 2019 07:57:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hafOf-0008VN-Lj for bug-guix@gnu.org; Tue, 11 Jun 2019 07:57:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <874l4x550r.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 Hi Maxim, >>> + (call-with-input-file metadata >>> + (lambda (port) >>> + (let loop ((requirements '())) >>> + (let ((line (read-line port))) >>> + ;; Stop at the first 'Provides-Extra' section: the non-optio= nal >>> + ;; requirements appear before the optional ones. >>> + (if (eof-object? line) >>> + (reverse (delete-duplicates requirements)) >>> + (cond >>> + ((and (requires-dist-header? line) (not (extra? line))) >>> + (loop (cons (specification->requirement-name >>> + (requires-dist-value line)) >>> + requirements))) >>> + (else >>> + (loop requirements))))))))) >>> + >> >> As before you can simplify the nested let and merge =E2=80=9Cif=E2=80=9D= and "cond=E2=80=9C. > > Oh, I get it now, I think: > > --8<---------------cut here---------------start------------->8--- > > (call-with-input-file metadata > (lambda (port) > (let loop ((requirements '())) > - (let ((line (read-line port))) > - ;; Stop at the first 'Provides-Extra' section: the non-optional > - ;; requirements appear before the optional ones. > - (if (eof-object? line) > - (reverse (delete-duplicates requirements)) > - (cond > - ((and (requires-dist-header? line) (not (extra? line))) > - (loop (cons (specification->requirement-name > - (requires-dist-value line)) > - requirements))) > - (else > - (loop requirements))))))))) > + (match (read-line port) > + (line > + ;; Stop at the first 'Provides-Extra' section: the non-option= al > + ;; requirements appear before the optional ones. > + (cond > + ((eof-object? line) > + (reverse (delete-duplicates requirements))) > + ((and (requires-dist-header? line) (not (extra? line))) > + (loop (cons (specification->requirement-name > + (requires-dist-value line)) > + requirements))) > + (else > + (loop requirements))))))))) > > (define (guess-requirements source-url wheel-url archive) > "Given SOURCE-URL, WHEEL-URL and a ARCHIVE of the package, return a li= st > --8<---------------cut here---------------end--------------->8--- Not quite. Your =E2=80=98match=E2=80=99 expression here doesn=E2=80=99t do= anything that a =E2=80=98let=E2=80=99 wouldn=E2=80=99t have done. It really just binds the= return value of (read-line port) to =E2=80=98line=E2=80=99; that=E2=80=99s the same as (let= ((line (read-line port))) =E2=80=A6). I gave a match example using predicate matchers in a previous reply. In any case, using =E2=80=98cond=E2=80=99 inside of a let would be just fine. = If you wanted to go with =E2=80=98match=E2=80=99, though, you=E2=80=99d replace th= e =E2=80=98cond=E2=80=99. -- Ricardo