lua-users home
lua-l archive

Re: local and global

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


Hello,
 No, what I want is to access x in [level-1], this is the x global to the
block/scope. Example:
 --x = 123 -- _G.x
 function test()
 local x = 123 --< I want to access this
 for i = 0,10 do
 local x = x + i --< [local x] = 246 + i
 if x == 130 then
 [global x ] = x --< [x this level-1] = [local x]
 end
 end
 Thanx,
 Leandro.
----- Original Message -----
From: "Daniel Silverstone" <dsilvers@digital-scurf.org>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Wednesday, October 15, 2003 6:59 AM
Subject: Re: local and global
> On Wed, 2003年10月15日 at 04:22, Leandro Candido wrote:
> > How can I access a global variable after a redeclaration as a local?
Ex:
> > [global x] = -x -- global x = negative of local x
>
> If you *definitely* mean global rather than "local in enclosing scope"
> then...
>
> _G["x"] or just _G.x should do what you want (unless I'm horribly
> mistaken)
>
> D.
>
> --
> Daniel Silverstone http://www.digital-scurf.org/
> Hostmaster, Webmaster, and Chief Code Wibbler: Digital-Scurf Unlimited
> GPG Public key available from keyring.debian.org KeyId: 20687895
>
>

AltStyle によって変換されたページ (->オリジナル) /