rxi / lurker

Auto-swaps changed Lua files in a running LÖVE project
MIT License
280 stars 27 forks source link

check for existing 'lume' module #2

Closed ryanc-me closed 10 years ago

rxi commented 10 years ago

I'm a bit confused as to the purpose of this change. Would you be able the explain what the change achieves? Thanks.

josefnpat commented 10 years ago

The conditional syntax:

local lume = lume or require "lume"

boils down to this logic:

if lume == nil then
    lume = require "lume"
end

So that if you've used lume elsewhere in the project, you just use that instance, instead of a new one.

rxi commented 10 years ago

Perhaps I should have clarified: I wasn't struggling with the syntax, but rather the intent.

I'm still not seeing the purpose. This seems to be disregarding the caching-functionality of require all together, for example, the following:

a = require "lume"
b = require "lume"
print(a == b)

will print true, as the table returned by require is identical each time (assuming its entry in the package.loaded table has not been altered manually)