Subject: Re: bug#49944: parse-partial-sexp fails to signal an error when (> START LIMIT).

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 11 Aug 2021 13:04:43 +0200

Eli Zaretskii <[email-masked]> writes:

>> So I don't understand what it is you're proposing: if we document 
>> that OLDSTATE should be the state at FROM, then we need to change the
>> code so that it never swaps FROM and TO.  And if we don't want to change
>> the code, then we should document that OLDSTATE will be used as the
>> state at TO when TO is smaller than FROM.
>
> The latter.  By documenting the expectations of the function, we leave
> it to the callers to make sure their code works as intended.

I think that sounds like a very complicated interface -- it would be
better if we didn't swap.

However, there may well be code out there today that calls the function
with OLDSTATE matching the point passed in by END, which is then swapped
with START (because it's smaller), and things work by accident.

Probably unlikely, but to detect this we'd have to signal an error, like
Alan suggested originally.  So...  perhaps we should just do that?
I.e., signal an error if END is smaller than START?  (And we could fix
up the swapping for clarity, but it wouldn't be necessary.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no