lua-users home
lua-l archive

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


I should make a summary:
require a  .lua file not use ".lua" because require treat  '.' as '\\' 
when require "a.lua"
the lua will look for "a\lua.lua"
so when use relative path "..\" like require "..\\a\\a" you will never get right path 
the lua will look for \\a\a.lua still in the same dir b

is that a bug ? 
1. It should handle "..", if the prefix is ".." not treat as \\\\
2. (suggestion) if the postfix  is ".lua" not treat '.' as '\\'

and I wish dofile will solved this, but in the a.lua 
will also require another file like 'c'
a 
   a.lua
   c.lua
b 
   b.lua
when use dofile in b.lua like dofile("..\\a\\a.lua") will cause a error can not find c.lua

So I hope solved it.


----- Original Message ----- 
From: "mos" <mmosquito@163.com>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Thursday, June 24, 2010 2:13 PM
Subject: require vs dofile (lua 5.1.4 windows)


> Hi!
>    there are 2 files in 2 fold like:
> a 
>  a.lua
> b 
>  b.lua
> 
> the b.lua use
>  require "..\\a\\a.lua"
> will get a error can not find a.lua
> 
> but use
>  dofile("..\\a\\a.lua")
> will ok
> 
> I don't konw why.
> 
> Best Regard
> yujiang
>