lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi

The expression syntax has some strange limitations.  For
example '(a or b).x' gives a syntax error.  I see no
logical reason for that.  Afaics the following patch
will fix that.

--- lua-4b-orig/src/lparser.c   Wed Sep 20 19:57:08 2000
+++ lua-4b-es1/src/lparser.c    Fri Oct 13 22:33:37 2000
@@ -636,6 +636,7 @@
       next(ls);
       expr(ls, v);
       check(ls, ')');
+      var_or_func_tail(ls, v);
       return;
     }
     case TK_NAME: case '%': {
@@ -649,6 +650,7 @@
   }
   v->k = VEXP;
   v->u.l.t = v->u.l.f = NO_JUMP;
+  var_or_func_tail(ls, v);
 }
 

Another point: the statement 'foo "a" "b"' is valid but
gives non obvious results.  I guess, most people will
see that as 'foo("a","b")' but it is 'foo("a")("b")',
that is the object returned by foo("a") is called as a
function with argument "b".  IMHO the first interpretation
would be more intuitive and useful, especially when mixing
strings and table constructors: 'create "foo" { x=1, y=2 }'.

Just my 2 cent, ET.