guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] gnu: Allow nfs file systems to be automatically mounted.


From: Ludovic Courtès
Subject: Re: [PATCH] gnu: Allow nfs file systems to be automatically mounted.
Date: Tue, 29 Nov 2016 22:51:38 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

John Darrington <address@hidden> skribis:

> On Mon, Nov 28, 2016 at 10:05:15PM +0100, Ludovic Court??s wrote:
>      John Darrington <address@hidden> skribis:
>      
>      > On Mon, Nov 28, 2016 at 02:59:09PM +0100, Ludovic Court??s wrote:
>      >      >      ???match???, 
>      >      >
>      >      > Have another look: +    (let* ((host (match (string-split 
> source #\:) ((h _) h)))
>      >      
>      >      Right, but there are other occurrences of ???car??? for 
> ???getaddrinfo???.  :-)
>      >
>      > 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 that 
> 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.
>      
>      ???match??? can be used to match anything, and I highly recommend using 
> it
>      for lists (info "(guile) Pairs"): it generates clearer and foolproof
>      code.
>      
>      In this case ???getaddrinfo??? might well return an empty list.
>      
> 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 not 
> 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’s not what I meant.

An expression like:

  (let ((x (match lst1 ((a . b) a)))
        (y (match lst2 ((a . b) a))))
    …)

is almost equivalent to using ‘car’ twice, only more verbose.  That is,
the cases where ‘lst1’ or ‘lst2’ is empty are not handled (‘match’
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’d want to gracefully handle syntax errors in ‘source’
and host name lookup failures for instance.

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]