[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Mutual requires
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 20 Dec 2012 12:17:28 +0200
On Thu, Dec 20, 2012 at 11:47 AM, Geoff Leyland
<geoff_leyland@fastmail.fm> wrote:
> function expression.__add(a, b)
> return add:new{a, b} -- I could 'require("add")' it here?
> end
This will work, and keeping a local module ref and setting it if not
already set is probably the most efficient solution:
local add
function expression:__add(a,b)
if not add then add = require 'add' end
return add:new(a,b)
end