lua-users home
lua-l archive

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


I was writing some small piece of code, testing a bit the syntax features
(with the aim of reducing the number of lines of code) of Lua when I
suddenly struggled in total surprise - after years of Lua programming: My
code needed a semicolon ( ; ). This has never happened to me before.
The Lua syntax check did complain absolutely correctly and in my opinion
this piece of code is not really nice and I think I am not going to use it
- yet it is maybe a quite nice example for what can happen and when a ; is
necessary in Lua code:

   local info = debug.getinfo(2)
   local msg = ("%s{%d} = %s (%s:%d)\n"):format( or
info.source,info.currentline); -- needing the ;
   (file or io.stdout):write(msg)

I don't know how it happens that I never experienced such a case before,
but I found it quite interesting...