lua-users home
lua-l archive

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


On Sat, Jul 09, 2011 at 11:26:56AM +0200, Michal Kottman wrote:
> 
> Don't expect any hand-holding from Lua. Quoting PIL: Lua gives you the
> power; you build the mechanisms. If you want a function to output a
> "nice" string for the users, write it yourself. In addition, the
> resulting code will be more readable, because IMO the following code:
> 
> print(quote(str))
> 
> is easier to understand than:
> 
> print(string.format("%q", str))
> 
Having written `quote`, you could even do this:

getmetatable('').__unm=quote
print(-str) 

Dirk