lua-users home
lua-l archive

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


Let me add a question, which one is better according to the use case? better: faster, less memory footprint, vs. better: more convenient, less prone to errors.

Blessings.

On Thu, Jun 24, 2010 at 1:47 AM, mos <mmosquito@163.com> wrote:
I know, should not add ".lua" when use require, it is my silly fault.
very sorry for bother you.

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


> but require also looks in the current working directory
>
> I find a way to solve this
>
> use require "..\\a\\a"  ok
> while require "..\\a\\a.lua" error
>
> very confuse about this.
>
> ----- Original Message -----
> From: "HyperHacker" <hyperhacker@gmail.com>
> To: "Lua list" <lua@bazar2.conectiva.com.br>
> Sent: Thursday, June 24, 2010 2:21 PM
> Subject: Re: require vs dofile (lua 5.1.4 windows)
>
>
> On Thu, Jun 24, 2010 at 00:13, mos <mmosquito@163.com> wrote:
>> 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
>>
>
> require() looks in the paths in package.path and package.cpath, while
> dofile() looks in the current working directory. See
> http://www.lua.org/manual/5.1/manual.html#pdf-require
>
> --
> Sent from my toaster.



--
Fernando P. García, http://www.develcuy.com
+51 1 9 8991 7871, Calle Santa Catalina Ancha #377, Cusco - Perú

** Before printing this message, please consider your commitment with the environment, taking care of it depends on you.
** Antes de imprimir este mensaje piensa en tu compromiso con el medio ambiente, protegerlo depende de tí.