On 11/10/2010 10:22 AM, Bart Schaefer wrote: > One additional thought on this ... > > 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. > > 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=1 # modify the global variable a typeset a; a=2 # modify the function-local a } a=0; f; echo $a # outputs 1 -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature