[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to test for the existence of a 'goto' target label?
- From: David Given <dg@...>
- Date: Sun, 09 Sep 2012 17:27:17 +0100
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