FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » terminate a PHP script
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: terminate a PHP script [message #172601 is a reply to message #172591] Tue, 22 February 2011 03:38 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
sheldonlg wrote:
> On 2/21/2011 8:24 PM, The Natural Philosopher wrote:
>> sheldonlg wrote:
>>> On 2/21/2011 1:54 PM, n00m wrote:
>>>>
>>>> > Again, why not if-then-else?
>>>>
>>>> what if it's 10 nested for() stmts?
>>>> And you need to break out of ALL for()'s from the innermost for()?
>>>> Do you like 10 if-then-else conditionals, 1 per each for()?
>>>
>>> && !$exit_all
>>>
>>> in each of the test conditions of the for loop where $exit_all is
>>> initially FALSE outside the outermost loop.
>>>
>>> for ($i1=0, $exit_all=FALSE; $i1 < $i1_end && !$exit_all; $i1++) {
>>> for ($i2=0; $i2 < $i2_end && !$exit_allt; $i2++) {
>>> ..... // and so on
>>> if ($some_condition == TRUE) {
>>> $exit_all = TRUE;
>>> break; // or continue which does one extra check step
>>> }
>>> }
>>> }
>>>
>>>
>>>
>> I didn't understand a word of that. ;-)
>
> I don't understand why? It is clear as a bell.
>
>> AND you used a BREAK. hanging is too good...
>
> A break is not a goto. Far from it. A break says "stop processing
> _this_ particular loop/test". Its scope is _clearly defined_. It
> resumes immediately after that loop/test. That is nothing like a goto
> which is an unconditional branch to ANYWHERE in the code.
Nope. Not in C it aint. For example. Its a branch to the same scope as
the block IIRC. Or at least the function, because i don't think you can
see the target label outside that scope. And I don't think global labels
can exist - would be a helluva mess on the stack if you DID branch
outside a function. You need longjmp() for that.

Once you introduce local stack based variables you cant use global jumps.

Only BASIC and ASSEMBLER allow that, and all bets are off in either
language if you abuse that privilege.!

I did manage howeer when trying to find another 200bytes in a ROM to
replace every instance of
POP DX
POP AX
RET

with

JMP SPACESAVER

and

SPACESAVER:
POP DX
POP AX
RET

I think it was one byte shorter, or something.


(Also, try
> writing a switch statement without a break.)
>

Exactly.
some form of limited goto is always required: teh questin is how to
wrire it best. After all consider thus staement

if ()
{
}
else...
{
}
what is the else, but a target for a conditional jump? Just because you
didn't write goto, doesn't mean there aint no jump.

In assambler thats a

CMP..something
JNE CURLY
//this is if the condition is met
JMP NEXT_CURLY
//else
CURLY:
//do else block stuff
NEXT_CURLY: // end of final brace.


ALL your precious 'structure' is simply ways of expressing those go tos
in a formal way.

If your languagee is not block structured, and has no local variables,
for sure you can write some utter spaghetti aided and abetted by
GOTOS:But that's merely a case of the language not giving you the tools
to do much else.

The moment you HAVE block structure and local variables you cant allow
GOTS to go very far. In fact as K & R realised, you need to introduce a
pretty fucking weird function pair, setjmp() and longjmp() to be able
to do it at all. Setjmp stores the stack pointer in a variable that you
can use with longjmp, to exit at the same place you called setjmp from
and restore the stack and program counter, and wipe out all the
locals.Its the ONLY way I know of to clean up the mess the jump would
otherwise make.

My point being that a goto in a block structured language merely is
another way to write a curly brace.

I rarely have had call to use it in such, its true. Return continue and
break serve much the same function as do curly braces, but its nice to
know its there, like the gimlet in the drawer next to the power drill,
in case it happens to be the easiest cleanest way to make a particular
hole..
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Extralight browser-webserver communication via cookies (+)
Next Topic: Storing multiple character set types (or a representation of em) in a table column
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Jul 08 21:43:38 GMT 2024

Total time taken to generate the page: 0.06908 seconds