lua-users home
lua-l archive

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


On Wed, Dec 8, 2010 at 6:29 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> Is there still a good reason to continue using loadstring?
> No.
>> 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)
    fh:close()
    if not func then return nil, err end
    return func
  end