Re: variables in namespaces, was: On closures and lamdba

From: Date: Wed, 24 Feb 2010 11:20:38 +0000
Subject: Re: variables in namespaces, was: On closures and lamdba
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-47049@lists.php.net to get a copy of this message
On 24.02.2010, at 13:28, Alain Williams wrote: > On Tue, Feb 23, 2010 at 11:01:05PM -0800, Stanislav Malyshev wrote: >> Hi! >> >>> I never did understand *why* variables were not namespaced. >> >> If you have so many global vars you need to namespace them, you should >> not use global vars. > > It is not a question of number -- you may have some module where the > functions need to share a couple of variables between themselves, eg a file handle. > If variables could be private to a namespace then you would be confident that > you would not get a variable name collision with some other, independently developed, > module. > > Objects are not always the answer. in situation, which you described, objects are definitely the answer. you have several functions, which share the same "state". that's very close to the definition of object.

« previous php.internals (#47049) next »