From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29069 invoked by alias); 10 Nov 2010 17:30:42 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28405 Received: (qmail 28795 invoked from network); 10 Nov 2010 17:30:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: pass (proxy.melb.primenet.com.au: SPF record at spf-1.redhat.com designates 209.132.183.28 as permitted sender) Message-ID: <4CDAD6BA.1020902@redhat.com> Date: Wed, 10 Nov 2010 10:30:34 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.6 MIME-Version: 1.0 To: Bart Schaefer CC: zsh-workers@zsh.org Subject: Re: static vs. dynamic scoping References: <4CD9C64E.8060307@redhat.com> <101110092252.ZM6257@torch.brasslantern.com> In-Reply-To: <101110092252.ZM6257@torch.brasslantern.com> X-Enigmail-Version: 1.1.2 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig4510B32F0D21DD11260C0EAB" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 --------------enig4510B32F0D21DD11260C0EAB Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 11/10/2010 10:22 AM, Bart Schaefer wrote: > One additional thought on this ... >=20 > Zsh does have the "-g" option of "typeset" to allow one declare or > to change the properties of a variable that is not in the scope of > the current function. However, "-g" doesn't really mean "global"; > it means only "the nearest dynamic scope where this variable is > already declared" which is the global scope if the parameter has > never been declared, but might even be the current scope if there > has previously been a "local" delcaration of the variable. >=20 > Does ksh93 have any mechanism for explicitly declaring a variable to > be global from inside a function scope? I'm not that familiar with ksh93; you'd have to ask David Korn for precise details. But my understanding is that with static scoping, every variable reference which was not explicitly declared local is inherently global, because there are no other scopes to worry about. That is (assuming ksh were to support local scoping with posix syntax functions): f () { a=3D1 # modify the global variable a typeset a; a=3D2 # modify the function-local a } a=3D0; f; echo $a # outputs 1 --=20 Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enig4510B32F0D21DD11260C0EAB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJM2ta6AAoJEKeha0olJ0NqSaoH/jUEOyCWvOOsAF7xflsy23P3 DDr0+uwKYr6eTuriYyAFmc88GKwLSkykFaXTFSlVCHjo3EEHQjyg1btXwM42C4Vr r9TpvFpiV7ZPbrl/PSm7h1A5k7UVnR1hFNifaj45xNoGuTCxpRrUUBp8wYC436jq 20XhlzgMdsOSii4nB0jHy9441Sb8cmEfeU8vOo38KZ1dTFWpZEkFrWIwCJYlL/bK NeqPekrr20IBedjIoMKCiktF9ucCpYTrVnKiljiRV/YxT4ZVu5A+BW8oNGsajdGj qPB97fG+ryrOxnfRihscUF0conpfSbQF0Z3sFpuB/b/bT10j03RrOjpip4u6uCw= =QoTg -----END PGP SIGNATURE----- --------------enig4510B32F0D21DD11260C0EAB--