lua-users home
lua-l archive

Small syntactic note (Was Re: string.gsub ...)

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


It is possibly worth saying that in Lua, as in many languages, ()
is used in two syntactically distinct contexts for two semantically
distinct purposes:
( [exprlist1] ) is a postfix "call" operator
( exp ) is a term
Like prefix/infix "-", the two contexts can easily be distinguished:
-- following a term (prefixexp or prefixexp ':' Name, in the Lua grammar):
 ( [exprlist] ) "call" (args)
 - "binary operator" (binop)
-- following a binop or at the beginning of an expression:
 ( expr ) "term" (prefixexp)
 - "unary operator" (unop)
It is perhaps the fact that this "pun" is so common that makes
it invisible.

AltStyle によって変換されたページ (->オリジナル) /