From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] gnu: Allow nfs file systems to be automatically mounted. Date: Tue, 29 Nov 2016 22:51:38 +0100 Message-ID: <87bmwynedx.fsf@gnu.org> References: <8760nc6et6.fsf@gnu.org> <1480152990-7080-1-git-send-email-jmd@gnu.org> <87fumenl44.fsf@gnu.org> <20161126193358.GA10000@jocasta.intra> <87polfbt8y.fsf@gnu.org> <20161128140754.GA7013@jocasta.intra> <87lgw3l3hw.fsf@gnu.org> <20161129062747.GA24796@jocasta.intra> 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]:56794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBqJV-00034Y-Ea for guix-devel@gnu.org; Tue, 29 Nov 2016 16:51:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBqJS-0004GN-7v for guix-devel@gnu.org; Tue, 29 Nov 2016 16:51:45 -0500 In-Reply-To: <20161129062747.GA24796@jocasta.intra> (John Darrington's message of "Tue, 29 Nov 2016 07:27:48 +0100") 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: John Darrington Cc: guix-devel@gnu.org, John Darrington John Darrington skribis: > On Mon, Nov 28, 2016 at 10:05:15PM +0100, Ludovic Court??s wrote: > John Darrington skribis: >=20=20=20=20=20=20 > > On Mon, Nov 28, 2016 at 02:59:09PM +0100, Ludovic Court??s wrote: > > > ???match???,=20 > > > > > > Have another look: + (let* ((host (match (string-split s= ource #\:) ((h _) h))) > >=20=20=20=20=20=20 > > Right, but there are other occurrences of ???car??? for ???ge= taddrinfo???. :-) > > > > But that occurance applies to a real list, rather than a list used= as record. > > In other words, I really do just want to get the first item of tha= t list. > > As I understand it, match is supposed to be used for heterogenous = lists where > > each member has its own semantics. That is not the case here. >=20=20=20=20=20=20 > ???match??? can be used to match anything, and I highly recommend us= ing it > for lists (info "(guile) Pairs"): it generates clearer and foolproof > code. >=20=20=20=20=20=20 > In this case ???getaddrinfo??? might well return an empty list. >=20=20=20=20=20=20 > So then "car" would raise an error (unless I check it first with pair?) -= just > as match would raise an error unless I add a catch-all case. I'm still n= ot=20 > convinced that match has any advantages in this case. > > However I've changed it despite that, and pushed this patch to master. I= hope > it's ok. No big deal, but it=E2=80=99s not what I meant. An expression like: (let ((x (match lst1 ((a . b) a))) (y (match lst2 ((a . b) a)))) =E2=80=A6) is almost equivalent to using =E2=80=98car=E2=80=99 twice, only more verbos= e. That is, the cases where =E2=80=98lst1=E2=80=99 or =E2=80=98lst2=E2=80=99 is empty a= re not handled (=E2=80=98match=E2=80=99 raises an exception.) The real gain is when each case is explicitly separated and handled: (match lst1 ((x . _) (match lst2 ((y . _) (do-something x y)) (_ (error "lst2 is empty")))) (_ (error "lst1 is bogus"))) In this case we=E2=80=99d want to gracefully handle syntax errors in =E2=80= =98source=E2=80=99 and host name lookup failures for instance. Ludo=E2=80=99.