View Single Post
11-16-17, 11:49 AM   #1
mtp1032
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 22
LUA Scoping Semantics

Hello,

I'm a very new to LUA programming (2 full days), tho' I do have an extensive background in C/C++ and Java. Alas, I have run into what appears to be a scoping problem and I'm confused. Here's the problem:

in mylib.lua I have the function definition

Code:
function parseStackTrace()
<lines of code>
end
And in my testing framework, myLibTests.lua, I have


Code:
function runTests()
    local result1, result2, result3 = parseStackTrace( debugstack())
end
When executed, the test fails with the following error message:
attempt to call global 'parseStackTrace' (a nil value)
(ASIDE: I'm using !Swatter)

my .toc file contains these lines
<boiler plate>
myLib.lua
myLibTests.lua
It's clear I'm missing something important and probably familiar to most LUA programmers. So, can someone either explain what's going on or point me to the appropriate documentation?

Cheers,
  Reply With Quote