[Lazarus] errors: Upper bound of case range is less than lower bound and duplicate case label

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Jan 22 09:38:32 CET 2013


On Tue, 22 Jan 2013 09:20:28 +0100
Bart <bartjunk64 at gmail.com> wrote:

> On 1/21/13, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
> 
> 
> > The lower-than and greater-than operators are defined for
> > strings. Do you want to remove them too?
> >
> >
> >> Ranges for strings are (countably) infinite, and this is (by design)
> >> not the case in the case of other cases (pun intended).
> 
> No, you are missing the analogy I meant (or I did not make myself clear enough).
> 
> Case was originally meant for Ordinal values.
> With Ordinal values ranges (1..100, 'a'..'z') are never infinite.
> Pascal has never had the concept of ranges (in this sense) that are
> infinite (countable or uncoutable).
> You cannot define ranges for Floats (they would be uncoutable
> infinite), and by that analogy I would suggest you should not be able
> to define ranges for strings, as they are (coutbale) infinite.
> 
> The ability to have an infinite (countable or uncoutable) "range"
> between two values for a given type however, does not mean you should
> not have lesser than, or greater than operators. If this were the case
> we'ld have to remove them for floats as well, and that would be rather
> silly.
> 
> So my analogy was more with floats (but they have uncoutable infinite
> ranges, as opposed to coutable infinity for strings).

To implement a case LowerBound..UpperBound you only need a transitive
compare operator. You don't need fixed size ranges. 
If you have small fixed size range then you can implement the case
via jump tables. But that is only an implementation detail.

IMHO if you think that the string compare operator makes sense, then
strings in case makes sense too. They make exactly the same sense.

Mattias




More information about the Lazarus mailing list