|
On Oct 9, 2015 6:41 AM, "Thomas Jericke" <tjericke@indel.ch> wrote:
>
> On 10/09/2015 12:48 AM, Nagaev Boris wrote:
>>
>>
>> t[[[z]]] looks ambiguous. Everybody would have to remember what it
>> means: t("z") or t["z"].
>>
> t[[z]] is t("z") so t[[[]]] would actually be t("[]"), wouldn't it?
> --
> Thomas
>
Yeah, this syntax is ambiguous. t [[[z]]] already looks like it could be parsed as one of:
t["z"] -- replacing innermost [[]] with ""
t"[z"] -- replacing first [[ and ]] with ""
t"[z]" -- replacing outermost [[]] with ""
As far as neatness, I think spaces improve it a lot here by clearly defining the intended meaning:
t[ [[z]] ] -- or even:
t[
[[some long string here]]
]
But of course spaces don't matter to the compiler.
My solution if I were presented with this situation would be one of:
local s=[[z]]
X = t[s]
Or: refactor so that indexing a table with a string that doesn't fit nicely in quotes is no longer necessary. :)