lua-users home
lua-l archive

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





On Sat, Aug 10, 2013 at 12:35 AM, Tim Hill <drtimhill@gmail.com> wrote:

On Aug 10, 2013, at 12:31 AM, Tim Hill <drtimhill@gmail.com> wrote:


On Aug 9, 2013, at 11:58 PM, Hao Wu <wuhao.wise@gmail.com> wrote:


So my question is, when dealing with string literal, why couldn't we just say:

"a string literal":lower()

instead

("a string literal"):lower()

Is there a language reason to prevent this?

Thanks,

~hao

What's more interesting is that, by my reading of the BNF, _neither_ of these should work (though the second, as you state, does work). SO far as I can see, the BNF doesn't describe the full colon syntax (it is only mentioned when used as part of a function declaration).

--Tim


Ignore that .. my brain shut down there for a moment. Here is the Lua BNF that is significant:

prefixexp ::= var | functioncall | ‘(’ exp ‘)’ functioncall ::= prefixexp args | prefixexp ‘:’ Name args 

So yes, you do need parens.


Yes, I was about to say that. 

It certainly shouldn't be a "BNF" issue or "parser" issue that wouldn't accept the first form (or maybe it is? the parser would take more memory? but we also have byte-code...) - this made me wonder why and the real reason behind it
 
--Tim




~hao