raf:
> On Thu, Feb 10, 2022 at 11:21:07PM -0500, Viktor Dukhovni 
> <postfix-us...@dukhovni.org> wrote:
> 
> > > On 10 Feb 2022, at 11:17 pm, raf <post...@raf.org> wrote:
> > > 
> > > But I still don't see why it was only the second
> > > replacement index that was out of range, and not the
> > > first as well.
> > 
> > https://sciencing.com/what-is-a-counterexample-in-algebra-12750822.html
> > ...
> > One Counterexample Is Sufficient
> > 
> > -- 
> >     Viktor.
> 
> Sorry, I shouldn't have said "as well".
> Maybe I should have said "instead".
> 
> I meant that I assume that the subject of an error
> message would be the first instance of an error. I'd
> expect a single error message, just not the one that
> was reported. I was assuming that things are processed
> left to right (patterns, input, FSAs etc.), and so I

There are two parsers: one for the LHS and one for the RHS. Each
parser reports its highest substitution index, and if the highest
index from the RHS parser is larger, then Postfix reports an
out-of-range error for that specific index.

You appear to think that the RHS parser "knows" details about the
LHS, but that is not the case*. Postfix in large part avoids tight
couplings. That makes code easier to reason about, so that even I
can understand how or why it works.

        Wietse

*In fact it the other way around. If the RHS contains no $number.
then Postfix informs the LHS paraer that the regex library does not
need to report the (begin, end) of matches, so it will be a little
smaller and will run a little faster.

Reply via email to