question about This
Brian Andresen
brian at techsoln.com
Mon May 27 17:41:44 PDT 2002
On 5/27/2002 4:44 PM, Matt Neuburg <matt at tidbits.com> wrote:
> local (pta = html.getpagetableaddress());
> script.newscriptobject("return this", @pta^.weirdness);
> return pta^.weirdness()
>
>Now, I claim *that* works when rendering statically but not when rendering
>dynamically. m.
The keyword "this" isn't defined for scripts housed in a local variable.
I don't know why UserLand imposes this restriction, but it's there.
local( scpt )
script.newScriptObject( "return this", @scpt )
dialog.alert( scpt() )
The stack trace from the Go To button shows a label of "anonymous" for
the topmost stack frame, which supports the idea that the kernel simply
doesn't know where "this" is located. This is not actually true; the
kernel *does* know the name of the script. Use:
script.newScriptObject( "on foo() { return 3 }", @scpt )
and
script.newScriptObject( "on foo() { return 3 }; return 4", @scpt )
and
script.newScriptObject( "on scpt() { return 3 }; return 4", @scpt )
to demonstrate that the interpreter knows the script is housed in "scpt".
So the information is there, but we're not allowed to get it.
-Brian
More information about the Frontier-Users
mailing list