[e-cvs] cvs commit: e/src/jsrc/org/erights/e/elib/ref Ref.java WhenBrokenReactor.java WhenResolvedReactor.java

markm@eros.cs.jhu.edu markm@eros.cs.jhu.edu
Mon, 27 Aug 2001 18:19:47 -0400


markm       01/08/27 18:19:47

  Modified:    src/bin/resources/org/erights/e/elang/syntax
                        ParserTables.data
               src/esrc/scripts fixdoc.e
               src/jsrc/org/erights/e/elang/syntax EBuilder.java
                        EParser.java e.y
               src/jsrc/org/erights/e/elib/ref Ref.java
                        WhenBrokenReactor.java WhenResolvedReactor.java
  Log:
  better when-catch-finally, thanks to Mark Seaborn (and previously, Alan Karp)

Revision  Changes    Path
1.15      +12 -16    e/src/bin/resources/org/erights/e/elang/syntax/ParserTables.data

Index: ParserTables.data
===================================================================
RCS file: /cvs/e/src/bin/resources/org/erights/e/elang/syntax/ParserTables.data,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
Binary files /tmp/cvs2XNN3x and /tmp/cvs25bZyV differ



1.7       +4 -1      e/src/esrc/scripts/fixdoc.e

Index: fixdoc.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/fixdoc.e,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- fixdoc.e	2001/08/14 01:43:01	1.6
+++ fixdoc.e	2001/08/27 22:19:46	1.7
@@ -38,4 +38,7 @@
     }
 }
 
-fix(<file:javadoc>, -1)
+for path in interp getArgs() {
+    fix(<file: path>, -1)
+}
+



1.73      +19 -7     e/src/jsrc/org/erights/e/elang/syntax/EBuilder.java

