Subject: Re: [PATCH v8 00/41] guix: node-build-system: Support compiling add-ons with node-gyp.

From: Liliana Marie Prikler <[email-masked]>
Date: Sat, 08 Jan 2022 00:06:17 +0100

Hi,

Am Freitag, dem 07.01.2022 um 16:07 -0500 schrieb Philip McGrath:
> My base position is that regexps should not be mandatory or default.
> It was very convenient to be able to just copy--paste package names
> from "package.json" into '#:absent-dependencies' (or whatever). I can
> imagine it being useful for tooling, too, to be able to find just
> from the package definition the dependencies which are being deleted,
> rather than  having to either download the origins or try to
> reconstruct names from regexps.
I don't think tooling should be too big of an issue, since you could
teach your tool to support regexp.  I.e. instead of checking whether a
newly added package has the name, you check whether it fits the
pattern.  That might generate false positive in some cases, perhaps
even many, but we can (and should) refine regexps that are too generic.

> Alternatively, I would also be ok with [...] a slight variant on it
> in which the user would write:
> 
>      `("foo" "bar" ,(make-regexp "baz"))
> 
> Since this (either variant) would not change the interpretation of 
> strings in the list of dependencies to delete, it could also be added
> later without breaking compatibility.
That's true, but the main reason to add it from my perspective is that
we don't need to change how regexps are interpreted from the rest of
Guix to make basic strings match fully.  For the fun of it, we could
also extend this to procedures of a single value so that one can
finally supply (const #t) :D

> I also think full string matches are better, regardless of any of the
> above. Here's an implementation that avoids unneeded copies and
> string comparison:
> 
>      (define (regexp-match-exact? rx str)
>        (define m (regexp-exec rx str))
>        (and m
>             (= (match:start m) 0)
>             (= (match:end m) (string-length str))))
I can't say this is more beautiful than 
(equal? (and=> (regexp-exec rx str) match:substring) str), but there's
only that many ways of making a partial match a full one and Guile core
has none of them...