Re: lua source as config file
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: lua source as config file
- From: PA <petite.abeille@...>
- Date: 2007年2月10日 14:54:20 +0100
On Feb 08, 2007, at 23:46, Doug Rogers wrote:
PA wrote:
function config( aPath )
local aChunck = setfenv( loadfile( aPath ), {} )
return getfenv( aChunck, aChunck() )
end
Thoughts?
I like this. The only drawback is that in operational code you will
have
to catch any errors raised by loadfile(). It also makes config()
unusable after such an error...
Hmmm... yes... very unfortunate... but as Roberto mentioned somewhere
else in this thread... a well placed assert should prevent such a
disaster:
function config( aPath )
local aChunk = setfenv( assert( loadfile( aPath ) ), {} )
return getfenv( aChunk, aChunk() )
end
- References:
- Re: lua source as config file, Glenn Maynard
- Re: lua source as config file, gary ng
- Re: lua source as config file, Luiz Henrique de Figueiredo
- Re: lua source as config file, George Petsagourakis
- Re: lua source as config file, Luiz Henrique de Figueiredo
- Re: lua source as config file, George Petsagourakis
- Re: lua source as config file, PA
- Re: lua source as config file, Luiz Henrique de Figueiredo
- Re: lua source as config file, PA
- Re: lua source as config file, Doug Rogers