Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:34:30+00:00 2026-06-05T22:34:30+00:00

I thought the documentation of lua_settop() was quite clear: void lua_settop (lua_State *L, int

  • 0

I thought the documentation of lua_settop() was quite clear:

void lua_settop (lua_State *L, int index);

Accepts any acceptable index, or 0, and sets the stack top to this index. If the
new top is larger than the old one, then the new elements are filled with nil. If
index is 0, then all stack elements are removed.

…and yet, this code:

lua_settop(L, 0);
top = lua_gettop(L);
if (lua_isnoneornil(L, top)) {
  printf("Invalid stack (nil)");
}
else {
  // WTF?
  printf("? %d -> %s", top, lua_typename(L, lua_type(L, top)));
}

Yields:

? 0 -> table

What gives?

How can I check if the stack is empty? Using (lua_gettop(L) == 0)?

If so, why is there even a lua_isnone() call?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:34:32+00:00Added an answer on June 5, 2026 at 10:34 pm

    Your question is trivially answered by the docs for lua_gettop:

    Returns the index of the top element in the stack. Because indices
    start at 1, this result is equal to the number of elements in the
    stack (and so 0 means an empty stack).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The MySQL documentation isn't very clear on this. I want to add an index
I'm struggling with something that I thought is quite simple - to generate documentation
Since I couldn't find anything on this in the documentation , I thought I
I searched google, but coulding find anything. Checked the documentation too... I thought Smarty
I thought I understood the basics of pointers, but after checking out some documentation
I know of the documentation for -XUndecidableInstances , but I thought I'd ask for
I recently felt the urge to generate documentation for my little project. I thought
I've read the documentation and thought I'd be able to do the following.... map
I've looked around, and not found much documentation on this, so I thought I'd
The documentation of Data.Array reads: Haskell provides indexable arrays, which may be thought of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.