[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: strings
- From: "Jérôme VUARAND" <jerome.vuarand@...>
- Date: Sat, 14 Oct 2006 21:49:39 -0400
As you can see in Lua syntax
(http://www.lua.org/manual/5.1/manual.html#8), in the definition of a
var, you can only index a prefixexp. "xxx" is an exp but not a
prefixexp. By surrounding it with parenthesis you create a prefixexp.
I don't know the real reason for this (the problem is the same for
tables, e.g. {foo=function() end}:foo()). I think I read something
about potential ambiguities with the function call without parenthesis
on the list some time ago, but I don't remember exacly the issue.
2006/10/14, Gavin Wraith <gavin@wra1th.plus.com>:
In message <d010fc8a0610140018s79bcd587h9102360e4a250c39@mail.gmail.com> you wrote:
> I can write
>
> s="xxxxxxxx"
> print(s:upper())
>
> why not
>
> "xxxxxxxxxx":upper()
>
> ?
Because "xxxxxxxxxx" is not an identifier but an expression?
Try ("xxxxxxxxxx"):upper() .
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/