Re: [PHP] Re: if elseif elseif elseif....
On Sun, 8 Mar 2009 01:54:22 +0600, le...@phpxperts.net (9el) wrote: >> >> >> They probably thought you couldn't handle the responsibility... and if >> you can't think for yourself then they may be right ;) >> >> > Once we have goto, it's a short slide down a slippery slope to setjmp >> > and longjmp. And thence, the apocalypse. ;-} >> >> Or maybe nirvana is just over the horizon! You can't know until you go >> there. >> >> >> As goto is unconditional it can make endless loop... but I think its been >overcome'd already And YOU can't make an endless lop with braces??? I manage to do it about once a week! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
Daniel Brown wrote: On Sat, Mar 7, 2009 at 15:23, Robert Cummings wrote: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Sat, Mar 7, 2009 at 15:23, Robert Cummings wrote: > > > for( ; ; ) > { > echo "You can make an endless loop in many, many ways.\n"; > } > > ?> -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Sun, 2009-03-08 at 01:54 +0600, 9el wrote: > > > > > > They probably thought you couldn't handle the responsibility... and if > > you can't think for yourself then they may be right ;) > > > > > Once we have goto, it's a short slide down a slippery slope to setjmp > > > and longjmp. And thence, the apocalypse. ;-} > > > > Or maybe nirvana is just over the horizon! You can't know until you go > > there. > > > > > > As goto is unconditional it can make endless loop... but I think its been > overcome'd already Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
> > > They probably thought you couldn't handle the responsibility... and if > you can't think for yourself then they may be right ;) > > > Once we have goto, it's a short slide down a slippery slope to setjmp > > and longjmp. And thence, the apocalypse. ;-} > > Or maybe nirvana is just over the horizon! You can't know until you go > there. > > > As goto is unconditional it can make endless loop... but I think its been overcome'd already
Re: [PHP] Re: if elseif elseif elseif....
On Sat, 2009-03-07 at 11:39 -0500, Paul M Foster wrote: > On Sat, Mar 07, 2009 at 05:52:55AM -0500, Robert Cummings wrote: > > > On Sat, 2009-03-07 at 02:12 -0500, Paul M Foster wrote: > > > On Sat, Mar 07, 2009 at 11:29:41AM +1100, Clancy wrote: > > > > > > > On Fri, 6 Mar 2009 08:53:44 -0500, danbr...@php.net (Daniel Brown) > > > > wrote: > > > > > > > > >On Fri, Mar 6, 2009 at 00:12, Clancy wrote: > > > > > > > > > > > > > > > > > > >Then you'll be happy with the advent of PHP6: > > > > > > > > > >http://php.net/goto > > > > > > > > > > Someone would add gotos to a language *on purpose*?! > > > > The demonization of goto was due to the kind of goto found in older > > languages that would either a) goto an arbitrary line number where line > > numbers might change as new line numbers were needed (who invented that > > concept anyways???). The other was where you might jump willie nillie to > > a globally defined goto label that might appear anywhere in a program > > versus jumping to a goto label within a well defined context. The goto > > added to PHP allows jumping only within the current context... you can't > > jump out of a function or into a function, nor as the help says can you > > jump into a loop, or into a switch statement. What this does is greatly > > simplify some types of coding where you might otherwise have to use > > multi level breaks, or define a temporary variable whose value is > > checked at various breakpoints. Goto resolves these issues by allowing > > jumping directly to a defined label within the context. Additionally, > > implementation of things likes parsers are extremely succinct using goto > > semantics. Goto has a place in languages, just not ad-hoc poorly thought > > out goto. > > My deities (Kernighan and Ritchie) told me not to use it, and I don't > want to offend them. They also told me how to indent my code. ;-} They probably thought you couldn't handle the responsibility... and if you can't think for yourself then they may be right ;) > Once we have goto, it's a short slide down a slippery slope to setjmp > and longjmp. And thence, the apocalypse. ;-} Or maybe nirvana is just over the horizon! You can't know until you go there. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Sat, Mar 07, 2009 at 05:52:55AM -0500, Robert Cummings wrote: > On Sat, 2009-03-07 at 02:12 -0500, Paul M Foster wrote: > > On Sat, Mar 07, 2009 at 11:29:41AM +1100, Clancy wrote: > > > > > On Fri, 6 Mar 2009 08:53:44 -0500, danbr...@php.net (Daniel Brown) wrote: > > > > > > >On Fri, Mar 6, 2009 at 00:12, Clancy wrote: > > > > > > > > > > > > > >Then you'll be happy with the advent of PHP6: > > > > > > > >http://php.net/goto > > > > > > > Someone would add gotos to a language *on purpose*?! > > The demonization of goto was due to the kind of goto found in older > languages that would either a) goto an arbitrary line number where line > numbers might change as new line numbers were needed (who invented that > concept anyways???). The other was where you might jump willie nillie to > a globally defined goto label that might appear anywhere in a program > versus jumping to a goto label within a well defined context. The goto > added to PHP allows jumping only within the current context... you can't > jump out of a function or into a function, nor as the help says can you > jump into a loop, or into a switch statement. What this does is greatly > simplify some types of coding where you might otherwise have to use > multi level breaks, or define a temporary variable whose value is > checked at various breakpoints. Goto resolves these issues by allowing > jumping directly to a defined label within the context. Additionally, > implementation of things likes parsers are extremely succinct using goto > semantics. Goto has a place in languages, just not ad-hoc poorly thought > out goto. My deities (Kernighan and Ritchie) told me not to use it, and I don't want to offend them. They also told me how to indent my code. ;-} Once we have goto, it's a short slide down a slippery slope to setjmp and longjmp. And thence, the apocalypse. ;-} Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Sat, Mar 7, 2009 at 02:12, Paul M Foster wrote: > > Someone would add gotos to a language *on purpose*?! Keep in mind that, unlike BASIC, the PHP implementation of GOTO will go to a label. Don't worry, you don't have to start line programming. (Those of you who read multiple threads on multiple lists will notice that this is probably the fifth time in the last month that the discussion of BASIC has come up and the fifth time it's come to tossing out some BASIC pseudo-code. As an aside, BASIC was developed forty-five years ago this year!) -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Sat, 2009-03-07 at 02:12 -0500, Paul M Foster wrote: > On Sat, Mar 07, 2009 at 11:29:41AM +1100, Clancy wrote: > > > On Fri, 6 Mar 2009 08:53:44 -0500, danbr...@php.net (Daniel Brown) wrote: > > > > >On Fri, Mar 6, 2009 at 00:12, Clancy wrote: > > > > > > > > >Then you'll be happy with the advent of PHP6: > > > > > >http://php.net/goto > > > > Someone would add gotos to a language *on purpose*?! The demonization of goto was due to the kind of goto found in older languages that would either a) goto an arbitrary line number where line numbers might change as new line numbers were needed (who invented that concept anyways???). The other was where you might jump willie nillie to a globally defined goto label that might appear anywhere in a program versus jumping to a goto label within a well defined context. The goto added to PHP allows jumping only within the current context... you can't jump out of a function or into a function, nor as the help says can you jump into a loop, or into a switch statement. What this does is greatly simplify some types of coding where you might otherwise have to use multi level breaks, or define a temporary variable whose value is checked at various breakpoints. Goto resolves these issues by allowing jumping directly to a defined label within the context. Additionally, implementation of things likes parsers are extremely succinct using goto semantics. Goto has a place in languages, just not ad-hoc poorly thought out goto. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Sat, Mar 07, 2009 at 11:29:41AM +1100, Clancy wrote: > On Fri, 6 Mar 2009 08:53:44 -0500, danbr...@php.net (Daniel Brown) wrote: > > >On Fri, Mar 6, 2009 at 00:12, Clancy wrote: > > > >Then you'll be happy with the advent of PHP6: > > > >http://php.net/goto > Someone would add gotos to a language *on purpose*?! Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, 6 Mar 2009 08:58:17 -0600, halip...@gmail.com (haliphax) wrote: >>> >> > I wholeheartedly concur. The first programming language I taught >>> >> > myself was BASIC about 23 years ago. We may never see the inclusion >>> >> > of GOSUB in PHP, but GOTO is certainly worthwhile. >>> >> > >>> >> > >>> >> > Side note: I wrote a BASIC interpreter in PHP about two weeks ago. >>> >> > Talk about fond memories. >>> >> >>> >> QuickBasic (actually QBasic, and then later QuickBasic when my mom >>> >> shelled out the money for me to buy it) was my first language. I >>> >> remember being completely flabbergasted when I found out they packaged >>> >> an interpreter with DOS, and it had been under my nose the whole time. >>> >> I think my first "finished" program was a D&D character generator. >>> >> Basically, just colored and formatted text with the output of 6 or so >>> >> random number generations. >>> >> >>> >> Meemorees... :D >>> > >>> > I did Basic on the TRS-80 and saved my programs to a big clunky audio >>> > tape drive... 1... 2... 3... queue Tedd with rocks :) >>> >>> Oh, I'm not even trying to pretend like I'm half as old as some on >>> this list. I still chew my own food, thank you very much. ;) >>> >>> (All in jest, of course... But some of you are pretty old. Ha!) >> >> I just turned 35... today... that's young by the standards of a 70 year >> old >:) > >Well, I may not be decrepit just yet, but I am by no means a >whippersnapper anymore. Looking at turning 27 this April. I'm sure >some of the more geriatric people in the world still consider me a >kid, but I can look at teenagers now and think, "What the hell are >they doing that for?" Yes, when I went to university the students were young adults. Now they are just kids! When I started programming (in about 1967) I worked for the Commonwealth Scientific and Industrial Research Organisation (CSIRO) in Australia. They had a little computer (a CDC 3200, costing $500,000 and with 32K of 24 bit words of core memory) in each capital city, and a big computer (a CDC 3600, costing $2,000,000 and with 64K of 48 bit words of memory) in Canberra. The little computers filled a large room, and had about 20 people operating them. The big one filled a whole floor, and had about 50 people operating it. I had to enter my programs on punch cards, and a courier would collect them twice a day and take them to Clayton (another site about 10 miles away). Then he would bring back the listings from the previous trip. After the morning run we had about 20 minutes to fix obvious bugs before he collected the next batch, and we had overnight to fix the afternoon run. When I got more ambitious, and started using the big computer, the cards were taken to Clayton where they were transferred to mag tape, which was couriered to the airport and flown to Canberra. The tapes were run overnight, and the listings written back to tapes, which were flown back to Melbourne next morning, taken to Clayton, transferred to paper, and brought back to our site. There was often fog in Canberra, which would close the airport, so if we were lucky we would get three runs in a week. Any trivial change would take a week to debug. We were programming in Fortran, and the I/O support was extremely primitive. You had to specify the format for every value you wished to read - eg F10.3 for a 10 digit floating point number, with three digits after the decimal point, and you had to place the decimal point in a specific column on the card. Despite all this I wrote a complex program for analysing linear electronic circuits. It was effectively an interpreter for my own high-level language. I never understood how subroutines worked, as the concept of stacks had not been developed, and you could jump into or out of loops and even subroutines with impunity. It also had an 'assigned goto' instruction, which was perfect for writing 'write only' software. My program was very simple. It consisted of a loop: Assign initial pointers to switches 1 to 3; Start: read a character; if it's a number { GOTO switch_1; } if it's a punctuation mark { GOTO switch_2; } if it's anything else { GOTO switch_3; } GOTO Start; Initial_switch_1 procedure: . GOTO start; Each time I found something interesting I would assign a new pointer to the appropriate switch. This gave extremely compact code, enabling me to get my complicated program into the ridiculously small memory, but I soon found that it was virtually impossible to debug, as the settings of the switches at any moment depended on the whole previous history. Presumably others made the same discovery, as the assigned goto never appeared on any subsequent computer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, Mar 6, 2009 at 19:29, Clancy wrote: > > Great news! .. Now ALL I have to do is to persuade my host to update from > 4.3.9. (or > maybe switch!) If your host is only using PHP4, you probably should switch because who knows what else they've chosen not to upgrade. Check out the forums at http://www.webhostingtalk.com/ for info on that. Just keep in mind that neither PHP 5.3 (where GOTO actually comes into play --- I typed PHP6 without thinking) nor PHP6 are yet officially released, and aren't likely to be in production anywhere yet. -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, 6 Mar 2009 08:53:44 -0500, danbr...@php.net (Daniel Brown) wrote: >On Fri, Mar 6, 2009 at 00:12, Clancy wrote: >> >> Don't take me too seriously on this. But it riles me that the same peoplewho >> threw out the >> GOTO as being too dangerous could then introduce the break statement which, >> as I said, >> it's like a GOTO without a target. As a long-time assembly programmer, I >> found the >> judicious use of GOTO's made for far clearer code than the mess of nested >> braces I am >> forced to use in PHP. > >Then you'll be happy with the advent of PHP6: > >http://php.net/goto Great news! .. Now ALL I have to do is to persuade my host to update from 4.3.9. (or maybe switch!) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
2009/3/6 haliphax > On Fri, Mar 6, 2009 at 9:08 AM, Stuart wrote: > > 2009/3/6 Robert Cummings > >> > >> I just turned 35... today... that's young by the standards of a 70 year > >> old >:) > > > > Happy Birthday ya wise old git. > > I started with BBC Basic, moved on to gwbasic then to C, and the rest, as > > they say, is history. > > First program I ever wrote was a game called Spider. I created person and > > spider characters (as in patching over existing letters in the standard > > character set), put them on a playing surface and the spider tried to > catch > > the person as they moved around to pick up asterisks. Really simple but > huge > > fun. I was hooked. Still am. > > Is that sort of like Robots, where you try to rescue all the humans, > and the robots take a step towards you every time you move? That was > my first TI-BASIC program, though I wrote it admittedly just two years > ago when I should have been paying attention in Accounting II. :D Sounds similar. My Mum was afraid of spiders and being 8 years old I made something I thought would freak her out. In my recollection it did but thinking about it I'm sure she was just humouring me. -Stuart -- http://stut.net/
Re: [PHP] Re: if elseif elseif elseif....
Robert Cummings wrote: > On Fri, 2009-03-06 at 08:51 -0600, haliphax wrote: > >> On Fri, Mar 6, 2009 at 8:46 AM, Robert Cummings wrote: >> >>> On Fri, 2009-03-06 at 08:38 -0600, haliphax wrote: >>> On Fri, Mar 6, 2009 at 8:19 AM, Daniel Brown wrote: > On Fri, Mar 6, 2009 at 09:15, Robert Cummings > wrote: > >> I remember the internals debate about 2 or 3 years ago. I was on the pro >> goto side... it does have uses when used properly. >> >I wholeheartedly concur. The first programming language I taught > myself was BASIC about 23 years ago. We may never see the inclusion > of GOSUB in PHP, but GOTO is certainly worthwhile. > > >Side note: I wrote a BASIC interpreter in PHP about two weeks ago. > Talk about fond memories. > QuickBasic (actually QBasic, and then later QuickBasic when my mom shelled out the money for me to buy it) was my first language. I remember being completely flabbergasted when I found out they packaged an interpreter with DOS, and it had been under my nose the whole time. I think my first "finished" program was a D&D character generator. Basically, just colored and formatted text with the output of 6 or so random number generations. Meemorees... :D >>> I did Basic on the TRS-80 and saved my programs to a big clunky audio >>> tape drive... 1... 2... 3... queue Tedd with rocks :) >>> >> Oh, I'm not even trying to pretend like I'm half as old as some on >> this list. I still chew my own food, thank you very much. ;) >> >> (All in jest, of course... But some of you are pretty old. Ha!) >> > > I just turned 35... today... that's young by the standards of a 70 year > old >:) > > Cheers, > Rob. > Yeah... wet behind the ears... heh...heh...heh :-P -- unheralded genius: "A clean desk is the sign of a dull mind. " - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, Mar 6, 2009 at 9:08 AM, Stuart wrote: > 2009/3/6 Robert Cummings >> >> I just turned 35... today... that's young by the standards of a 70 year >> old >:) > > Happy Birthday ya wise old git. > I started with BBC Basic, moved on to gwbasic then to C, and the rest, as > they say, is history. > First program I ever wrote was a game called Spider. I created person and > spider characters (as in patching over existing letters in the standard > character set), put them on a playing surface and the spider tried to catch > the person as they moved around to pick up asterisks. Really simple but huge > fun. I was hooked. Still am. Is that sort of like Robots, where you try to rescue all the humans, and the robots take a step towards you every time you move? That was my first TI-BASIC program, though I wrote it admittedly just two years ago when I should have been paying attention in Accounting II. :D -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
2009/3/6 Robert Cummings > I just turned 35... today... that's young by the standards of a 70 year > old >:) Happy Birthday ya wise old git. I started with BBC Basic, moved on to gwbasic then to C, and the rest, as they say, is history. First program I ever wrote was a game called Spider. I created person and spider characters (as in patching over existing letters in the standard character set), put them on a playing surface and the spider tried to catch the person as they moved around to pick up asterisks. Really simple but huge fun. I was hooked. Still am. -Stuart -- http://stut.net/
Re: [PHP] Re: if elseif elseif elseif....
On Fri, Mar 6, 2009 at 8:56 AM, Robert Cummings wrote: > On Fri, 2009-03-06 at 08:51 -0600, haliphax wrote: >> On Fri, Mar 6, 2009 at 8:46 AM, Robert Cummings wrote: >> > On Fri, 2009-03-06 at 08:38 -0600, haliphax wrote: >> >> On Fri, Mar 6, 2009 at 8:19 AM, Daniel Brown wrote: >> >> > On Fri, Mar 6, 2009 at 09:15, Robert Cummings >> >> > wrote: >> >> >> >> >> >> I remember the internals debate about 2 or 3 years ago. I was on the >> >> >> pro >> >> >> goto side... it does have uses when used properly. >> >> > >> >> > I wholeheartedly concur. The first programming language I taught >> >> > myself was BASIC about 23 years ago. We may never see the inclusion >> >> > of GOSUB in PHP, but GOTO is certainly worthwhile. >> >> > >> >> > >> >> > Side note: I wrote a BASIC interpreter in PHP about two weeks ago. >> >> > Talk about fond memories. >> >> >> >> QuickBasic (actually QBasic, and then later QuickBasic when my mom >> >> shelled out the money for me to buy it) was my first language. I >> >> remember being completely flabbergasted when I found out they packaged >> >> an interpreter with DOS, and it had been under my nose the whole time. >> >> I think my first "finished" program was a D&D character generator. >> >> Basically, just colored and formatted text with the output of 6 or so >> >> random number generations. >> >> >> >> Meemorees... :D >> > >> > I did Basic on the TRS-80 and saved my programs to a big clunky audio >> > tape drive... 1... 2... 3... queue Tedd with rocks :) >> >> Oh, I'm not even trying to pretend like I'm half as old as some on >> this list. I still chew my own food, thank you very much. ;) >> >> (All in jest, of course... But some of you are pretty old. Ha!) > > I just turned 35... today... that's young by the standards of a 70 year > old >:) Well, I may not be decrepit just yet, but I am by no means a whippersnapper anymore. Looking at turning 27 this April. I'm sure some of the more geriatric people in the world still consider me a kid, but I can look at teenagers now and think, "What the hell are they doing that for?" -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, 2009-03-06 at 08:51 -0600, haliphax wrote: > On Fri, Mar 6, 2009 at 8:46 AM, Robert Cummings wrote: > > On Fri, 2009-03-06 at 08:38 -0600, haliphax wrote: > >> On Fri, Mar 6, 2009 at 8:19 AM, Daniel Brown wrote: > >> > On Fri, Mar 6, 2009 at 09:15, Robert Cummings > >> > wrote: > >> >> > >> >> I remember the internals debate about 2 or 3 years ago. I was on the pro > >> >> goto side... it does have uses when used properly. > >> > > >> >I wholeheartedly concur. The first programming language I taught > >> > myself was BASIC about 23 years ago. We may never see the inclusion > >> > of GOSUB in PHP, but GOTO is certainly worthwhile. > >> > > >> > > >> >Side note: I wrote a BASIC interpreter in PHP about two weeks ago. > >> > Talk about fond memories. > >> > >> QuickBasic (actually QBasic, and then later QuickBasic when my mom > >> shelled out the money for me to buy it) was my first language. I > >> remember being completely flabbergasted when I found out they packaged > >> an interpreter with DOS, and it had been under my nose the whole time. > >> I think my first "finished" program was a D&D character generator. > >> Basically, just colored and formatted text with the output of 6 or so > >> random number generations. > >> > >> Meemorees... :D > > > > I did Basic on the TRS-80 and saved my programs to a big clunky audio > > tape drive... 1... 2... 3... queue Tedd with rocks :) > > Oh, I'm not even trying to pretend like I'm half as old as some on > this list. I still chew my own food, thank you very much. ;) > > (All in jest, of course... But some of you are pretty old. Ha!) I just turned 35... today... that's young by the standards of a 70 year old >:) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, 2009-03-06 at 08:54 -0500, Daniel Brown wrote: > On Fri, Mar 6, 2009 at 08:53, Daniel Brown wrote: > > > >Then you'll be happy with the advent of PHP6: > > > >http://php.net/goto > > Uhh yeah, and 5.3 before that even. Duh. I remember the internals debate about 2 or 3 years ago. I was on the pro goto side... it does have uses when used properly. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, Mar 6, 2009 at 8:46 AM, Robert Cummings wrote: > On Fri, 2009-03-06 at 08:38 -0600, haliphax wrote: >> On Fri, Mar 6, 2009 at 8:19 AM, Daniel Brown wrote: >> > On Fri, Mar 6, 2009 at 09:15, Robert Cummings wrote: >> >> >> >> I remember the internals debate about 2 or 3 years ago. I was on the pro >> >> goto side... it does have uses when used properly. >> > >> > I wholeheartedly concur. The first programming language I taught >> > myself was BASIC about 23 years ago. We may never see the inclusion >> > of GOSUB in PHP, but GOTO is certainly worthwhile. >> > >> > >> > Side note: I wrote a BASIC interpreter in PHP about two weeks ago. >> > Talk about fond memories. >> >> QuickBasic (actually QBasic, and then later QuickBasic when my mom >> shelled out the money for me to buy it) was my first language. I >> remember being completely flabbergasted when I found out they packaged >> an interpreter with DOS, and it had been under my nose the whole time. >> I think my first "finished" program was a D&D character generator. >> Basically, just colored and formatted text with the output of 6 or so >> random number generations. >> >> Meemorees... :D > > I did Basic on the TRS-80 and saved my programs to a big clunky audio > tape drive... 1... 2... 3... queue Tedd with rocks :) Oh, I'm not even trying to pretend like I'm half as old as some on this list. I still chew my own food, thank you very much. ;) (All in jest, of course... But some of you are pretty old. Ha!) -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, 2009-03-06 at 08:38 -0600, haliphax wrote: > On Fri, Mar 6, 2009 at 8:19 AM, Daniel Brown wrote: > > On Fri, Mar 6, 2009 at 09:15, Robert Cummings wrote: > >> > >> I remember the internals debate about 2 or 3 years ago. I was on the pro > >> goto side... it does have uses when used properly. > > > >I wholeheartedly concur. The first programming language I taught > > myself was BASIC about 23 years ago. We may never see the inclusion > > of GOSUB in PHP, but GOTO is certainly worthwhile. > > > > > >Side note: I wrote a BASIC interpreter in PHP about two weeks ago. > > Talk about fond memories. > > QuickBasic (actually QBasic, and then later QuickBasic when my mom > shelled out the money for me to buy it) was my first language. I > remember being completely flabbergasted when I found out they packaged > an interpreter with DOS, and it had been under my nose the whole time. > I think my first "finished" program was a D&D character generator. > Basically, just colored and formatted text with the output of 6 or so > random number generations. > > Meemorees... :D I did Basic on the TRS-80 and saved my programs to a big clunky audio tape drive... 1... 2... 3... queue Tedd with rocks :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, Mar 6, 2009 at 8:19 AM, Daniel Brown wrote: > On Fri, Mar 6, 2009 at 09:15, Robert Cummings wrote: >> >> I remember the internals debate about 2 or 3 years ago. I was on the pro >> goto side... it does have uses when used properly. > > I wholeheartedly concur. The first programming language I taught > myself was BASIC about 23 years ago. We may never see the inclusion > of GOSUB in PHP, but GOTO is certainly worthwhile. > > > Side note: I wrote a BASIC interpreter in PHP about two weeks ago. > Talk about fond memories. QuickBasic (actually QBasic, and then later QuickBasic when my mom shelled out the money for me to buy it) was my first language. I remember being completely flabbergasted when I found out they packaged an interpreter with DOS, and it had been under my nose the whole time. I think my first "finished" program was a D&D character generator. Basically, just colored and formatted text with the output of 6 or so random number generations. Meemorees... :D -- // Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, Mar 6, 2009 at 09:15, Robert Cummings wrote: > > I remember the internals debate about 2 or 3 years ago. I was on the pro > goto side... it does have uses when used properly. I wholeheartedly concur. The first programming language I taught myself was BASIC about 23 years ago. We may never see the inclusion of GOSUB in PHP, but GOTO is certainly worthwhile. Side note: I wrote a BASIC interpreter in PHP about two weeks ago. Talk about fond memories. -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, Mar 6, 2009 at 08:53, Daniel Brown wrote: > > Then you'll be happy with the advent of PHP6: > > http://php.net/goto Uhh yeah, and 5.3 before that even. Duh. -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, Mar 6, 2009 at 00:12, Clancy wrote: > > Don't take me too seriously on this. But it riles me that the same peoplewho > threw out the > GOTO as being too dangerous could then introduce the break statement which, > as I said, > it's like a GOTO without a target. As a long-time assembly programmer, I > found the > judicious use of GOTO's made for far clearer code than the mess of nested > braces I am > forced to use in PHP. Then you'll be happy with the advent of PHP6: http://php.net/goto -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
On Fri, 06 Mar 2009 10:16:47 +1100, dmag...@gmail.com (Chris) wrote: > >> Rather than encoding all the variable names into one long unwieldy set of >> statements, I >> would put them all into an array, and then use a loop to process the array. >> This way all >> the variable names are together, and the next time you want to enter another >> set of >> variables you can use the same code, but read from a different array. >> >> For example: >> >>$oblig_fields = array('TitleN', 'first_nameN', ''); >>$ok = true; >>$i = 0; while ($i < count($oblig_fields && $ok)) >> { >> if (!isset($_POST[$oblig_fields[$i]]) || ($_POST[$oblig_fields[$i]] == >> '')) >> { >> $ok = false; >> } >> else >> { >> $results[$oblig_fields[$i]] = $_POST[$oblig_fields[$i]]; >> } >> ++$i; >> } >>if (!$ok) { echo 'Scream!!!'; } > >The problem with that is if I miss 5 fields, I have 5 page refreshes to >get to the end & actually successfully submit the form. If you keep an >array of broken entries (per my previous suggestion) you get all the >form fields missed in one go. Easily fixed. Just put: $missing = false; at the start of the loop, and then: $missing[$oblig_fields[$i]] = true; each time you find a missing field. Then the array keys for $missing will tell you which fields you have to fetch again. >I'd just do a foreach instead of a while, count, and counter. > >foreach ($oblig_fields as $field_name) { > if (!isset($_POST[$field_name]) || empty($_POST[$field_name])) { > > } >} > >> I am sure you could use a "break" statement in place of the "$ok = false;" >> above, but I >> have never trusted the break statement. To my mind it is like a GOTO without >> a target. > >Must've been a bad experience ;) Always works for me. Don't take me too seriously on this. But it riles me that the same peoplewho threw out the GOTO as being too dangerous could then introduce the break statement which, as I said, it's like a GOTO without a target. As a long-time assembly programmer, I found the judicious use of GOTO's made for far clearer code than the mess of nested braces I am forced to use in PHP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
Rather than encoding all the variable names into one long unwieldy set of statements, I would put them all into an array, and then use a loop to process the array. This way all the variable names are together, and the next time you want to enter another set of variables you can use the same code, but read from a different array. For example: $oblig_fields = array('TitleN', 'first_nameN', ''); $ok = true; $i = 0; while ($i < count($oblig_fields && $ok)) { if (!isset($_POST[$oblig_fields[$i]]) || ($_POST[$oblig_fields[$i]] == '')) { $ok = false; } else { $results[$oblig_fields[$i]] = $_POST[$oblig_fields[$i]]; } ++$i; } if (!$ok) { echo 'Scream!!!'; } The problem with that is if I miss 5 fields, I have 5 page refreshes to get to the end & actually successfully submit the form. If you keep an array of broken entries (per my previous suggestion) you get all the form fields missed in one go. I'd just do a foreach instead of a while, count, and counter. foreach ($oblig_fields as $field_name) { if (!isset($_POST[$field_name]) || empty($_POST[$field_name])) { } } I am sure you could use a "break" statement in place of the "$ok = false;" above, but I have never trusted the break statement. To my mind it is like a GOTO without a target. Must've been a bad experience ;) Always works for me. It breaks out of the current loop (for, foreach, while - doesn't matter about the loop syntax) or switch and continues executing the code straight after the loop. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: if elseif elseif elseif....
Davi Ramos wrote: > I tought you forgot to initializae the $obligatoryFieldNotPresent variable, > as PHP create variables when they are initialized, the > $obligatoryFieldNotPresent variable is created inside the if. > > $obligatoryFieldNotPresent = 0; > > if (strlen($_POST["titleIN"]) == 0 ) { >$obligatoryFieldNotPresent = 1; >} >elseif (strlen($_POST["first_nameIN"]) == 0 ) { >$obligatoryFieldNotPresent = 1; >} >elseif (strlen($_POST["publisherIN"]) == 0 ) { >$obligatoryFieldNotPresent = 1; >} >elseif (strlen($_POST["copyrightIN"]) == "" ) { >$obligatoryFieldNotPresent = 1; >} >elseif (strlen($_POST["ISBNIN"]) == 0 ) { >$obligatoryFieldNotPresent = 1; >} >elseif (strlen($_POST["languageIN"]) == 0 ) { >$obligatoryFieldNotPresent = 1; >} >elseif (!empty($_POST['categoriesIN'])) { >$obligatoryFieldNotPresent = 0; > } > > It's there, I just didn't include it as it is followed by a lot of stringies: $obligatoryFieldNotPresent = 0; if (isset($_REQUEST["AddNewBooksRequest"])) { $titleIN= $_POST["titleIN"];.snipetysnip... -- unheralded genius: "A clean desk is the sign of a dull mind. " - Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com/andypantry.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php