GNU bug report logs -
#42146
[PATCH core-updates 1/?] build: substitute: Don't fail silently.
Previous Next
Full log
Message #47 received at 42146 <at> debbugs.gnu.org (full text, mbox):
Hi Ludo,
Ludovic Courtès <ludo <at> gnu.org> writes:
> Hi,
>
> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:
>
>> * etc/teams.scm.in (<regexp*>, make-regexp*, regexp*-exec): Move to...
>> * guix/build/utils.scm: ... here.
>> (list-matches*): New procedure.
>
>
> [...]
>
>> +++ b/guix/build/utils.scm
>
> [...]
>
>> +;;;
>> +;;; Extend regexp objects with a pattern field.
>> +;;;
>> +(define-record-type <regexp*>
>> + (%make-regexp* pat flag rx)
>> + regexp*?
>> + (pat regexp*-pattern) ;the regexp pattern, a string
>> + (flag regexp*-flag) ;regexp flags
>> + (rx regexp*-rx)) ;the compiled regexp object
>> +
>> +;;; Work around regexp implementation.
>> +;;; This record allows to track the regexp pattern and then display it.
>> +(define* (make-regexp* pat #:optional (flag regexp/extended))
>
> I’m skeptical about the concrete benefits. I would not include it in
> (guix build utils), or at least not in this patch series.
>
> (I tend to be super conservative about (guix build utils) because we
> rarely get a chance to change it.)
The original users are substitute* and the teams.scm script. Since
substitute* is from (guix build utils), it makes sense to add it there
as well, since they are coupled.
The benefit is concrete: it makes it possible to show which regexp
pattern failed to match (its textual representation), instead of
something much less useful such as a generic placeholder such as
"<unknown> (regexp)".
It's in actual use if you look at the definition of substitute:
--8<---------------cut here---------------start------------->8---
(let ((rx+proc (map (match-lambda
(((or (? regexp? pattern) (? regexp*? pattern)) . proc)
(cons pattern proc))
((pattern . proc)
(cons (make-regexp* pattern regexp/extended) proc)))
pattern+procs)))
--8<---------------cut here---------------end--------------->8---
The previous version followed a different approach, annotating the
rx+proc list with the raw pattern; I think the approach here is a bit
cleaner, and it should also enable users to pass pre-computed regexp*
objects to substitute* and have useful error messages produced.
--
Thanks,
Maxim
This bug report was last modified 1 year and 234 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.