Index: EBuilder.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/syntax/EBuilder.java,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- EBuilder.java	2001/08/23 08:57:06	1.72
+++ EBuilder.java	2001/08/27 22:19:46	1.73
@@ -1437,7 +1437,7 @@
     /**
      * Then when statement base-case expands as follows:
      * <pre>
-     * when (eExpr) -> auds(patt1) {
+     * when (eExpr) -> auds(patt1) :resultGuard {
      *     body1
      * } catch ... {
      *     ...
@@ -1445,7 +1445,7 @@
      * </pre>
      * expands to
      * <pre>
-     * Ref whenResolved(eExpr, def auds(resolution) :void {
+     * Ref whenResolved(eExpr, def auds(resolution) :resultGuard {
      *     try {
      *         if (Ref isBroken(resolution)) {
      *             throw(Ref optProblem(resolution))
@@ -1461,6 +1461,7 @@
     private EExpr whenBase(EExpr eExpr,
                            Object[] auds,
                            Pattern patt1,
+                           EExpr resultGuard,
                            EExpr body1,
                            Object catchers,
                            Object optFinally)
@@ -1483,14 +1484,16 @@
                     "whenResolved",
                     list(eExpr,
                          methObject(auds,
-                                    methHead("run", list(resPatt), VOID),
+                                    methHead("run",
+                                             list(resPatt),
+                                             resultGuard),
                                     body1)));
     }
 
     /**
      * Then normal when statement syntax expands as follows:
      * <pre>
-     * when (eExprs,...) -> auds(patts,...) {
+     * when (eExprs,...) -> auds(patts,...) :resultGuard {
      *     body1
      * } catch patt2 {
      *     body2
@@ -1499,7 +1502,8 @@
      * eExprs and patts must have the same arity, which must be >=1.  If it's 
      * exactly 1, the we use the above base case.  Otherwise we expand to
      * <pre>
-     * when (promiseAllFulfilled([eExprs,...]) -> auds([patts,...]) {
+     * when (promiseAllFulfilled([eExprs,...]) -> 
+             auds([patts,...]) :resultGuard {
      *     body1
      * } catch patt2 {
      *     body2
@@ -1511,6 +1515,7 @@
     private EExpr whenList(EExpr[] eExprs,
                            Object[] auds,
                            Pattern[] patts,
+                           EExpr resultGuard,
                            EExpr body1,
                            Object catchers,
                            Object optFinally)
@@ -1539,6 +1544,7 @@
         return whenBase(eExpr,
                         auds,
                         patt1,
+                        resultGuard,
                         body1,
                         catchers,
                         optFinally);
@@ -1556,20 +1562,26 @@
         EExpr[] eExprs = null;
         Object[] auds = null;
         Pattern[] patts = null;
+        EExpr resultGuard = null;
 
         EList heads = (EList)headList;
-        if (heads.size() == 3) {
+        if (heads.size() == 4) {
             //the normal syntax
             eExprs =  (EExpr[])typedArray(heads.get(0), EExpr.class);
             auds =              (Object[])heads.get(1);
             patts = (Pattern[])typedArray(heads.get(2), Pattern.class);
-        } else if (heads.size() == 2) {
+            resultGuard =          (EExpr)heads.get(3);
+            
+        } else if (heads.size() == 3) {
             reserved("alternate when syntax");
+        } else {
+            throw new RuntimeException("internal: unrecognized when arity");
         }
         
         return whenList(eExprs,
                         auds,
                         patts,
+                        resultGuard,
                         (EExpr)bodyExpr,
                         catchers,
                         optFinally);



1.81      +390 -382  e/src/jsrc/org/erights/e/elang/syntax/EParser.java

Index: EParser.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/syntax/EParser.java,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- EParser.java	2001/08/23 08:57:06	1.80
+++ EParser.java	2001/08/27 22:19:46	1.81
@@ -341,23 +341,23 @@
    70,   70,   70,   18,   18,   78,   78,   78,   78,   78,
    78,   78,   15,   15,   79,   79,   46,   46,   81,   81,
    82,   82,   82,   82,   82,   83,   83,   83,   48,   48,
-   48,   49,   85,   86,   84,   84,   53,   53,   87,   87,
-   88,    1,    1,    9,    9,   65,   37,   37,   80,   80,
-   43,   43,   89,   89,   38,   13,   13,   17,   17,   17,
-   17,   17,   17,   17,   17,   17,   17,   17,   17,   44,
-   44,   50,   47,   47,   47,   91,   92,   94,   94,   95,
-   95,   93,   93,   51,   51,   54,   96,   52,   52,   57,
-   57,   97,   97,   97,   97,   99,   99,   99,   99,   98,
-   98,   98,  101,  101,  102,  102,  103,  103,  100,  100,
-   90,   90,   90,   90,   90,   90,   90,   90,   90,   90,
-   90,   90,   90,   90,   90,   90,   90,   90,   90,   90,
-   90,   90,   90,   90,   90,   90,   90,   90,   90,   90,
-   90,   90,   90,   90,   90,   90,   90,   90,   90,   90,
-   90,   90,   90,   90,   90,   90,   90,   90,   90,   90,
-   90,   90,   90,   90,   90,   90,   90,   90,   90,   90,
-   90,   90,   90,   90,   90,   90,   90,   90,   90,   90,
-   90,   90,   90,   90,   90,   90,   90,   90,   90,   90,
-   90,   90,   90,   90,   90,
+   48,   49,   85,   86,   84,   84,   87,   53,   53,   88,
+   88,   89,    1,    1,    9,    9,   65,   37,   37,   80,
+   80,   43,   43,   90,   90,   38,   13,   13,   17,   17,
+   17,   17,   17,   17,   17,   17,   17,   17,   17,   17,
+   44,   44,   50,   47,   47,   47,   92,   93,   95,   95,
+   96,   96,   94,   94,   51,   51,   54,   97,   52,   52,
+   57,   57,   98,   98,   98,   98,  100,  100,  100,  100,
+   99,   99,   99,  102,  102,  103,  103,  104,  104,  101,
+  101,   91,   91,   91,   91,   91,   91,   91,   91,   91,
+   91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
+   91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
+   91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
+   91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
+   91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
+   91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
+   91,   91,   91,   91,   91,   91,   91,   91,   91,   91,
+   91,   91,   91,   91,   91,   91,
 };
 final static short yylen[] = {                            2,
     1,    1,    2,    1,    1,    3,    3,    1,    3,    1,
@@ -382,15 +382,15 @@
     4,    5,    2,    5,    2,    1,    1,    2,    4,    4,
     1,    2,    2,    5,    1,    1,    1,    4,    1,    4,
     3,    4,    3,    4,    3,    4,    5,    2,    4,    5,
-    2,    5,    3,    2,    0,    3,    9,    4,    1,    3,
-    4,    0,    1,    1,    2,    0,    1,    1,    1,    3,
-    1,    3,    3,    2,    1,    1,    1,    1,    1,    1,
-    1,    1,    1,    1,    1,    1,    1,    1,    1,    5,
-    7,    6,    7,    1,    1,    0,    0,    1,    3,    1,
-    3,    1,    3,    1,    1,    2,    3,    0,    2,    7,
-    3,    1,    2,    2,    4,    2,    4,    2,    4,    2,
-    5,    4,    2,    3,    1,    4,    2,    2,    0,    3,
+    2,    5,    3,    2,    0,    3,    3,    8,    5,    1,
+    3,    4,    0,    1,    1,    2,    0,    1,    1,    1,
+    3,    1,    3,    3,    2,    1,    1,    1,    1,    1,
     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+    5,    7,    6,    7,    1,    1,    0,    0,    1,    3,
+    1,    3,    1,    3,    1,    1,    2,    3,    0,    2,
+    7,    3,    1,    2,    2,    4,    2,    4,    2,    4,
+    2,    5,    4,    2,    3,    1,    4,    2,    2,    0,
+    3,    1,    1,    1,    1,    1,    1,    1,    1,    1,
     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -398,100 +398,101 @@
     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    1,
 };
 final static short yydefred[] = {                         0,
-  234,    0,    0,    0,    2,    0,  246,    0,    0,    0,
-  301,  302,  303,  304,  305,  306,  307,  308,  309,  310,
-  311,  312,  313,  314,  315,  316,  317,  318,  319,  320,
-  321,  322,  323,  324,  325,  326,  327,  328,  329,  330,
-  331,  332,  333,  334,  335,  336,  337,  338,  339,  340,
-  341,  342,  343,  344,  345,  346,  347,  348,  349,  350,
-  351,  352,  353,  354,  355,  356,  357,  358,  359,  360,
-  361,  362,  363,  364,  365,  366,  367,  368,  369,  370,
-  371,  372,  373,  374,  375,  376,  377,  378,  379,  380,
-  381,  382,  383,  384,  385,    0,    0,    0,    0,    0,
+  235,    0,    0,    0,    2,    0,  247,    0,    0,    0,
+  302,  303,  304,  305,  306,  307,  308,  309,  310,  311,
+  312,  313,  314,  315,  316,  317,  318,  319,  320,  321,
+  322,  323,  324,  325,  326,  327,  328,  329,  330,  331,
+  332,  333,  334,  335,  336,  337,  338,  339,  340,  341,
+  342,  343,  344,  345,  346,  347,  348,  349,  350,  351,
+  352,  353,  354,  355,  356,  357,  358,  359,  360,  361,
+  362,  363,  364,  365,  366,  367,  368,  369,  370,  371,
+  372,  373,  374,  375,  376,  377,  378,  379,  380,  381,
+  382,  383,  384,  385,  386,    0,    0,    0,    0,    0,
     0,  188,    3,    0,  189,    0,  174,    0,  167,  172,
-  247,   96,   97,   98,   99,  100,  102,    0,    0,    0,
+  248,   96,   97,   98,   99,  100,  102,    0,    0,    0,
     0,    4,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    5,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,  266,    0,    0,    0,    0,    8,   12,    0,   15,
+    0,  267,    0,    0,    0,    0,    8,   12,    0,   15,
     0,    0,    0,    0,   28,    0,    0,    0,    0,    0,
    60,    0,    0,   92,    0,   78,  101,    0,  105,  108,
-  119,  120,  235,    0,    0,    0,    0,    0,    0,    0,
-  236,    0,    0,    0,    0,    0,  158,    0,    0,    0,
+  119,  120,  236,    0,    0,    0,    0,    0,    0,    0,
+  237,    0,    0,    0,    0,    0,  158,    0,    0,    0,
     0,    0,    0,  176,  175,    0,    0,    0,    0,  139,
   138,    0,    0,  205,  206,    0,    0,    0,    0,  197,
   196,    0,    0,    0,  201,    0,    0,    0,  161,    0,
-    0,    0,  245,    0,    0,  114,  236,    0,    0,    0,
-    0,    0,    0,  127,    0,    0,    0,    0,    0,    0,
-    0,    0,  237,    0,  241,    0,  122,  123,    0,    0,
-  125,    0,    0,    0,  129,    0,    0,    0,    0,    0,
-    0,    0,    0,    0,    6,    0,    0,    0,    0,  248,
-  249,  250,  251,  252,    0,  253,  254,  255,  256,  257,
-  258,  259,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,    0,    0,    0,    0,  146,  104,    0,    0,
-    0,    0,    0,  173,  187,    0,  153,    0,    0,    0,
-  154,    0,    0,  157,    0,   10,  145,    0,    0,    0,
-    0,    0,  180,  178,  181,    0,  177,    0,  103,    0,
-    0,    0,  266,    0,  264,  265,  202,  198,    0,    0,
-    0,  115,    0,  109,    0,    0,    0,  239,    0,    0,
-  266,  116,    0,  275,  274,    0,    0,  236,  110,  126,
-    0,  266,    0,    0,   76,   75,   73,   74,  130,  244,
-    0,  106,  107,    0,    0,    0,    0,    0,    0,  155,
-    0,    0,    0,  221,  128,    0,    0,    0,    0,    0,
-  112,    0,    9,    0,   16,    0,    0,    0,    0,    0,
+    0,    0,  246,    0,    0,  114,  237,    0,    0,    0,
+    0,    0,    0,    0,  127,    0,    0,    0,    0,    0,
+    0,    0,    0,  238,    0,  242,    0,  122,  123,    0,
+    0,  125,    0,    0,    0,  129,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    6,    0,    0,    0,    0,
+  249,  250,  251,  252,  253,    0,  254,  255,  256,  257,
+  258,  259,  260,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  146,  104,    0,
+    0,    0,    0,    0,  173,  187,    0,  153,    0,    0,
+    0,  154,    0,    0,  157,    0,   10,  145,    0,    0,
+    0,    0,    0,  180,  178,  181,    0,  177,    0,  103,
+    0,    0,    0,  267,    0,  265,  266,  202,  198,    0,
+    0,    0,  115,    0,  109,    0,    0,    0,  240,    0,
+    0,  267,  116,    0,  276,  275,    0,    0,  237,    0,
+  110,  126,    0,  267,    0,    0,   76,   75,   73,   74,
+  130,  245,    0,  106,  107,    0,    0,    0,    0,    0,
+    0,  155,    0,    0,    0,  221,  128,    0,    0,    0,
+    0,    0,  112,    0,    9,    0,   16,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,  148,    0,  147,    0,  131,  166,    0,    0,
-  163,    0,    0,    0,    0,    0,    7,    0,  190,  191,
-  185,    0,    0,    0,    0,  179,  165,    0,  135,    0,
-  224,    0,    0,  136,    0,    0,    0,    0,    0,    0,
-    0,    0,   86,    0,    0,    0,    0,  117,  276,    0,
-    0,    0,  229,    0,    0,    0,    0,    0,    0,    0,
-  290,  281,  243,    0,  242,  240,  121,    0,    0,  124,
-    0,    0,    0,    0,    0,    0,  113,    0,    0,   21,
-   23,    0,   18,   22,   19,   25,   29,   31,   32,   40,
-   39,   36,   37,   38,   33,   34,   35,   43,   44,   45,
-   42,   46,    0,    0,   54,    0,   51,    0,   59,    0,
-   56,   57,   67,   66,   63,   65,   61,   62,   64,   71,
-   70,   69,    0,    0,   79,    0,    0,    0,   93,  149,
-  192,  194,  162,    0,  156,    0,    0,  159,   11,  152,
-  150,  152,  183,  182,    0,    0,  223,  236,  199,  200,
-    0,  209,    0,  111,  134,  133,    0,    0,   87,  236,
-    0,  279,    0,    0,  228,    0,  118,    0,    0,  293,
-    0,  295,    0,    0,    0,    0,  267,  260,  219,    0,
-  226,    0,    0,   24,  203,    0,    0,    0,    0,   94,
-    0,  169,  171,    0,    0,    0,    0,  268,    0,  222,
-    0,   88,    0,  272,    0,  277,    0,    0,  230,  298,
-  297,    0,  294,  292,    0,    0,    0,  282,  267,    0,
-    0,  300,    0,  220,    0,   81,    0,   84,   95,  151,
-  184,  142,    0,    0,    0,    0,    0,    0,  267,    0,
-   89,    0,    0,    0,  231,    0,  283,  286,  288,    0,
-  284,    0,  291,  261,    0,   80,  141,    0,    0,    0,
-    0,    0,    0,  269,    0,    0,  210,  273,  262,    0,
-  296,  280,    0,    0,    0,  204,    0,  215,    0,    0,
-    0,  218,  211,  213,  271,  263,    0,  285,  287,  289,
-  214,    0,  212,    0,  227,  216,    0,  217,
+    0,    0,    0,    0,  148,    0,  147,    0,  131,  166,
+    0,    0,  163,    0,    0,    0,    0,    0,    7,    0,
+  190,  191,  185,    0,    0,    0,    0,  179,  165,    0,
+  135,    0,  224,    0,    0,  136,    0,    0,    0,    0,
+    0,    0,    0,    0,   86,    0,    0,    0,    0,  117,
+  277,  227,    0,    0,  230,    0,    0,    0,    0,    0,
+    0,    0,    0,  291,  282,  244,    0,  243,  241,  121,
+    0,    0,  124,    0,    0,    0,    0,    0,    0,  113,
+    0,    0,   21,   23,    0,   18,   22,   19,   25,   29,
+   31,   32,   40,   39,   36,   37,   38,   33,   34,   35,
+   43,   44,   45,   42,   46,    0,    0,   54,    0,   51,
+    0,   59,    0,   56,   57,   67,   66,   63,   65,   61,
+   62,   64,   71,   70,   69,    0,    0,   79,    0,    0,
+    0,   93,  149,  192,  194,  162,    0,  156,    0,    0,
+  159,   11,  152,  150,  152,  183,  182,    0,    0,  223,
+  237,  199,  200,    0,  209,    0,  111,  134,  133,    0,
+    0,   87,  237,    0,  280,    0,    0,    0,  118,    0,
+    0,    0,  294,    0,  296,    0,    0,    0,    0,  268,
+  261,  219,    0,  226,    0,    0,   24,  203,    0,    0,
+    0,    0,   94,    0,  169,  171,    0,    0,    0,    0,
+  269,    0,  222,    0,   88,    0,  273,    0,  278,    0,
+  229,  231,    0,  299,  298,    0,  295,  293,    0,    0,
+    0,  283,  268,    0,    0,  301,    0,  220,    0,   81,
+    0,   84,   95,  151,  184,  142,    0,    0,    0,    0,
+    0,    0,  268,    0,   89,    0,    0,  232,    0,    0,
+  284,  287,  289,    0,  285,    0,  292,  262,    0,   80,
+  141,    0,    0,    0,    0,    0,    0,  270,    0,    0,
+  210,  274,  263,    0,  297,  281,    0,    0,    0,  204,
+    0,  215,    0,    0,    0,  218,  211,  213,  272,  264,
+  228,  286,  288,  290,  214,    0,  212,    0,  216,    0,
+  217,
 };
 final static short yydgoto[] = {                          3,
-  188,    5,  400,  198,  146,  368,  335,  147,    6,  148,
-  149,  150,  151,  534,  563,  152,  283,  105,  154,  155,
-  156,  542,  157,  158,  159,  557,  160,  561,  161,  565,
-  162,  572,  163,  164,  165,  166,  241,  383,  167,  168,
-  318,  169,  242,  170,  218,  264,  354,  256,  213,  372,
-  373,  498,  230,  374,  171,  172,  234,  202,  479,  480,
-  319,  343,  473,  183,  243,  184,  185,  186,  187,  107,
-  108,  109,  110,  195,  196,  344,  345,  214,  215,  244,
-  603,  687,  711,  732,  355,  356,  502,  503,  245,  111,
-  250,  519,  655,  649,  689,  499,  669,  384,  670,  511,
-  507,  621,  622,
+  188,    5,  402,  198,  146,  369,  336,  147,    6,  148,
+  149,  150,  151,  537,  566,  152,  284,  105,  154,  155,
+  156,  545,  157,  158,  159,  560,  160,  564,  161,  568,
+  162,  575,  163,  164,  165,  166,  242,  385,  167,  168,
+  319,  169,  243,  170,  218,  265,  355,  257,  213,  373,
+  374,  500,  230,  375,  171,  172,  235,  202,  481,  482,
+  320,  344,  475,  183,  244,  184,  185,  186,  187,  107,
+  108,  109,  110,  195,  196,  345,  346,  214,  215,  245,
+  606,  691,  715,  736,  356,  357,  231,  504,  505,  246,
+  111,  251,  522,  658,  652,  693,  501,  673,  386,  674,
+  514,  510,  624,  625,
 };
-final static short yysindex[] = {                      -320,
-    0,10200,    0,12076,    0, -308,    0,16891,   54,16891,
+final static short yysindex[] = {                      -330,
+    0,10280,    0,12156,    0, -302,    0,16971,  102,16971,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
@@ -500,75 +501,76 @@
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,    0,    0,    0, -272, -272, 6843, -272,   31,
-   49,    0,    0,  118,    0,  -93,    0,  136,    0,    0,
-    0,    0,    0,    0,    0,    0,    0,12546,10318,10318,
-13600,    0,10200, 6962,   54, 8469,   54,   92,   92,13480,
-   54,    0,   54,13600, -272, -272, -272, -272, -279, -272,
-    8,    0,  -84,15322, 9272, -272,    0,    0,  132,    0,
-    0,  358, -164, -147,    0,  -35,   47,  116,  120,  -19,
-    0, -151, 8803,    0,  208,    0,    0,  -36,    0,    0,
-    0,    0,    0,  192, -272, -131,  201,13136,16891, -272,
-    0, -129,  225,  -23,  233,   -4,    0,12076,  287,   73,
-   76, -272,   85,    0,    0,   97, -272,13600,   20,    0,
-    0,   92,  -45,    0,    0,16891,16891,  216,  223,    0,
-    0,  313,   92,  -57,    0,   92, -129,   86,    0,   92,
- -272, -272,    0,  329,  282,    0,    0, -272,  367,   92,
-   92,  282,15440,    0,16891,13136,13136,13136,16891,    2,
-  320,    7,    0,  372,    0,  380,    0,    0,  165, -272,
-    0,  166, 9734,   94,    0,   92,16891,16891,  318,  321,
-    0,   51,  118,14524,    0, 8927,12076, -272, -272,    0,
-    0,    0,    0,    0, -272,    0,    0,    0,    0,    0,
-    0,    0, -272, -272, -272, -272, -272, -272, -272, -272,
- -272, -272, -272, -272, -272, -272, -272, -272, -272, -272,
- -272, -272, -272, -272, -272, -272, -272, -272, -272, -272,
- -272, -272,16891,   89, -272,  410,    0,    0,  122, -272,
-  408,10200, -272,    0,    0,14062,    0, -272,  409, -272,
-    0,  333, -272,    0, -272,    0,    0,  328,  336,12546,
-  349,  353,    0,    0,    0,   85,    0,12546,    0,  207,
-   92,10200,    0,  207,    0,    0,    0,    0,  224,  226,
- 9734,    0, -272,    0,12076,  206,15558,    0,  453, -272,
-    0,    0, -176,    0,    0,  195, -272,    0,    0,    0,
- -272,    0,   95,  117,    0,    0,    0,    0,    0,    0,
- -272,    0,    0, -279, -272,    0,  387,12076,  389,    0,
-  476, 9734, -272,    0,    0,  192,  201,  269,  276, -272,
-    0,   92,    0, 9272,    0,12546,12076,12076,12199,12076,
-12546,12546,12546,12669,10200,10200,12669,12669,12669,12546,
-12546,12546,12546,12546,12546,12546,12669,12546,12669,12669,
-12669,12669,12669,12669,12669,12669,15676,  442,  497, -272,
-  499,  503,    0,  410,    0,12546,    0,    0,12546,  118,
-    0,10200, -272,10200, -272, 6962,    0, 8927,    0,    0,
-    0, -272,16891,10200,16198,    0,    0,10318,    0,  277,
-    0,   92, -272,    0,  421,  423,  508,16891,   92,  -75,
- -272,  510,    0,  512, -272,10200,   92,    0,    0,  140,
-  146,  205,    0,  286,  281,16487,  520, -272, -272, -272,
-    0,    0,    0,    2,    0,    0,    0, -272,  437,    0,
-  505,  528,12546,  445,  446,12076,    0,  118, -147,    0,
-    0,  -21,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0, -117, -117,    0,  120,    0,  120,    0,  -19,
-    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0, -272,  532,    0, -272,  533, -272,    0,    0,
-    0,    0,    0,10662,    0,10662, -129,    0,    0,    0,
-    0,    0,    0,    0,  -45,10318,    0,    0,    0,    0,
-  505,    0,  531,    0,    0,    0,  536, -272,    0,    0,
-   92,    0, -272, -272,    0, -272,    0,  521,  521,    0,
-    3,    0,  521, -106,  537,16891,    0,    0,    0,  505,
-    0,    0,    0,    0,    0,  217,  540, -272,  542,    0,
-  543,    0,    0,  460,  462,  207,   92,    0,  -26,    0,
- -272,    0,  550,    0,  310,    0,13600,10200,    0,    0,
-    0, -272,    0,    0, -272,15794,15794,    0,    0, -272,
-  521,    0,  468,    0, -272,    0,  553,    0,    0,    0,
-    0,    0,  207,   54,15912,15912, -272, -107,    0,16891,
-    0, -272,  470,  561,    0,16487,    0,    0,    0,  477,
-    0, -169,    0,    0,  227,    0,    0,  -98, 9734,  -25,
-   92,  100,   92,    0, -272,  479,    0,    0,    0,10200,
-    0,    0, -272,15794,15794,    0,   54,    0,  564,12076,
- 9734,    0,    0,    0,    0,    0,  279,    0,    0,    0,
-    0,  505,    0,  568,    0,    0,  505,    0,
+    0,    0,    0,    0,    0, -292, -292, 6923, -292,  -27,
+   26,    0,    0,  100,    0,   -7,    0,  112,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,12626,10398,10398,
+13680,    0,10280, 7042,  102, 8549,  102,   65,   65,13560,
+  102,    0,  102,13680, -292, -292, -292, -292, -309, -292,
+    9,    0,  -75,15402, 9352, -292,    0,    0,  138,    0,
+    0,  341, -225, -179,    0,    6,   24,   47,   61,  -11,
+    0, -171, 8883,    0,  176,    0,    0,   12,    0,    0,
+    0,    0,    0,  170, -292, -180,  190,13216,16971, -292,
+    0, -162,  169,   -1,  171,    7,    0,12156,  228,   25,
+   27, -292,   38,    0,    0,   56, -292,13680,  114,    0,
+    0,   65,  -76,    0,    0,16971,16971,  192,  203,    0,
+    0,  289,   65,  -67,    0,   65, -162,   89,    0,   65,
+ -292, -292,    0,  300,  255,    0,    0, -292,  311,   65,
+  -31,   65,  255,15520,    0,16971,13216,13216,13216,16971,
+  -15,  292,   41,    0,  348,    0,  368,    0,    0,  158,
+ -292,    0,  160, 9814,   51,    0,   65,16971,16971,  299,
+  305,    0,   46,  100,14604,    0, 9007,12156, -292, -292,
+    0,    0,    0,    0,    0, -292,    0,    0,    0,    0,
+    0,    0,    0, -292, -292, -292, -292, -292, -292, -292,
+ -292, -292, -292, -292, -292, -292, -292, -292, -292, -292,
+ -292, -292, -292, -292, -292, -292, -292, -292, -292, -292,
+ -292, -292, -292,16971,   95, -292,  398,    0,    0,  161,
+ -292,  407,10280, -292,    0,    0,14142,    0, -292,  412,
+ -292,    0,  332, -292,    0, -292,    0,    0,  337,  339,
+12626,  342,  344,    0,    0,    0,   38,    0,12626,    0,
+  206,   65,10280,    0,  206,    0,    0,    0,    0,  227,
+  230, 9814,    0, -292,    0,12156,  204,15638,    0,  448,
+ -292,    0,    0,  -98,    0,    0,  129, -292,    0, -292,
+    0,    0, -292,    0,  103,  110,    0,    0,    0,    0,
+    0,    0, -292,    0,    0, -309, -292,    0,  371,12156,
+  372,    0,  458, 9814, -292,    0,    0,  170,  190,  243,
+  244, -292,    0,   65,    0, 9352,    0,12626,12156,12156,
+12279,12156,12626,12626,12626,12749,10280,10280,12749,12749,
+12749,12626,12626,12626,12626,12626,12626,12626,12749,12626,
+12749,12749,12749,12749,12749,12749,12749,12749,15756,  415,
+  469, -292,  470,  476,    0,  398,    0,12626,    0,    0,
+12626,  100,    0,10280, -292,10280, -292, 7042,    0, 9007,
+    0,    0,    0, -292,16971,10280,16278,    0,    0,10398,
+    0,  253,    0,   65, -292,    0,  386,  400,  482,16971,
+   65,  -63, -292,  486,    0,  488, -292,10280,   65,    0,
+    0,    0,  116,  186,    0,  258,  256,13680,16567,  492,
+ -292, -292, -292,    0,    0,    0,  -15,    0,    0,    0,
+ -292,  410,    0,  487,  508,12626,  426,  427,12156,    0,
+  100, -179,    0,    0,   -6,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0, -119, -119,    0,   61,    0,
+   61,    0,  -11,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0, -292,  514,    0, -292,  515,
+ -292,    0,    0,    0,    0,    0,10742,    0,10742, -162,
+    0,    0,    0,    0,    0,    0,    0,  -76,10398,    0,
+    0,    0,    0,  487,    0,  517,    0,    0,    0,  521,
+ -292,    0,    0,   65,    0, -292,  487, -292,    0,  518,
+  505,  505,    0,    8,    0,  505,  -92,  524,16971,    0,
+    0,    0,  487,    0,    0,    0,    0,    0,  193,  525,
+ -292,  529,    0,  533,    0,    0,  452,  453,  206,   65,
+    0,  -57,    0, -292,    0,  539,    0,  301,    0,10280,
+    0,    0,10280,    0,    0, -292,    0,    0, -292,15874,
+15874,    0,    0, -292,  505,    0,  456,    0, -292,    0,
+  541,    0,    0,    0,    0,    0,  206,  102,15992,15992,
+ -292, -195,    0,16971,    0, -292,  462,    0,  205,16567,
+    0,    0,    0,  478,    0, -185,    0,    0,  217,    0,
+    0,  -85, 9814,  -24,   65,  105,   65,    0, -292,  480,
+    0,    0,    0,  487,    0,    0, -292,15874,15874,    0,
+  102,    0,  560,12156, 9814,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  487,    0,  565,    0,  487,
+    0,
 };
-final static short yyrindex[] = {                      6365,
-    0,  133,    0,   74,    0, 5602,    0,    0,    0,    0,
+final static short yyrindex[] = {                      6461,
+    0,  182,    0,   17,    0, 5407,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
@@ -577,87 +579,88 @@
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,    0,    0,    0,13013,17009,  -43,11606,    0,
-    0,    0,    0,  580,    0,    0,    0, 6065,    0,    0,
-    0,    0,    0,    0,    0,    0,    0,  133,  -86,  -81,
-    0,    0,  133,  133,    0,    0,    0,    0,    0,    0,
-    0,    0,    0,    0,17009,13013,13013,13013,10789,11606,
-    0,    0,    0,    0,  133,  610,    0,    0,   26,    0,
- 1114, 5318,    0, 6150,    0, 4926,  845, 5133, 4682, 4511,
-    0, 4472, 4094,    0, 2403,    0,    0,    0,    0,    0,
-    0,    0,    0, 5340,11606,    0, 5714,  133,    0,14406,
-    0,  -17,    0,   11,    0,  518,    0,  133,    0,    0,
-    0,11729,    0,    0,    0,    0,11729,    0,    0,    0,
-    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,    0,14864,    0,    0,  331,    0,    0,    0,
-16030,11136,    0, 2818,    0,    0,    0,11606,    0,    0,
-    0,    0,    0,    0,    0,  133,  133,  133,    0,   17,
-    0,    0,    0,   34,    0,    0,    0,    0,    0,11259,
-    0,    0,  -11,  490,    0,    0,    0,    0,    0,    0,
- 7424,    0,  733,    0,    0,  128,  555,11729,11606,    0,
-    0,    0,    0,    0,11606,    0,    0,    0,    0,    0,
-    0,    0,11606,11606,11729,11729,11729,11729, 9390, 9390,
-11729,11729,11729,11729,11729,11729,11729,11729,11729,11729,
-11729,11729,11729,11729,11729,11729,11729,11729,11729,11729,
-16030,10789,    0, 2971,11136,    0,    0,    0,    0,11729,
-    0,  133,11729,    0,    0,    0,    0, 9390, 5982, 9390,
-    0, 6015, 6499,    0,   -3,    0,    0,    0,    0,  133,
-17127,16655,    0,    0,    0,    0,    0,  133,    0,  352,
-    0,  133,    0,  352,    0,    0,    0,    0,    0,    0,
-  -11,    0,17009,    0,  133, 1835,    0,    0,    0,11136,
-    0,    0, 2250,    0,    0,    0,11606,    0,    0,    0,
-16369,    0,  -67,    0,    0,    0,    0,    0,    0,    0,
-11606,    0,    0,11606,11606, 1267,    0,  -39,    0,    0,
-    0,  -11,11729,    0,    0, 7764, 7886,    0,    0,11606,
-    0,    0,    0,  133,    0,  133,  133,  133,  133,  133,
-  133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
-  133,  133,  133,  133,  133,  133,  133,  133,  133,  133,
-  133,  133,  133,  133,  133,  133,    0,    0, 3386,11136,
-    0,    0,    0,    0,    0,  133,    0,    0,  133,   -8,
-    0,  133, 9856,  133, 9856,  133,    0,  -22,    0,    0,
-    0,11606,    0,  133,    0,    0,    0,  -81,    0,    0,
-    0,    0,  -80,    0,    0,    0,    0,    0,    0,    0,
-11136, 3539,    0,    0,  -56,  133,    0,    0,    0,    0,
-    0,    0,    0,    0, 1682,  576,    0,  -96,16369,17009,
-    0,    0,    0,    0,    0,    0,    0,  501,    0,    0,
-  490,    0,  133,    0,    0,  133,    0, 7302, 6200,    0,
-    0,11606,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0, 5169, 5304,    0, 4718,    0, 5097,    0, 4547,
-    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,    0,11136, 3954,    0,11136,    0,11136,    0,    0,
-    0,    0,    0,  133,    0,  133,    0,    0,    0,    0,
-    0,    0,    0,    0,    0,  -86,    0,    0,    0,    0,
-  490,    0,14982,    0,    0,    0,    0,11136,    0,    0,
-    0,    0,13944, 9390,    0,11606,    0,  -10,  -10,    0,
-  587,    0,  -67,  504,    0,    0,    0,    0,    0,  490,
-    0, 8226, 8348,    0,    0,    0,    0,11136,    0,    0,
-    0,    0,    0,    0,    0,  352,    0,    0,  -42,    0,
-17009,    0,    0,    0,  506,    0,    0,  133,    0,    0,
-    0,16773,    0,    0,  501,    0,    0,    0,    0,  501,
-  -67,    0,    0,    0,11606,    0,    0,    0,    0,    0,
-    0,    0,  352,    0,    0,    0,  -80,  507,    0,    0,
-    0,  -20,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,  509,    0,    0,    0,    0,    0,    0,  -11,  490,
-    0,  490,    0,    0,  501,    0,    0,    0,    0,  133,
-    0,    0,  501,    0,    0,    0,    0,    0,    0,  133,
-  -11,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-    0,  490,    0,    0,    0,    0,  490,    0,
+    0,    0,    0,    0,    0,13093,17089,  -60,11686,    0,
+    0,    0,    0, 5787,    0,    0,    0, 6030,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  182,  -55, -113,
+    0,    0,  182,  182,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,17089,13093,13093,13093,10869,11686,
+    0,    0,    0,    0,  182,  610,    0,    0,   21,    0,
+  825,  531,    0, 6084,    0, 5167, 5245, 4778, 4326, 4152,
+    0, 4116, 4080,    0, 2376,    0,    0,    0,    0,    0,
+    0,    0,    0, 5820,11686,    0, 5855,  182,    0,14486,
+    0,  -26,    0,   34,    0,  522,    0,  182,    0,    0,
+    0,11809,    0,    0,    0,    0,11809,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,14944,    0,    0,  330,    0,    0,    0,
+16110,11216,    0, 2529,    0,    0,    0,11686,    0,    0,
+    0,    0,    0,    0,    0,    0,  182,  182,  182,    0,
+   48,    0,    0,    0,   35,    0,    0,    0,    0,    0,
+11339,    0,    0,  -22,  493,    0,    0,    0,    0,    0,
+    0, 7504,    0,  671,    0,    0,   70,   15,11809,11686,
+    0,    0,    0,    0,    0,11686,    0,    0,    0,    0,
+    0,    0,    0,11686,11686,11809,11809,11809,11809, 9470,
+ 9470,11809,11809,11809,11809,11809,11809,11809,11809,11809,
+11809,11809,11809,11809,11809,11809,11809,11809,11809,11809,
+11809,16110,10869,    0, 2944,11216,    0,    0,    0,    0,
+11809,    0,  182,11809,    0,    0,    0,    0, 9470, 5890,
+ 9470,    0, 5993, 6579,    0,  -12,    0,    0,    0,    0,
+  182,17207,16735,    0,    0,    0,    0,    0,  182,    0,
+  351,    0,  182,    0,  351,    0,    0,    0,    0,    0,
+    0,  -22,    0,17089,    0,  182, 1808,    0,    0,    0,
+11216,    0,    0, 1961,    0,    0,    0,11686,    0,14024,
+    0,    0,16449,    0, -117,    0,    0,    0,    0,    0,
+    0,    0,11686,    0,    0,11686,11686, 1240,    0,  -72,
+    0,    0,    0,  -22,11809,    0,    0, 7844, 7966,    0,
+    0,11686,    0,    0,    0,  182,    0,  182,  182,  182,
+  182,  182,  182,  182,  182,  182,  182,  182,  182,  182,
+  182,  182,  182,  182,  182,  182,  182,  182,  182,  182,
+  182,  182,  182,  182,  182,  182,  182,  182,    0,    0,
+ 3097,11216,    0,    0,    0,    0,    0,  182,    0,    0,
+  182,  -30,    0,  182, 9936,  182, 9936,  182,    0,   -4,
+    0,    0,    0,11686,    0,  182,    0,    0,    0, -113,
+    0,    0,    0,    0,  377,    0,    0,    0,    0,    0,
+    0,    0,11216, 3512,    0,    0,  -59,  182,    0,    0,
+    0,    0,    0,    0,    0,    0, 1393,    0,  579,    0,
+  -79,16449,17089,    0,    0,    0,    0,    0,    0,    0,
+  496,    0,    0,  493,    0,  182,    0,    0,  182,    0,
+ 7382, 6284,    0,    0,11686,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0, 4913, 4949,    0, 4703,    0,
+ 4742,    0, 4287,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,11216, 3665,    0,11216,    0,
+11216,    0,    0,    0,    0,    0,  182,    0,  182,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,  -55,    0,
+    0,    0,    0,  493,    0,15062,    0,    0,    0,    0,
+11216,    0,    0,    0,    0, 9470,  493,11686,    0,    0,
+  -16,  -16,    0,  581,    0, -117,  501,    0,    0,    0,
+    0,    0,  493,    0, 8306, 8428,    0,    0,    0,    0,
+11216,    0,    0,    0,    0,    0,    0,    0,  351,    0,
+    0, -103,    0,17089,    0,    0,    0,  503,    0,  182,
+    0,    0,  182,    0,    0,16853,    0,    0,  496,    0,
+    0,    0,    0,  496, -117,    0,    0,    0,11686,    0,
+    0,    0,    0,    0,    0,    0,  351,    0,    0,    0,
+  377,  504,    0,    0,    0,  -70,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  507,    0,    0,    0,    0,
+    0,    0,  -22,  493,    0,  493,    0,    0,  496,    0,
+    0,    0,    0,  493,    0,    0,  496,    0,    0,    0,
+    0,    0,    0,  182,  -22,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,  493,    0,    0,    0,  493,
+    0,
 };
 final static short yygindex[] = {                         0,
-    1,    0,  275,   12,    0,   68,  232,  370, -138, -153,
-    0, -201,  221,    0,  179,    0,    0,   50,  222,  212,
- -267, -286,   57,  -18,  -50,    0,  -14,  197,   58,   78,
-  194,    0,    0, -122,    0,    0,  -48, -120, -225,   90,
-    0,   -7,    0,  311,    0, -121, -260,  377,    0,  412,
-  264,  144,    0,  267,  160,    0,    0, -110, -290,    0,
-    0, -270, -310, -236, -174,  -69,    0,    0, -112,  327,
- -529,    0,    0,    0,    0,  308,    0,    0,    0, -217,
-    0,    0,  -31, -249, -593,  -32,    0,   41,  265,    0,
- -223, -578,    9,    0,    0,    0,    0, -579,    0, -539,
-  151,    0,  -29,
+    1,    0,  120,   50,    0,  -20,  233,  369, -146, -147,
+    0, -255,  223,    0,  331,    0,    0,  173,  219,  212,
+  183,   63,  108, -284,  -36,    0,   10,  198,  202,   59,
+  194,    0,    0,  -18,    0,    0,   23, -121, -236,   91,
+    0,   -2,    0,  139,    0, -110, -238,  388,    0,  424,
+  279,  154,    0,  283,  174,    0,    0, -114, -325,    0,
+    0, -278, -279, -252, -178,    2,    0,    0, -112,  346,
+ -403,    0,    0,    0,    0,  321,    0,    0,    0, -219,
+    0,    0,  -14, -186, -597,  -13,    0,    0,   64,  278,
+    0, -260, -525,   29,    0,    0,    0,    0, -613,    0,
+ -549,  165,    0,  -17,
 };
-final static int YYTABLESIZE=17506;
+final static int YYTABLESIZE=17586;
 
 //These two tables are not statically initialized, but rather
 //initialized on first use, so that a failure to initialize them
@@ -679,7 +682,7 @@
         yytable = (short[])obInp.readObject();
         yycheck = (short[])obInp.readObject();
         long hash = EYaccFixer.checkhash(yytable, yycheck);
-        if (hash != 2899208771068227488L) {
+        if (hash != 7347504338038639248L) {
             throw new RuntimeException(rName + " bad checkhash: " +
                                        hash);
         }
@@ -946,19 +949,20 @@
 "method : ON methHead body",
 "method : META parenExpr MapsTo parenExpr",
 "method : META parenExpr body",
-"methHead : '(' patternList ')' returnGuard",
-"methHead : verb '(' patternList ')' returnGuard",
-"methHead : verb returnGuard",
-"funcHead : '(' patternList ')' returnGuard",
-"funcHead : verb '(' patternList ')' returnGuard",
-"funcHead : verb returnGuard",
-"classHead : audits '(' patternList ')' returnGuard",
+"methHead : '(' patternList ')' resultGuard",
+"methHead : verb '(' patternList ')' resultGuard",
+"methHead : verb resultGuard",
+"funcHead : '(' patternList ')' resultGuard",
+"funcHead : verb '(' patternList ')' resultGuard",
+"funcHead : verb resultGuard",
+"classHead : audits '(' patternList ')' resultGuard",
 "matcher : MATCH pattern body",
 "delegator : DELEGATE body",
-"returnGuard :",
-"returnGuard : ':' br order",
-"whenHead : '(' args ')' OpWhen br audits '(' patterns ')'",
-"whenHead : audits '(' whenClauses ')'",
+"resultGuard :",
+"resultGuard : ':' br order",
+"whenArgs : '(' args ')'",
+"whenHead : whenArgs OpWhen br audits '(' patterns ')' resultGuard",
+"whenHead : audits '(' whenClauses ')' resultGuard",
 "whenClauses : whenClause",
 "whenClauses : whenClauses ',' whenClause",
 "whenClause : eExpr OpWhen br pattern",
@@ -1118,7 +1122,7 @@
 "reserved : WSTRING",
 };
 
-//#line 1083 "e.y"
+//#line 1086 "e.y"
 
 /**
  *
@@ -1550,7 +1554,7 @@
  */
 static public final IntTable TheTokenTable = tokenTable(TheTokens);
 
