Subject: [Ltru] ohterwises in procedure

From: "Randy Presuhn" <[email-masked]>
Date: Tue, 4 Apr 2006 14:33:23 -0700

Hi -

I found it difficult to figure out the nesting of the ifs and otherwises in
this proposed text in http://www.inter-locale.com/ID/matching-diff-11-12.html:

   3.  While there are more subtags left in the language range's list:  
           A.  If the subtag currently being examined in the range is the  
               wildcard ('*'), move to the next subtag in the range until a  
               non-wildcard subtag is found.  

           B.  Otherwise, if there are no more subtags in the language tag's  
               list, the match fails.  
                                                                               
           C.  Otherwise, compare the current subtag in the range's list  
               with the current subtag in the language tag's list.  If they  
               match, move to the next subtag in both lists and continue  
               with the loop.  
      
           D.  Otherwise, if the language tag's subtag is a "singleton" (a  
               single letter or digit, which includes the private-use subtag  
               'x') the match fails.  
      
           E.  Otherwise, move to the next subtag in the language tag's list  
               and continue with the loop. 

In addition, the "until" construct embedded in A seems to duplicate the
result of the "while" in 3 with the "if" in A.  After completion of the
"until" loop in A, at what step does processing resume?  Since C and
E explicity mention continuing with the loop, does it exit the loop
or continue with step B?  In short, I'm not able to figure out how to
get this algorithm description to produce the results in the list of
examples that follows it.

Other than the special handling of singletons, I *think* the intended
algorithm should behave something like this:

do forever
{
   while language range subtag is not wildcard
   {
       if language range subtag equals language tag subtag
       {
           next language range subtag
           next language tag subtag
       }
       else
       {
           return no match
       }
   }

   if language range exhausted
   {
       return match;                         all ranges act as though trailing wildcards
   }

   while language range subtag is wildcard
   {
       next language range subtag;          treat multiple wildcards like a single one
   }

   if language range exhausted
   {
       return match;                        nothing but trailing wildcards
   }

   ; at this point we've encountered something other than a wildcard after a wildcard
   ; we need to advance through the language tag being examined to find the next
   ; subtag that matches
   while (language range subtag not equal language tag subtag)
   {
       next language tag subtag
   }

   if language tag exhausted
   {
       return no match;                    we found nothing to match the post-wildcard part
   }
}

BUT, this pseudo-code was reverse-engineered from the examples, not the algorithm
description in section 3.2.2.  The "Otherwise" in step C seems to be where the
descriptions diverge.

Randy

_______________________________________________
Ltru mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/ltru

---

From: John Cowan <[email-masked]>
Date: Tue, 4 Apr 2006 17:56:11 -0400

> this proposed text in http://www.inter-locale.com/ID/matching-diff-11-12.html:

The intention is a single if-then-elseif-then-elseif-then chain.  "Otherwise"
is a synonym for "else" that works better in English prose; see the Perl code
in http://www1.ietf.org/mail-archive/web/ltru/current/msg04792.html for my
original intentions.

>                non-wildcard subtag is found.  

Addison seems to have modified this line's behavior.  The words "until a
non-wildcard subtag is found" are not necessary, as repeated steps through
the main loop will remove multiple wildcards.  I suggest these words be
replaced with "and continue with the loop", as my original version had it.

(My bad, for not checking that Addison's algorithm, which is phrased in
terms of "moving to" subtags, was still equivalent to mine, which was
phrased in terms of "removing" subtags.)

> do forever

I think this algorithm is flawed, but I'm not up to analyzing it just now.
The Perl code is very close to my original pseudocode as well as to Addison's
as amended, and it runs the test cases correctly.

-- 
John Cowan  [email-masked]  www.ap.org  www.ccil.org/~cowan
The present impossibility of giving a scientific explanation is no proof
that there is no scientific explanation. The unexplained is not to be
identified with the unexplainable, and the strange and extraordinary
nature of a fact is not a justification for attributing it to powers
above nature.  --The Catholic Encyclopedia, s.v. "telepathy" (1913)

---

From: "Addison Phillips" <[email-masked]>
Date: Tue, 4 Apr 2006 14:45:07 -0700

If you replace the word "otherwise" with "else" and remove the phrase "until a non-wildcard subtag is found", then the result works correctly. The pseudo-code is:

while (range-subtag.remaining() > 0) {
    if (range-subtag == "*") {
       next range-subtag;
    } else if (no-more-tag-subtags) {
       return no-match;
    } else if (range-subtag == tag-subtag) {
       // NB> singletons in both match here
       next range-subtag;
       next tag-subtag;
    } else if (tag-subtag.length() == 1) {
       return no-match;
    } else {
       // only increment the tag if none of the above true
       next tag-subtag;
    }
} // loop around until out of range subtags
return match;

Addison Phillips
Internationalization Architect - Yahoo! Inc.

Internationalization is an architecture.
It is not a feature. 

> -----Original Message-----
> From: Randy Presuhn [mailto:[email-masked]]
> Sent: 2006年4月4日 14:33
> To: LTRU Working Group
> Subject: [Ltru] ohterwises in procedure
> 
> Hi -
>

---

From: "Addison Phillips" <[email-masked]>
Date: Tue, 4 Apr 2006 15:06:16 -0700

> replaced with "and continue with the loop", as my original version had it.

You're right. My text is misleading.
> phrased in terms of "removing" subtags.)

I elected to use "moving to" to avoid giving the impression that one might
modify the tag or subtags in some way.

Addison Phillips

---

From: John Cowan <[email-masked]>
Date: Tue, 4 Apr 2006 18:11:15 -0400

> modify the tag or subtags in some way.

I understood that and agree with your reasoning.

-- 
Henry S. Thompson said, / "Syntactic, structural,               John Cowan
Value constraints we / Express on the fly."     [email-masked]
Simon St. Laurent: "Your / Incomprehensible     http://www.ap.org
Abracadabralike / schemas must die!"            http://www.ccil.org/~cowan