the following code is excerpted from an lua file, say file0.lua
local Tags = require('file1')
local Set = require('file2')
local Guidance = {}
highway_classes = {
motorway = road_priority_class.motorway,
motorway_link = road_priority_class.motorway_link,
trunk = road_priority_class.trunk,
trunk_link = road_priority_class.trunk_link,
primary = road_priority_class.primary,
primary_link = road_priority_class.primary_link,
secondary = road_priority_class.secondary,
secondary_link = road_priority_class.secondary_link,
tertiary = road_priority_class.tertiary
}
I have searched through the two required files, i.e., file1 and file2. I did not find any mention of road_priority_class anywhere. I did find it in another lua file, say file3.lua. But this file3.lua is not required at all in file0.lua. I was wondering, do you happen to know under what scenario would this be possible? I'm new to Lua and the code I'm working on is embedded in c++ environment, I guess that would be the reason. Any comments are greatly appreciated.
If
road_priority_classis a global variable, then it's available anywhere from the moment it has been declared (i.e. the file is required anywhere)The main reason why you shouldn't normally do this is precisely because it makes it hard to track where things come from and breaks modularity.