-//#line 4977 "EParser.java"
+//#line 4997 "EParser.java"
 //###############################################################
 // method: yylexdebug : check lexer state
 //###############################################################
@@ -2441,247 +2445,251 @@
 { yyval = val_peek(0); }
 break;
 case 227:
-//#line 820 "e.y"
-{ yyval = list(val_peek(7), val_peek(3), val_peek(1)); }
+//#line 818 "e.y"
+{ yyval = val_peek(1); }
 break;
 case 228:
-//#line 822 "e.y"
-{ pocket("when-clauses");
-                                                  yyval = list(val_peek(3), val_peek(1)); }
+//#line 823 "e.y"
+{ yyval = list(val_peek(7), val_peek(4), val_peek(2), val_peek(0)); }
 break;
 case 229:
-//#line 827 "e.y"
-{ yyval = list(val_peek(0)); }
+//#line 825 "e.y"
+{ pocket("when-clauses");
+                                                  yyval = list(val_peek(4), val_peek(2), val_peek(0)); }
 break;
 case 230:
-//#line 828 "e.y"
-{ yyval = with(val_peek(2), val_peek(0)); }
+//#line 830 "e.y"
+{ yyval = list(val_peek(0)); }
 break;
 case 231:
-//#line 832 "e.y"
+//#line 831 "e.y"
+{ yyval = with(val_peek(2), val_peek(0)); }
+break;
+case 232:
+//#line 835 "e.y"
 { list(val_peek(3), val_peek(0)); }
 break;
