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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:20:43+00:00 2026-06-12T02:20:43+00:00

Possible Duplicate: Why make global Lua functions local? In many lua-scripts from the community

  • 0

Possible Duplicate:
Why make global Lua functions local?

In many lua-scripts from the community I see something like to add a module to a script:

local module = require("module")

But according to the lua-manual, this is not the way, to load modules. The modules itself have their module-name inside, so that

require("module")

is just enough to use the module like this: module.myfunction(). The first example with the local-definition just writes “true” into the module-var – indicating, that the module has loaded successfully.

The stange thing is, that I see this kind of loading “local module = require(“module”)” everywhere in the web. Most of the scripts from the lua-community I do not get to working because of this error. I also wonder why I do not found any issues about this on the web yet.

The next thing is, that also actually loading the modules sometimes results in strange errors. For example: I have a script with

require("purexml.lua")

than I got this error:

no field package.preload['purexml.lua']
no file './purexml/lua.lua'
no file '/usr/local/share/lua/5.1/purexml/lua.lua'
no file '/usr/local/share/lua/5.1/purexml/lua/init.lua'
no file '/usr/local/lib/lua/5.1/purexml/lua.lua'
no file '/usr/local/lib/lua/5.1/purexml/lua/init.lua'
no file './purexml/lua.so'
no file '/usr/local/lib/lua/5.1/purexml/lua.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './purexml.so'
no file '/usr/local/lib/lua/5.1/purexml.so'
no file '/usr/local/lib/lua/5.1/loadall.so'

But doing this works fine:

require("purexml")

Am I missing something really obvious here? I use Lua 5.1.4 by the way…

  • 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-12T02:20:45+00:00Added an answer on June 12, 2026 at 2:20 am

    local module = require("module") creates a local variable containing the module, in addition to the default global (the local shadows the global, of course). Locals are a lot faster in Lua to access, so performance is most likely the reason this is used.

    And the error you get is obvious, you mustn’t add the file extension while loading modules.

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

Sidebar

Related Questions

Possible Duplicate: Make iPhone app paid version replace free version on install from app
Possible Duplicate: How to make python scripts executable on Windows? Set up Python on
Possible Duplicate: How can I make an EXE file from a Python program? i
Possible Duplicate: How to make half curl animation in iPhone like the maps app
Possible Duplicate: How to make drag-and-drop from one list to another in C#/WindowsForms? I
Possible Duplicate: java PreparedStatement Can I make the prepared statement SELECT * FROM STUDENTS
Possible Duplicate: How can I make an HTTP GET request from Perl? I am
Possible Duplicate: Make error: missing separator I've made many makefiles, but today I was
Possible Duplicate: How to make org syntax links in any emacs buffer look like
Possible Duplicate: Why is it bad to make elements global variables in Javascript? In

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.