lua-users home
lua-l archive

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


> setmetatable({}, {__gc = function() print("Hello") end})
> 
> But it prints nothing when I try to run in on www.lua.org/cgi-bin/demo
> Why?

Good catch!

It does print "Hello" but it does not show! Look at the HTML and you'll see

	Your program ran successfully.<!-- Hello
	</TEXTAREA><P><IMG SRC="images/alert.png" ALIGN="absbottom">
	Your program was aborted.<!-- -->

That happens because "Hello" is printed only when the Lua interpreter
exits, after the Lua program ran, and then the CGI script has already
collected the output from the Lua program.

Sorry about that. It's probably too complicated to fix this, but
I welcome fixes, of course. The source of the demo is at
	http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/index.html#demo
for those who want to try.