-case 236:
-//#line 850 "e.y"
+case 237:
+//#line 853 "e.y"
 { yyval = list(); }
 break;
-case 239:
-//#line 860 "e.y"
+case 240:
+//#line 863 "e.y"
 { yyval = list(val_peek(0)); }
 break;
-case 240:
-//#line 861 "e.y"
+case 241:
+//#line 864 "e.y"
 { yyval = with(val_peek(2), val_peek(0)); }
 break;
-case 241:
-//#line 866 "e.y"
+case 242:
+//#line 869 "e.y"
 { yyval = list(val_peek(0)); }
 break;
-case 242:
-//#line 867 "e.y"
+case 243:
+//#line 870 "e.y"
 { yyval = with(val_peek(2), val_peek(0)); }
 break;
-case 243:
-//#line 871 "e.y"
+case 244:
+//#line 874 "e.y"
 { yyval = new Assoc(val_peek(2), val_peek(0)); }
 break;
-case 244:
-//#line 872 "e.y"
+case 245:
+//#line 875 "e.y"
 { reserved("export binding"); }
 break;
-case 246:
-//#line 885 "e.y"
+case 247:
+//#line 888 "e.y"
 { yyval = hilbert(val_peek(0)); }
 break;
-case 247:
-//#line 886 "e.y"
+case 248:
+//#line 889 "e.y"
 { reserved("keyword \"" +
                                                    ((Token)val_peek(0)).token() +
                                                    "\""); }
 break;
