Vinzent Hoefler a écrit :
On Thursday 17 April 2008 17:53, mm wrote:
Rodrigo Palhano a écrit :
On Tue, 15 Apr 2008 19:39:37 -0300, Zaher Dirkey <[EMAIL PROTECTED]>
wrote:
I use GO TO when teaching pascal, but after all i ask them to not
use it, it
just a bridge to learning the logic of programming language.
There is another word i hate to use it it is EXIT.
I also understand EXIT as a bad programming practice, it makes life
harder for code readers.
I don't ;-) Even Ada has an "Exit" instruction which one is better
than the Pascal one because, with Ada, "Exit" is a keyword.
Careful. Ada's "exit" is not Pascal's "exit", it's much more like
Pascals "break" (and thus shares the same deficiences when it comes to
the possibility of obfuscated control structures, but can be even
worse).
What Pascal programmers know as "exit" is called "return" in Ada
Yes, of course :-) Now, I don't quite agree with you with what you call
obfuscated control structures. I find the Ada "Break" (which is called
"exit") very handy. In order to do the same with Pascal, not taking in
account some sub-optimal Standard Pascal fanatic method, one has to use
a goto.
For instance, the Ada code
for i in imin .. imax loop
J_LOOP:
for j in jmin .. jmax loop
for k in kmin .. kmax loop
exit J_LOOP when <some test>;
DoSomething;
end loop;
end loop J_LOOP;
end loop;
is equivalent to
for i := imin to imax do
begin
for j := jmin to jmax do
for k := kmin to kmax do
begin
if <some test> then goto EndJLoop;
DoSomething;
end;
EndJLoop:
end;
but I prefer the Ada code.
mm
----
http://www.ellipsa.net/
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal