lua-users home
lua-l archive

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



On Feb 02, 2005, at 22:38, David Burgess wrote:

Not too sure what you want, start with an investigation of the "package" table.

Good thinking!

package.loaded: { "ATask" = "table: 0x109c70"; "string" = "table: 0x101bc0"; "debug" = "table: 0x1023c0"; "LUTask" = "table: 0x10a9c0"; "LUClass" = "table: 0x108730"; "LUObject" = "table: 0x1058c0"; "MyClass" = "table: 0x103ca0"; "table" = "table: 0x1012a0"; "io" = "table: 0x101320"; "os" = "table: 0x101910"; "MyOtherClass" = "table: 0x105eb0"; "math" = "table: 0x101ee0"; "LUMap" = "table: 0x107310"; "coroutine" = "table: 0x101000"; "LUList" = "table: 0x106e40" }

This is useful by itself :)

But no path in sight :/

cpath and path may be what you are after although I suspect not.

No, they define the actual search path.

When you use "require" the package.path defines where the source
will be loaded from. Which part of the package.path is not recorded.

As an aside, how does one find out the OS file separator (e.g. '/')
from Lua itself?


You cant. (Someone tell me if I am wrong). In 5.1 there nothing Lua does that
needs it ither than the C defined LUA_DIRSEP which is not aptly named.
It will probably be defined as "" for me. You could deduce it from package.path
and package.cpath

Hmmm... that sound pretty good :)

Not sure how I would deduce the separator though. My path look something like this:

package.path: ./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/ init.lua
package.cpath: ./?.so;/usr/local/lib/lua/5.1/?.so

What would be a workable way to identify the separator? Looking at non-alphanumeric characters before the question mark?

or externally define PATH_SEP so you could use
os.getenv'PATH_SEP'

I would prefer to have everything pretty much self-contained.

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/