-case 248:
-//#line 902 "e.y"
+case 249:
+//#line 905 "e.y"
 { yyval = "add"; }
 break;
-case 249:
-//#line 903 "e.y"
+case 250:
+//#line 906 "e.y"
 { yyval = "and"; }
 break;
-case 250:
-//#line 904 "e.y"
+case 251:
+//#line 907 "e.y"
 { yyval = "approxDivide"; }
 break;
-case 251:
-//#line 905 "e.y"
+case 252:
+//#line 908 "e.y"
 { yyval = "floorDivide"; }
 break;
-case 252:
-//#line 906 "e.y"
+case 253:
+//#line 909 "e.y"
 { yyval = "shiftLeft"; }
 break;
-case 253:
-//#line 907 "e.y"
+case 254:
+//#line 910 "e.y"
 { yyval = "remainder"; }
 break;
-case 254:
-//#line 908 "e.y"
+case 255:
+//#line 911 "e.y"
 { yyval = "mod"; }
 break;
-case 255:
-//#line 909 "e.y"
+case 256:
+//#line 912 "e.y"
 { yyval = "multiply"; }
 break;
-case 256:
-//#line 910 "e.y"
+case 257:
+//#line 913 "e.y"
 { yyval = "or"; }
 break;
-case 257:
-//#line 911 "e.y"
+case 258:
+//#line 914 "e.y"
 { yyval = "pow"; }
 break;
-case 258:
-//#line 912 "e.y"
+case 259:
+//#line 915 "e.y"
 { yyval = "subtract"; }
 break;
-case 259:
-//#line 913 "e.y"
+case 260:
+//#line 916 "e.y"
 { yyval = "xor"; }
 break;
-case 260:
-//#line 922 "e.y"
+case 261:
+//#line 925 "e.y"
 { yyval = NULL; }
 break;
-case 261:
-//#line 923 "e.y"
+case 262:
+//#line 926 "e.y"
 { yyval = val_peek(3); }
 break;
-case 262:
-//#line 927 "e.y"
+case 263:
+//#line 930 "e.y"
 { yyval = val_peek(2); }
 break;
-case 263:
-//#line 932 "e.y"
+case 264:
+//#line 935 "e.y"
 { yyval = eScript(val_peek(3), optMatcher(val_peek(2))); }
 break;
-case 264:
-//#line 934 "e.y"
+case 265:
+//#line 937 "e.y"
 { pocket("plumbing");
                                   yyval = eScript(null, val_peek(0)); }
 break;
-case 265:
-//#line 936 "e.y"
+case 266:
+//#line 939 "e.y"
 { pocket("plumbing");
                                   yyval = eScript(null, val_peek(0)); }
 break;
-case 266:
-//#line 945 "e.y"
+case 267:
+//#line 948 "e.y"
 { myNest++; }
 break;
-case 267:
-//#line 949 "e.y"
+case 268:
+//#line 952 "e.y"
 { myNest--; }
 break;
-case 269:
-//#line 954 "e.y"
+case 270:
+//#line 957 "e.y"
 { yyval = with(val_peek(2), val_peek(1)); }
 break;
-case 271:
-//#line 959 "e.y"
+case 272:
+//#line 962 "e.y"
 { yyval = with(val_peek(2), val_peek(1)); }
 break;
-case 273:
-//#line 964 "e.y"
+case 274:
+//#line 967 "e.y"
 { yyval = with(val_peek(2), val_peek(1)); }
 break;
-case 276:
-//#line 981 "e.y"
+case 277:
+//#line 984 "e.y"
 { yyval = with(val_peek(1), val_peek(0)); }
 break;
-case 277:
-//#line 985 "e.y"
+case 278:
+//#line 988 "e.y"
 { yyval = matcher(val_peek(1), val_peek(0)); }
 break;
-case 278:
-//#line 992 "e.y"
+case 279:
+//#line 995 "e.y"
 { yyval = null; }
 break;
-case 279:
-//#line 993 "e.y"
+case 280:
+//#line 996 "e.y"
 { yyval = val_peek(0); }
 break;
-case 280:
-//#line 1004 "e.y"
+case 281:
+//#line 1007 "e.y"
 { yyval = oType(val_peek(6), val_peek(2)); }
 break;
-case 281:
-//#line 1005 "e.y"
+case 282:
+//#line 1008 "e.y"
 { yyval = oType(val_peek(2), list(val_peek(1))); }
 break;
-case 285:
-//#line 1012 "e.y"
-{ yyval = with(val_peek(3),val_peek(1)); }
-break;
 case 286:
-//#line 1016 "e.y"
-{ yyval = list(val_peek(0)); }
+//#line 1015 "e.y"
+{ yyval = with(val_peek(3),val_peek(1)); }
 break;
 case 287:
-//#line 1017 "e.y"
-{ yyval = with(val_peek(3),val_peek(0)); }
+//#line 1019 "e.y"
+{ yyval = list(val_peek(0)); }
 break;
 case 288:
