lua-users home
lua-l archive

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


On 09/09/12 16:59, marbux wrote:
[...]
> strToLoad = "goto strLabelText"
>   load(strToLoad)
[...]

This won't work. Labels are lexical objects, and lexical scope isn't
imported into a load() function --- the goto you're trying to compile
here can't see the scope in which the label is defined.

Here's a complete example:

---snip---
::label::

local s = "goto label"
local c, e = load(s)
print(c, e)
---snip---

This will emit this:

nil	[string "goto label"]:1: no visible label 'label' for <goto> at line 1

(Looking at your code, you seem to be calling load() but then not doing
anything with the result. load() doesn't *run* code, it merely compiles
it --- it returns a function which you then have to call. I suspect
you're being misled by this, as you're discarding the error which tells
you the compilation has failed, and so the result is a noop.)

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ }
│ --- Conway's Game Of Life, in one line of APL

Attachment: signature.asc
Description: OpenPGP digital signature