Re: speaking of control structures...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/5/09 8:55 PM, "Clancy" <clancy_1@xxxxxxxxxxxx> wrote:

> On Tue, 05 May 2009 14:13:23 -0400, robert@xxxxxxxxxxxxx (Robert Cummings)
> wrote:
> 
>> On Tue, 2009-05-05 at 13:56 -0400, Tom Worster wrote:
>>> there's a control structure i wish php had: a simple block that you can
>>> ...........
> 
>> But PHP 5.3 introduces goto:
>> 
>> <?php
>> 
>> header:
>> 
>>    if( $something ) ...
>> 
>>    goto body;
>> 
>> body:
>> 
>>    if( $soemthingElse ) ...
>>        goto footer;
>> 
>>    if( $seomthingerElse ) ...
>> 
>>    goto footer;
>> 
>> footer:
>> 
>>    // blah blah blah
>>    goto done;
>> 
>> done;
> 
> I heartily agree. In my opinion 'break' is like a 'goto' without a label. As I
> used to
> tell my students "if I say 'break' the one thing I can be sure of is that you
> will all
> disappear. I had no idea where most of you go, or what you do, and I'm not
> even sure if
> I'll ever see some of you again."
> 
> 'Goto' makes it possible to set up the more complex control sequences you
> sometimes need,
> yet have them clearly defined. For example:
> 
> <?php
> 
> begin: .......
> if ( ... ) { goto error; }
> .......
> if ( .... ) { goto footer; }
> .......
> goto body;
> 
> repeat: ....
> if ( .... ) { goto footer; }
> .......
> if ( ... ) { goto error; }
> 
> body: .........
> if ($error) { goto error; }
> ........
> if (!$error) { goto footer; }
> error: ........
> 
> footer:   ........
> if ( .... ) { goto repeat; }
> ?>
> 
> I find it very difficult to set up sequences like this using if/else if (or
> switches, but
> I don't like them anyway), and have to resort to setting flags and very
> careful
> indentation to make sure that I'm doing what I intended. Unfortunately my
> provider is
> still using PHP 4.something, and I have been too busy to switch to someone
> more
> up-to-date.

clancy, i can't argue with you. my desired usage of break is really just a
cover-up for a goto. i know.

it makes no logical sense but i think i'd sooner adopt oop than gotos. my
mom taught me to program back in the late 70s and early 80s. she was an old
hand. when FORTRAN 4 came out she thought it was the bees knees. when Z80
micros with MS-BASIC came out, she thought they were cute. when turbo pascal
came out on CP/M, she was impressed and taught me to quit using gotos.

so while it makes no logical sense, perhaps you can see that it makes
emotional sense.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux