lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:
> 
> Here is a version of require that works in 4.0:
> 
>         do
>          local A={}
>          function require(x)
>           if %A[x]==nil then %A[x]=1; return %dofile(x) end
>          end
>         end

Btw, what do you think about a slight modification that detects
dependency loops?  (I do that in Sol.)

  if A[x]==nil then
    A[x]=1
    ...dofile...
    A[x]=2
    return results...
  elseif A[x]==1 then
    error("dependency loop")
  end

Ciao, ET.