Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-02-01 Thread Jochem Maas
Roman Neuhauser wrote: ... > > Singleton in Design Patterns, p. 127: > > : Intent > : Ensure a class only has one instance, and provide a global point of > : access to it. > > The second part is IMO pretty much what you said. it's completely out of context: a, there is no suggestion

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-02-01 Thread Németh Zoltán
On cs, 2007-02-01 at 10:53 -0500, Robert Cummings wrote: > On Thu, 2007-02-01 at 16:42 +0100, Roman Neuhauser wrote: > > > > If PHP was statically typed, global variables would still be a bad > > smell. They are bad smell in C++ and Java, for example. It's too easy > > to call getfoo() before you

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-02-01 Thread Robert Cummings
On Thu, 2007-02-01 at 16:42 +0100, Roman Neuhauser wrote: > > If PHP was statically typed, global variables would still be a bad > smell. They are bad smell in C++ and Java, for example. It's too easy > to call getfoo() before you have set up $foo. The risk grows > exponentially: as soon as you

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-02-01 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-02-01 15:46:39 +0100: > Roman Neuhauser wrote: > > # [EMAIL PROTECTED] / 2007-02-01 02:26:09 +0100: > >> Roman Neuhauser wrote: > >>> # [EMAIL PROTECTED] / 2007-01-31 19:41:42 +0100: > instead I would suggest that your better off doing one of 2 things: > >

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-02-01 Thread Jochem Maas
Roman Neuhauser wrote: > # [EMAIL PROTECTED] / 2007-02-01 02:26:09 +0100: >> Roman Neuhauser wrote: >>> # [EMAIL PROTECTED] / 2007-01-31 19:41:42 +0100: instead I would suggest that your better off doing one of 2 things: 1. pass in the array to the function explicitly. 2. use a

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-02-01 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-02-01 02:26:09 +0100: > Roman Neuhauser wrote: > > # [EMAIL PROTECTED] / 2007-01-31 19:41:42 +0100: > >> instead I would suggest that your better off doing one of 2 things: > >> > >> 1. pass in the array to the function explicitly. > >> 2. use a special function that can

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-01-31 Thread Jochem Maas
speedy wrote: > Hello Jochem, > > Wednesday, January 31, 2007, 7:41:42 PM, you wrote: > >> use of 'global' is bad practice in anything that resembles a complex/real >> application. your function has no control over the what $arr is and any >> piece of >> code code change $arr into *anything* at

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-01-31 Thread Jochem Maas
Roman Neuhauser wrote: > # [EMAIL PROTECTED] / 2007-01-31 19:41:42 +0100: >> instead I would suggest that your better off doing one of 2 things: >> >> 1. pass in the array to the function explicitly. >> 2. use a special function that can be called to retrieve the array >> from within your example f

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-01-31 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-31 19:41:42 +0100: > instead I would suggest that your better off doing one of 2 things: > > 1. pass in the array to the function explicitly. > 2. use a special function that can be called to retrieve the array > from within your example function. > > bad advice? I'm

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-01-31 Thread Jochem Maas
speedy wrote: > Hello Martin, > > Wednesday, January 31, 2007, 4:50:22 PM, you wrote: > >> There is nothing wrong with the global keyword, just use $GLOBAL >> ['arr'] instead to avoid the reference, or create a copy by >> assignment. > > Yep, already did, 10x for the suggestion. :) > >> Anyway,

Re: [PHP] nested, referenced foreach & implicit current array pointer issues

2007-01-30 Thread Martin Alterisio
2007/1/30, speedy <[EMAIL PROTECTED]>: Hello PHP crew, As a followup to: http://bugs.php.net/bug.php?id=22879 That's not a bug, just an user doing things the wrong way and blaming the language. I've stumbled upon this problem in a way: function f() { global $arr; foreach($arr as $