OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

# xri message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Pseudocode compacting

• From: "Tan, William" <William.Tan@neustar.biz>
• To: XRI TC <xri@lists.oasis-open.org>
• Date: Thu, 01 Nov 2007 18:50:05 -0400

```This was just an exercise I did to compact the pseudocode in XRI
Resolution 2.0 WD11-ED06, section 12.6.
By assuming the semantics of looping constructs in "modern procedural
languages", I was able to save 13 lines.

The new pseudocode is attached, and I'm listing the diff here:

--- sel.old     2007-10-22 22:15:15.000000000 +0000
+++ sel.new     2007-10-22 22:34:30.000000000 +0000
@@ -9,19 +9,11 @@
NEXT SEP
ELSE
SET Positive.x=TRUE
-                               NEXT SEL
ENDIF
ELSEIF match on this SEL is DEFAULT     ;see 10.3.2 & 12.3.4
-                       IF Positive.x=TRUE                      ;see 12.3.5
-                               NEXT SEL
-                       ELSEIF nodefault="x"            ;see 10.3.2
-                               NEXT SEL
-                       ELSE
+                       IF Positive.x != TRUE AND nodefault != x
;see 12.3.5
SET Default.x=TRUE
-                               NEXT SEL
ENDIF
-               ELSEIF match on this SEL is NEGATIVE    ;see 12.3.1
-                       NEXT SEL
ENDIF
ENDFOR
IF Matched.x=FALSE                                      ;see 12.3.3
@@ -42,10 +34,7 @@
ADD SEP TO DEFAULT SET                  ;see 12.4.4
ENDIF
ENDFOR
-IF SELECTED SET != EMPTY                               ;see 12.5.1
-       RETURN SELECTED SET
-ENDIF
-IF DEFAULT SET != EMPTY                                ;see 12.5.2
+IF SELECTED SET = EMPTY                                ;see 12.5.1
FOR EACH SEP IN DEFAULT SET
IF (Positive.Type=TRUE AND Positive.Path=TRUE) OR
(Positive.Type=TRUE AND Positive.MediaType=TRUE) OR
@@ -53,20 +42,18 @@
ENDIF
ENDFOR
-       IF SELECTED SET != EMPTY
-               RETURN SELECTED SET
-       ENDIF
-       FOR EACH SEP IN DEFAULT SET
-               IF Positive.Type=TRUE OR
-               Positive.Path=TRUE OR
-               Positive.MediaType=TRUE
-                       ADD SEP TO SELECTED SET
-               ENDIF
-       ENDFOR
-       IF SELECTED SET != EMPTY
-               RETURN SELECTED SET
-       ELSE
-               RETURN DEFAULT SET
+       IF SELECTED SET = EMPTY
+               FOR EACH SEP IN DEFAULT SET
+                       IF Positive.Type=TRUE OR
+                       Positive.Path=TRUE OR
+                       Positive.MediaType=TRUE
+                               ADD SEP TO SELECTED SET
+                       ENDIF
+               ENDFOR
ENDIF
ENDIF
-RETURN EMPTY SET
+IF SELECTED SET != EMPTY
+       RETURN SELECTED SET
+ELSE
+       RETURN DEFAULT SET
+ENDIF

=wil
```
```FOR EACH SEP
CREATE set of SEL match flags
SET all flags to FALSE
FOR EACH SEL of category x (where x=Type, Path, or Mediatype)
SET Matched.x=TRUE
IF match on this SEL is POSITIVE
IF select="true"			;see 12.4.2
NEXT SEP
ELSE
SET Positive.x=TRUE
ENDIF
ELSEIF match on this SEL is DEFAULT	;see 10.3.2 & 12.3.4
IF Positive.x != TRUE AND nodefault != x	;see 12.3.5
SET Default.x=TRUE
ENDIF
ENDIF
ENDFOR
IF Matched.x=FALSE					;see 12.3.3
IF nodefault_x != TRUE			;see 10.3.2
SET Default.x=TRUE
ENDIF
ENDIF
IF Positive.Type=TRUE AND
Positive.Path=TRUE AND
Positive.Mediatype=TRUE				;see 12.4.3
NEXT SEP
ELSEIF SELECTED SET != EMPTY			;see 12.5.1
NEXT SEP
ELSEIF (Positive.Type=TRUE OR Default.Type=TRUE) AND
(Positive.Path=TRUE OR Default.Path=TRUE) AND
(Positive.MediaType=TRUE OR Default.MediaType=TRUE)
ADD SEP TO DEFAULT SET			;see 12.4.4
ENDIF
ENDFOR
IF SELECTED SET = EMPTY				;see 12.5.1
FOR EACH SEP IN DEFAULT SET
IF (Positive.Type=TRUE AND Positive.Path=TRUE) OR
(Positive.Type=TRUE AND Positive.MediaType=TRUE) OR
(Positive.Path=TRUE AND Positive.MediaType=TRUE)
ENDIF
ENDFOR
IF SELECTED SET = EMPTY
FOR EACH SEP IN DEFAULT SET
IF Positive.Type=TRUE OR
Positive.Path=TRUE OR
Positive.MediaType=TRUE