-//#line 1019 "e.y"
-{ reserved("on event"); }
+//#line 1020 "e.y"
+{ yyval = with(val_peek(3),val_peek(0)); }
 break;
 case 289:
-//#line 1020 "e.y"
+//#line 1022 "e.y"
 { reserved("on event"); }
 break;
 case 290:
-//#line 1027 "e.y"
-{ yyval = mType(val_peek(1),list(),val_peek(0)); }
+//#line 1023 "e.y"
+{ reserved("on event"); }
 break;
 case 291:
-//#line 1028 "e.y"
-{ yyval = mType(val_peek(4),val_peek(2),val_peek(0)); }
+//#line 1030 "e.y"
+{ yyval = mType(val_peek(1),list(),val_peek(0)); }
 break;
 case 292:
-//#line 1029 "e.y"
-{ yyval = mType("run",val_peek(2),val_peek(0)); }
+//#line 1031 "e.y"
+{ yyval = mType(val_peek(4),val_peek(2),val_peek(0)); }
 break;
 case 293:
-//#line 1033 "e.y"
-{ yyval = val_peek(0); }
+//#line 1032 "e.y"
+{ yyval = mType("run",val_peek(2),val_peek(0)); }
 break;
 case 294:
-//#line 1034 "e.y"
-{ yyval = val_peek(1); }
+//#line 1036 "e.y"
+{ yyval = val_peek(0); }
 break;
 case 295:
-//#line 1038 "e.y"
-{ yyval = list(val_peek(0)); }
+//#line 1037 "e.y"
+{ yyval = val_peek(1); }
 break;
 case 296:
-//#line 1039 "e.y"
-{ yyval = with(val_peek(3),val_peek(0)); }
+//#line 1041 "e.y"
+{ yyval = list(val_peek(0)); }
 break;
 case 297:
-//#line 1046 "e.y"
-{ yyval = pType(val_peek(1),val_peek(0)); }
+//#line 1042 "e.y"
+{ yyval = with(val_peek(3),val_peek(0)); }
 break;
 case 298:
-//#line 1047 "e.y"
-{ yyval = pType(null,val_peek(0)); }
+//#line 1049 "e.y"
+{ yyval = pType(val_peek(1),val_peek(0)); }
 break;
 case 299:
-//#line 1051 "e.y"
-{ yyval = null; }
+//#line 1050 "e.y"
+{ yyval = pType(null,val_peek(0)); }
 break;
 case 300:
-//#line 1052 "e.y"
+//#line 1054 "e.y"
+{ yyval = null; }
+break;
+case 301:
+//#line 1055 "e.y"
 { yyval = val_peek(0); }
 break;
-//#line 6105 "EParser.java"
+//#line 6129 "EParser.java"
 //########## END OF USER-SUPPLIED ACTIONS ##########
     }//switch
     //#### Now let's reduce... ####



1.76      +15 -12    e/src/jsrc/org/erights/e/elang/syntax/e.y

Index: e.y
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/syntax/e.y,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- e.y	2001/08/23 08:57:07	1.75
+++ e.y	2001/08/27 22:19:47	1.76
@@ -759,10 +759,10 @@
  * Appears in method definition
  */
 methHead:
-             '(' patternList ')' returnGuard { $$ = methHead("run", $2, $4); }
- |      verb '(' patternList ')' returnGuard { $$ = methHead($1, $3, $5); }
+             '(' patternList ')' resultGuard { $$ = methHead("run", $2, $4); }
+ |      verb '(' patternList ')' resultGuard { $$ = methHead($1, $3, $5); }
 
