[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [Kepler-Project] SAPI semantics in CGILua
- From: "Dirk Feytons" <dirk.feytons@...>
- Date: Mon, 16 Jul 2007 22:37:46 +0200
On 7/16/07, Tomas Guisasola Gorham <firstname.lastname@example.org> wrote:
> At the moment I'm looking at the SAPI.Response.write() function. The
> documentation says it takes a string as parameter. However, when
> looking at the CGILua code from Kepler 1.0 it can call the write()
> function with either a string or a number. A bit confusing but when
> the SAPI implementation uses lua_tostring()/lua_tolstring() or
> luaL_checkstring()/luaL_checklstring() then everything works. If
> however they use e.g. lua_type() to verify that an actual string was
> passed in things can go wrong.
Why is it confusing? I think a number could be used in place
of a string anywhere in Lua don't you?
In hindsight it's quite obvious but when you're just starting with Lua
(like I am) then seeing in the documentation that the write() function
takes a string and reading in the Lua manual that there are separate
string and number types...
> In the current CVS version of CGILua there has been a change recently
> based on a discussion here on the mailing list last April to introduce
> cgilua.print() and equate cgilua.put() to SAPI.Response.write(). This
> changes the expected semantics of that SAPI function: it now becomes
> variadic and the typechecks that previously were in cgilua.put()
> should now be done in SAPI.
The typechecks have to be done in SAPI anyway. The difference
now is that `cgilua.put' will not check types again. `cgilua.print'
on the other hand will apply `tostring' to all its arguments, thus it
will not fail (like primitive `print').
I think we have to correct SAPI.Response.write documentation
to show that it accepts more than one string (I think all the current
implementations accept that).
Yeah, now it says:
Generates output using the given string.
I checked a few implementations but I'm not an expert on those
servers: mod2, cgi and fastcgi seem OK, isapi seems to output only one
I'm thinking about maybe writing a kind of 'unit test' for my SAPI
implementation. If I have something usable and decent I'll share it on
the list. If I discover other unclarities when tackling the other SAPI
functions I'll be back as well :)