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 7822977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:05:18+00:00 2026-06-02T08:05:18+00:00

If I have a global table Table that has functions getValue() , setValue() ,

  • 0

If I have a global table Table that has functions getValue(), setValue(), etc. Can I store a reference to Table.getValue or do I have to store a reference to Table and then call the member functions?

lua_getglobal(L, "Table");

lua_getfield(L, -1, "getValue");
getValueRef = luaL_ref(L, LUA_REGISTRYINDEX);

lua_getfield(L, -1, "setValue");
setValueRef = luaL_ref(L, LUA_REGISTRYINDEX);

lua_pop(L, 1); // Pop "Table" off of the stack
  • 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-02T08:05:20+00:00Added an answer on June 2, 2026 at 8:05 am

    There is no such thing as a “member function” in Lua. There is simply a function, which is a value. You can store functions anywhere, directly in the global table, in some other table you create, etc. Functions (and all Lua values for that matter) have no association with any table they happen to be stored in.

    If you want to store a function somewhere (and creating a “reference” is nothing more than storing it somewhere), you can.

    FYI: it is not a good idea to directly use the registry for Lua “references”. I’d suggest creating a table you store in a particular slot in the registry to use for your references. Of course, I would say that it’s not a good idea to use “references” for what you’re doing period.

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

Sidebar

Related Questions

Can Dynamic libraries have global, local and static variables in linux? If yes, then
I have a global header and footer that has a Database connection and a
I have a string like following: CREATE GLOBAL TEMPORARY TABLE some_temp_table_name or CREATE GLOBAL
I have a sample file like the following: CREATE GLOBAL TEMPORARY TABLE tt_temp_user_11 (
I am trying to code a global lookup table of sorts. I have game
In Actionscript you can have global variables like this: var number : Number =
If i have global variable in A.dll, that depends on global variable in B.dll
I have a global variable that is an instance of my custom class. How
I have the following problem: Our system has products that when released only are
I have a MyISAM table that basically contains a log. A cluster of machines

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.