- |      verb                     returnGuard { pocket("no-paren-method");
+ |      verb                     resultGuard { pocket("no-paren-method");
                                                $$ = methHead($1, list(), $2); }
  ;
 
@@ -771,11 +771,11 @@
  * Appears in "function" definition
  */
 funcHead:
-             '(' patternList ')' returnGuard { $$ = methHead("run", $2, $4); }
+             '(' patternList ')' resultGuard { $$ = methHead("run", $2, $4); }
 
- |      verb '(' patternList ')' returnGuard { pocket("one-method-object");
+ |      verb '(' patternList ')' resultGuard { pocket("one-method-object");
                                                $$ = methHead($1, $3, $5); }
- |      verb                     returnGuard { pocket("no-paren-method");
+ |      verb                     resultGuard { pocket("no-paren-method");
                                                $$ = methHead($1, list(), $2); }
  ;
 
@@ -784,7 +784,7 @@
  *
  */
 classHead:
-        audits '(' patternList ')' returnGuard   { $$ = list($1, $3, $5); }
+        audits '(' patternList ')' resultGuard   { $$ = list($1, $3, $5); }
  ;
 
 /**
@@ -809,18 +809,21 @@
 /**
  * Optional guard.  If empty, defaults to ":void".
  */
-returnGuard:
+resultGuard:
         /*empty*/                               { $$ = VOID; }
  |      ':' br order                            { $$ = $3; }
  ;
 
+whenArgs:
+        '(' args ')'                            { $$ = $2; }
+ ;
 
 whenHead:
-        '(' args ')' OpWhen br audits '(' patterns ')' 
-                                                { $$ = list($2, $6, $8); }
+        whenArgs OpWhen br audits '(' patterns ')' resultGuard
+                                                { $$ = list($1, $4, $6, $8); }
 
- |      audits '(' whenClauses ')'              { pocket("when-clauses");
-                                                  $$ = list($1, $3); }
+ |      audits '(' whenClauses ')' resultGuard  { pocket("when-clauses");
+                                                  $$ = list($1, $3, $5); }
  ;
 
 whenClauses:



1.26      +29 -12    e/src/jsrc/org/erights/e/elib/ref/Ref.java

Index: Ref.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/ref/Ref.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- Ref.java	2001/08/22 14:26:14	1.25
+++ Ref.java	2001/08/27 22:19:47	1.26
@@ -565,24 +565,32 @@
     }
 
     /**
-     * Used for the when-catch construct.  <p>
-     * 
+     * Used for the when-catch construct.
+     * <p>
      * If ref never becomes resolved, the reactor is not invoked. 
      * Should ref become resolved, the reactor will be invoked exactly once.  
      * For example, if ref becomes fulfilled and then broken, the reactor 
-     * will hear of exactly one of these events. <p>
-     *
+     * will hear of exactly one of these events.
+     * <p>
      * Once ref becomes resolved the reactor will be invoked with the 
      * resolution.  Should the reactor be invoked with a non-broken 
      * value (and therefore a fulfilled value), all earlier messages sent on 
      * ref before the whenResolved are guaranteed to have been successfully 
-     * delivered. <p> 
-     *
-     * @see #whenBroken
+     * delivered.
+     * 
+     * @see #whenBroken(Object, OneArgFunc)
+     * @return A promise that will resolve to the outcome of calling the 
+     *         reactor, as explained <a 
+     * href="http://www.eros-os.org/pipermail/e-lang/2001-August/005638.html"
+     *         >here</a>.
      */
-    static public void whenResolved(Object ref, OneArgFunc reactor) {
+    static public Object whenResolved(Object ref, OneArgFunc reactor) {
+        Object[] pair = promise();
         E.sendOnly(ref, "whenMoreResolved",
-                   new WhenResolvedReactor(reactor, ref));
+                   new WhenResolvedReactor(reactor,
+                                           ref,
+                                           (Resolver)pair[1]));
+        return pair[0];
     }
     
     /**
@@ -597,11 +605,20 @@
      * or may not inform the reactor of partitions that happen after it is 
      * garbage. 
      *
-     * @see #whenResolved
+     * @see #whenResolved(Object, OneArgFunc)
+     * @return A promise that will resolve to the outcome of calling the 
+     *         reactor, as explained <a 
+     * href="http://www.eros-os.org/pipermail/e-lang/2001-August/005638.html"
+     *         >here</a>.  Note that, if ref becomes near, it'll never break, 
+     *         so the returned promise will never be resolved!
      */
-    static public void whenBroken(Object ref, OneArgFunc reactor) {
+    static public Object whenBroken(Object ref, OneArgFunc reactor) {
+        Object[] pair = promise();
         E.sendOnly(ref, "whenBroken",
-                   new WhenBrokenReactor(reactor, ref));
+                   new WhenBrokenReactor(reactor,
+                                         ref,
+                                         (Resolver)pair[1]));
+        return pair[0];
     }
     
 



1.2       +58 -41    e/src/jsrc/org/erights/e/elib/ref/WhenBrokenReactor.java

Index: WhenBrokenReactor.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/ref/WhenBrokenReactor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WhenBrokenReactor.java	2001/07/31 13:09:14	1.1
+++ WhenBrokenReactor.java	2001/08/27 22:19:47	1.2
@@ -29,12 +29,19 @@
 import org.erights.e.elib.util.OneArgFunc;
 
 /**
- * Used to implement "Ref whenBroken/2". <p>
- *
- * Like a Once extended to also invoke "wrapped run/1" when a client 
- * is lost (according to reactToLostClient).  Only does the run/1 behavior 
- * if argument is broken.
- *
+ * Used to implement {@link Ref#whenBroken(Object, OneArgFunc)}.
+ * <p>
+ * Wraps a 'done' function (the second argument of whenBroken), so that the 
+ * done function will eventually be invoked with the original reference 
+ * exactly once under the following conditions: 
+ * <ul>
+ * <li>The original reference is broken
+ * </ul>
+ * This object is woken up by reactToLostClient and the response to 
+ * whenBroken, but in both cases it ignores the argument and treats the 
+ * message just as a wakeup call. 
+ * 
+ * @see WhenResolvedReactor
  * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
  * @author <a href="mailto:tstanley@cocoon.com">Terry Stanley</a>
  */
@@ -43,69 +50,79 @@
     
     private OneArgFunc myOptWrapped;
     private Object myRef;
+    private Resolver myOptResolver;
     
     /**
-     * If I should be told to reactToLostClient before I'm told to run/1, 
-     * then I run/1 on myself with ref as the argument.
+     * Should ref become broken, invoke wrapped, and resolve resolver to its
+     * outcome. 
+     * <p>
+     * Assumes a first whenBroken will be sent with this WhenBrokenReactor as 
+     * argument. 
      */
-    public WhenBrokenReactor(OneArgFunc wrapped, Object ref) {
+    public WhenBrokenReactor(OneArgFunc wrapped,
+                             Object ref,
+                             Resolver resolver)
+    {
         myOptWrapped = wrapped;
         myRef = ref;
+        myOptResolver = resolver;
     }
     
     /**
-     * If arg is broken, then invoke myOptWrapped once, and remember not to
-     * invoke it again (by forgetting it).  Also forget myRef, since we won't 
-     * need it for reactToLostClient. <p>
+     * Causes us to wakeup and check if myRef is broken.
+     * <p>
+     * If myRef is broken, then invoke myOptWrapped once (resolving 
+     * myOptResolver to the outcome), and remember not to invoke it again (by 
+     * forgetting it).  Also forget myRef and myOptResolver, since we won't 
+     * need them again. Further invocations silently return null rather than 
+     * complaining.
+     * <p>  
+     * If myRef is not resolved, then send a new <pre>
      *
-     * If arg is not resolved, then remember it as a better myRef (for 
-     * supporting reactToLostClient), and send a new <pre>
+     *     myRef <- whenMoreResolved(this)
+     * </pre> message whose response should wake me up again.  If myRef is 
+     * resolved but not broken, then be clever.
      *
-     *     arg <- whenMoreResolved(this)
-     * </pre> message.  Unlike a Once, redundant invocations silently return 
-     * null rather than complaining.
-     *
      * @return Always returns null, irrespective of what 
-     *         myOptWrapped.run(arg) returns.
+     *         myOptWrapped.run(arg) returns. 
      */
-    public Object run(Object arg) {
+    public Object run(Object ignored) {
         if (null == myOptWrapped) {
             return null;
         }
-        if (Ref.isBroken(arg)) {
+        if (Ref.isBroken(myRef)) {
+            Object ref = myRef;
+            OneArgFunc wrapped = myOptWrapped;
+            Resolver resolver = myOptResolver;
+            
             myRef = null;
-            OneArgFunc optWrapped = myOptWrapped;
             myOptWrapped = null;
-            optWrapped.run(arg);
+            myOptResolver = null;
+            
+            resolver.resolve(E.send(wrapped, "run", ref));
+
         } else if (Ref.isNear(myRef)) {
+            // Once it's near, it'll never be broken.
+            // Note that the resolver will be forever unresolved in this 
+            // case!
             myRef = null;
             myOptWrapped = null;
-        } else if (Ref.isResolved(arg)) {
+            myOptResolver = null;
+        } else if (Ref.isResolved(myRef)) {
             //It's far, just hang out waiting for partition
         } else {
-            myRef = arg;
-            E.sendOnly(arg, "whenMoreResolved", this);
+            //Not yet resolved, keep polling.
+            //XXX should we poll with whenBroken(..) instead?
+            E.sendOnly(myRef, "whenMoreResolved", this);
         }
         return null;
     }
     
     /**
-     * If I haven't been run/1 yet, then I run(ref) with the ref I was 
-     * constructed with, given that it's already broken, which it should be.
+     * Just like run/1, this is treated merely as a wakeup call to check 
+     * myRef.
      */
     public void reactToLostClient(Throwable problem) {
-        if (null == myOptWrapped) {
-            return;
-        }
-        if (Ref.isBroken(myRef)) {
-            //Just in case the reference is broken with a different problem 
-            //than the partition problem, report the reference's problem, as 
-            //that's more specific.
-            run(myRef);
-        } else {
-            //for myRef to be unbroken is likely a bug, but better to report 
-            //the problem.
-            run(Ref.broken(problem));
-        }
+        run(myRef);
     }
 }



1.8       +33 -18    e/src/jsrc/org/erights/e/elib/ref/WhenResolvedReactor.java

Index: WhenResolvedReactor.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/ref/WhenResolvedReactor.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- WhenResolvedReactor.java	2001/08/13 01:47:03	1.7
+++ WhenResolvedReactor.java	2001/08/27 22:19:47	1.8
@@ -29,15 +29,16 @@
 import org.erights.e.elib.util.OneArgFunc;
 
 /**
- * Used to implement "Ref whenResolved/2", which is used to implement the 
- * <a href="http://www.skyhunter.com/marcs/ewalnut.html#SEC20"
- * >when-catch</a> construct <p>
- *
+ * Used to implement {@link Ref#whenResolved(Object, OneArgFunc)}, which is 
+ * used to implement the <a 
+ * href="http://www.skyhunter.com/marcs/ewalnut.html#SEC20">when-catch</a> 
+ * construct. 
+ * <p>
  * Wraps a 'done' function (the second argument of whenResolved, which is the 
  * right side of the "->" of a when-catch construct), so that the done 
  * function will eventually be invoked with the original reference exactly 
- * once under the following conditions: <ul>
- *
+ * once under the following conditions: 
+ * <ul>
  * <li>The original reference is resolved
  * <li>Either all prior messages sent on the original reference are already 
  * delivered, or the original reference has become broken.
@@ -46,6 +47,7 @@
  * whenMoreResolved, but in both cases it ignores the argument and treats the 
  * message just as a wakeup call.
  *
+ * @see WhenBrokenReactor
  * @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
  * @author <a href="mailto:tstanley@cocoon.com">Terry Stanley</a>
  */
@@ -54,33 +56,40 @@
     
     private OneArgFunc myOptWrapped;
     private Object myRef;
+    private Resolver myOptResolver;
     
     /**
-     * When ref is resolved, invoke wrapped. <p>
-     *
+     * When ref is resolved, invoke wrapped, and resolve resolver to its 
+     * outcome. 
+     * <p>
      * Assumes a first whenMoreResolved will be sent with this 
      * WhenResolvedReactor as argument.
      */
-    /*package*/ WhenResolvedReactor(OneArgFunc wrapped, Object ref) {
+    /*package*/ WhenResolvedReactor(OneArgFunc wrapped,
+                                    Object ref,
+                                    Resolver resolver)
+    {
         myOptWrapped = wrapped;
         myRef = ref;
+        myOptResolver = resolver;
     }
     
     /**
      * Causes us to wakeup and check if myRef is resolved.
-     * 
-     * If myRef is resolved, then invoke myOptWrapped once, and remember not to
-     * invoke it again (by forgetting it).  Also forget myRef, since we won't 
-     * need it again. Further invocations silently return null rather than 
-     * complaining.<p>
-     *
+     * <p>
+     * If myRef is resolved, then invoke myOptWrapped once (resolving 
+     * myOptResolver to the outcome), and remember not to invoke it again (by 
+     * forgetting it).  Also forget myRef and myOptResolver, since we won't 
+     * need them again. Further invocations silently return null rather than 
+     * complaining.
+     * <p>  
      * If myRef is not resolved, then send a new <pre>
      *
      *     myRef <- whenMoreResolved(this)
      * </pre> message whose response should wake me up again.
      *
      * @return Always returns null, irrespective of what 
-     *         myOptWrapped.run(...) returns.
+     *         myOptWrapped.run(...) returns. 
      */
     public Object run(Object ignored) {
         if (null == myOptWrapped) {
@@ -88,11 +97,17 @@
         }
         if (Ref.isResolved(myRef)) {
             Object ref = myRef;
-            OneArgFunc optWrapped = myOptWrapped;
+            OneArgFunc wrapped = myOptWrapped;
+            Resolver resolver = myOptResolver;
+            
             myRef = null;
             myOptWrapped = null;
-            optWrapped.run(ref);
+            myOptResolver = null;
+            
+            resolver.resolve(E.send(wrapped, "run", ref));
+
         } else {
+            //Not yet resolved, keep polling.
             E.sendOnly(myRef, "whenMoreResolved", this);
         }
         return null;