Subject: i;ascii-numeric comparator issue

From: Sorin Suciu <[email-masked]>
Date: Tue, 05 Apr 2005 18:13:35 +0300

I am trying to implement the i;ascii-numeric comparator and 
according to rfc 2244 : "All values which do not begin with a US-ASCII 
digit are considered equal with an ordinal value higher than all non-NIL 
single-valued"
   I understand for this that if I have a value that begins with other 
that a digit, i give it the highest value in my interval (for ex. 2^32 
given an interval of 0 - 2^32-1). But what happens if I compare 2 values 
starting with a non-digit character? Are they  equal? What if I have  a 
""  string (a  NULL  value)?
  If i make the assumtion that all values starting with a non-digit or 
NULL value are equal to 2^32, then the following code will behave wrong

if address :is :all :i;ascii-numeric "To" "aa" {
    discard;
}
if address :is :all :i;ascii-numeric "From" "" {
    discard;
}
both tests will evaluate to true which, for the seccond case, explicitly 
contradicts the base RFC (3028)

any ideas?

---

From: [email-masked]
Date: Tue, 05 Apr 2005 08:43:56 -0700 (PDT)

> digit are considered equal with an ordinal value higher than all non-NIL

Seems pretty clear to me.

> given an interval of 0 - 2^32-1).

That's an implementation detail.

> But what happens if I compare 2 values
> starting with a non-digit character? Are they  equal?

Of course they are. I fail to see what part of "all values which do not begin
with a US-ASCII digit are considered equal" is in any way unclear.

> What if I have  a ""  string (a  NULL  value)?

It is also equal. Numeric comparisons only make sense for numbers.

> NULL value are equal to 2^32, then the following code will behave wrong

I see nothing "wrong" about it.

> if address :is :all :i;ascii-numeric "To" "aa" {

I assume you meant "if address :is :all :comparator "i;ascii-numeric" ...",
but in any case, this test will return true if the address doesn't
begin with a digit and false if it does.

> if address :is :all :i;ascii-numeric "From" "" {

Same thing.

> both tests will evaluate to true

Incorrect. There are cases where they will return "false".

> which, for the seccond case, explicitly

I see no contradiction here, but if there is it is it is the base specification
that needs to be changed. Comparators in general can completely change the
result that's returned. That's what they are for. But as long as they behave
consistently and meet the (minimal) constraints imposed on comparator behavior
there is no problem.

				Ned

---

From: Kjetil Torgrim Homme <[email-masked]>
Date: Tue, 05 Apr 2005 23:43:52 +0200

On Tue, 2005-04-05 at 08:43 -0700, [email-masked] wrote:
> [...]
> I fail to see what part of "all values which do not begin

I think he understood it as "... are considered equal _to_ an ordinal
value ...".  I found the wording a little unclear, although I wasn't in
doubt about the intended meaning.  a comma after "equal" might have made
the text a little clearer.
-- 
Kjetil T. (not a native speaker)