lua-users home
lua-l archive

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


I have been playing with Lua5.1w6. In luaconf.h it says:

/*
@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
@* facility.
** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
** off the advisory error when nesting [[...]].
*/
#define LUA_COMPAT_LSTR     2

I have compiled with LUA_COMPAT_LSTR equal to 2, but I do not get
any nesting, as I would have expected in Lua5.02:

*lua51
Lua 5.1 (work6)  Copyright (C) 1994-2005 Tecgraf, PUC-Rio
> print [[a[[b]]c]]
stdin:1: '=' expected near ']'
> print [=[a[=[b]=]c]=]
stdin:1: '=' expected near ']'
>

I can understand the weaknesses of using ]] as a string terminator
in view of expressions like foo[bar[7]], so I welcome the possibility
of having [=[....]=]  and so on, which avoid this; but nestability
I would have thought a vital asset. 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. Single line
comments do not cut the mustard. For what other reason but nestability
do C programmers find themselves using #ifdef COMMENT42 ... #endif
to make up for the deficiencies of /*...*/ ?

Is there something I have misunderstood? 
-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/