lua-users home
lua-l archive

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

Simple, possibly obvious question.  The 3.2 Reference Manual-- which I
assume is the latest-- states the following in section 5.3:

"As a general rule, all API functions pop from the stack all elements they

Yet, I don't see this in library functions.  Take for example the C code
for strbyte:

static void str_byte (lua_State *L) {
  long l;
  const char *s = luaL_check_lstr(L, 1, &l);
  long pos = posrelat(luaL_opt_long(L, 2, 1), l);
  luaL_arg_check(L, 0<pos && pos<=l, 2,  "out of range");
  lua_pushnumber(L, (unsigned char)s[pos-1]);

Unless I'm missing something, stack elements are referenced, but they
aren't popped off.

I assume this is just a documentation issue; the code clearly works just
fine.  Or am I missing something?  I'm asking because I'm starting to
integrate Lua into my application, and I want to make sure I understand
what I'm doing.-- and doing it correctly.