Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-28 Thread Adam Harvey
On 28 June 2011 18:08, Dave Ingram wrote: > So what about modifying the loop syntax slightly, to explicitly scope a > variable in a foreach? Or would this be problematic/counter-intuitive too? > > foreach ($abc as var $def) { > } > > and > > foreach ($abc as var &$def) { > } PHP's scoping behavio

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-28 Thread Dave Ingram
On 06/23/11 21:48, John Crenshaw wrote: >> I think proposed change is extremely counter intuitive to the design >> of PHP in regard to scoping and would be a very large bc break, PHP is >> doing exactly what it is suppose to do here and I wouldn't want it any >> other way. > Agreed. Although I gene

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-26 Thread David Muir
>> personally I find that weird, and unintuitive, but changin that in a major >> or minor version could be changed if we chose to. > I think it's a behaviour that could be changed in some step like from > 5.3 to 5.4 or so. Personally I don't think it would influence existing > implementations much

RE: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread John Crenshaw
-Original Message- From: Derick Rethans [mailto:der...@php.net] > On Thu, Jun 23, 2011 at 8:49 AM, Martin Scotta wrote: > > I think proposed change is extremely counter intuitive to the design > of PHP in regard to scoping and would be a very large bc break, PHP is > doing exactly wha

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Derick Rethans
On Thu, 23 Jun 2011, Chris Stockton wrote: > On Thu, Jun 23, 2011 at 8:49 AM, Martin Scotta wrote: > >  Martin Scotta > >> > > foreach ($values as $value) { > >  // use $value > > } > > unset ($value); // <-- unset done inside core > > > > foreach ($values as $key => $value) { > >  // use $key an

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Martin Scotta
Martin Scotta On Thu, Jun 23, 2011 at 12:27 PM, Stefan Neufeind wrote: > On 06/23/2011 05:17 PM, Anthony Ferrara wrote: > > Personally, I don't care for the concept of a block scope. I do > > understand that it can have benefits and make certain tasks easier. > > But it can also lead to weird

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Anthony Ferrara
> You can always argue that creating smaller methods (like "no methods > with more than 100 lines" or so) would limit the problems of a forgotten > (not unset()) reference-variable. But imho that's not the point. It is the point. Should we support a feature that will not help those who are follow

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Chris Stockton
Hello, On Thu, Jun 23, 2011 at 8:49 AM, Martin Scotta wrote: >  Martin Scotta >> > foreach ($values as $value) { >  // use $value > } > unset ($value); // <-- unset done inside core > > foreach ($values as $key => $value) { >  // use $key and $value > } > unset ($key, $value); // <-- unset done i

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Stefan Neufeind
On 06/23/2011 05:17 PM, Anthony Ferrara wrote: > Personally, I don't care for the concept of a block scope. I do > understand that it can have benefits and make certain tasks easier. > But it can also lead to weird bugs and inconsistencies. For example, > take the following code: > > $good = fal

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Martin Scotta
Martin Scotta On Thu, Jun 23, 2011 at 12:12 PM, Paul Dragoonis wrote: > On Thu, Jun 23, 2011 at 4:09 PM, Ferenc Kovacs wrote: > > > On Thu, Jun 23, 2011 at 5:03 PM, Stefan Neufeind > wrote: > > > > > Hi, > > > > > > I've lately discussed with a colleague which scopes of variables exist > > >

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Stefan Neufeind
On 06/23/2011 05:09 PM, Ferenc Kovacs wrote: > On Thu, Jun 23, 2011 at 5:03 PM, Stefan Neufeind wrote: > >> I've lately discussed with a colleague which scopes of variables exist >> for PHP or would probably make sense. In general I think the general >> idea of having variables available all thro

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Anthony Ferrara
Personally, I don't care for the concept of a block scope. I do understand that it can have benefits and make certain tasks easier. But it can also lead to weird bugs and inconsistencies. For example, take the following code: $good = false; foreach ($array1 as $value) { $good = $good & $val

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Martin Scotta
Martin Scotta On Thu, Jun 23, 2011 at 12:09 PM, Ferenc Kovacs wrote: > On Thu, Jun 23, 2011 at 5:03 PM, Stefan Neufeind wrote: > > > Hi, > > > > I've lately discussed with a colleague which scopes of variables exist > > for PHP or would probably make sense. In general I think the general > >

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Paul Dragoonis
On Thu, Jun 23, 2011 at 4:09 PM, Ferenc Kovacs wrote: > On Thu, Jun 23, 2011 at 5:03 PM, Stefan Neufeind wrote: > > > Hi, > > > > I've lately discussed with a colleague which scopes of variables exist > > for PHP or would probably make sense. In general I think the general > > idea of having var

Re: [PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Ferenc Kovacs
On Thu, Jun 23, 2011 at 5:03 PM, Stefan Neufeind wrote: > Hi, > > I've lately discussed with a colleague which scopes of variables exist > for PHP or would probably make sense. In general I think the general > idea of having variables available all throughout a function is okay as > this allows t

[PHP-DEV] Variable scopes for language constructs (foreach, ...)

2011-06-23 Thread Stefan Neufeind
Hi, I've lately discussed with a colleague which scopes of variables exist for PHP or would probably make sense. In general I think the general idea of having variables available all throughout a function is okay as this allows things like foreach($vals as $v) { // ... $found = true; } if($fo