[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Compiling
- From: "Wim Couwenberg" <wcou@...>
- Date: Mon, 21 Jun 2004 15:50:16 +0200
> If I compile foo.lua -> foo.luac and execute it, it actually executes
> the require() call and looks for bar.lua. This is terrible, because I
> can't hide the source code. I suppose I could compile bar.lua ->
> bar.luac and require *that* file, but that feels a whole lot more like
> a hack than a solution...
Not a hack at all. Note that require does quite some work to find the file
that is actually required. In particular it does not need the .lua
extension. Consider the following:
---
LUA_PATH = "./?.lua;./?.luac"
require "bar"
---
In this example require tries to load the files ./bar.lua and then
./bar.luac. In this way an uncompiled script preempts a compiled script,
which is quite useful in practice.
So the solution is to set the appropriate LUA_PATH and omit extensions in
the require call for code scripts.
--
Wim