[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: loadstring vs load
- From: David Manura <dm.lua@...>
- Date: Wed, 8 Dec 2010 23:30:34 -0500
On Wed, Dec 8, 2010 at 6:29 AM, Roberto Ierusalimschy
>> Is there still a good reason to continue using loadstring?
>> Is it scheduled for deprecation?
> Probably it will be.
It would be possible to deprecate load as well, in favor of loadin. I
wonder why 5.2-alpha didn't redefine load as such:
load (ld [, source [, env, [, mode]]])
A function like the following has already made it into my standard library:
function loadfilein(filename, env) -- note: could add mode and
chunkname to this as well
local fh, err = io.open(filename, 'rb')
if not fh then return nil, err end
local func, err = loadin(env, fh:lines(4096), filename)
if not func then return nil, err end