[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#36772: feature request: checked variant of "substitute*"
From: |
Robert Vollmert |
Subject: |
bug#36772: feature request: checked variant of "substitute*" |
Date: |
Tue, 23 Jul 2019 15:41:58 +0200 |
> On 23. Jul 2019, at 15:35, Ricardo Wurmus <address@hidden> wrote:
>
>
> Hi Robert,
>
>> I think it would be great to have the following variant of substitute*:
>>
>> (substitute*-once filename (pattern vars) body)
>>
>> which acts like the usual substitute-*, except it also asserts that the
>> substitution applies to exactly one line in the file, causing a build
>> failure otherwise.
>
> I agree that the effect of substitute* should be checked. I think
> substitute* should fail when one of its clauses failed to match
> anything.
>
> Each clause could also accept an optional argument to make them only
> match one location. We wouldn’t have to duplicate the macro for that
> and it’s a simple extension to failing on zero matches.
>
> What do you think?
That sounds like a good improvement, too. I think the important part is
ensuring the substitution matches at all, maybe we could leave out the
“at most once” part. (I doubt it would be used a lot if it’s not the default.)
Cheers
Robert