lua-users home
lua-l archive

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


> > print [[a[[b]]c]]
> stdin:1: '=' expected near ']'

Are you sure?? It worked OK in my machine...
  > print [[a[[b]]c]]
  a[[b]]c


> > print [=[a[=[b]=]c]=]
> stdin:1: '=' expected near ']'

The LUA_COMPAT_LSTR=2 is only for compatibility, so it allows nesting
only for the simple case [[...]] (without equal signs).


> Is there something I have misunderstood? 

The description of long brackets without nesting is conceptually much
simpler than with nesting. It is easy to write a Lua pattern to match
those elements; I believe other tools also can be simpler when there is
no nesting. For instance, a single *find* is enough to find for sure the
end of any long string.

>  To be able to comment out chunks of code secure in the knowledge
> that already existing comments will not terminate the new comment
> prematurely, is surely vital for debugging, however questionable the
> practice formally.

In practice, using [==[ ... ]==] to comment out a piece of code will
work 99% of the time. In the other 1% cases, you get a clear error
message (so the earlier termination does not go unnoticed).

-- Roberto