Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-10

Some pascal enhancement

4 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aleksey V. Vaneev

Hello,

  Dunno if it's actual, but I think it is a good idea to add parameter
  to break; and continue; instructions. Like break (2); or continue
  (3);
  In my practice I've had some problems with several nested while ()
  and for() loops. One always needs to have some boolean variable to
  signal exiting from main loop.
  while (smth) do
   begin
    for i := 1 to 20 do
     if (smth2) then
       break; // HERE it is wiser in fact to break upper while() statement
   end;

Best regards,
Aleksey

Reply by email

Peter Vreman
Aleksey V. Vaneev wrote: > to break; and continue; instructions. Like break (2); or continue > (3); What is the mean, using goto and labels solves this problem. Labels in pascal is a bad

style, but who can say that these

"many-storied" breaks would be better? IMHO, "pretty programming style" should not be an

end in itself: effectivity of

solution of concrete problem is more important.

I agree here that using goto and a label is much nicer and creates less errors. Because adding an extra loop would require you to adjust all the continue(2) to continue(3), and forgetting one is easily done as it doesn't trigger a compiler error/warning

Reply by email

Pavel V. Ozerski
to Aleksey V. Vaneev: Dunno if it's actual, but I think it is a good idea to add parameter to break; and…
Aleksey V. Vaneev wrote
to break; and continue; instructions. Like break (2); or continue (3);

What is the mean, using goto and labels solves this problem. Labels in pascal is a bad style, but who can say that these "many-storied" breaks would be better? IMHO, "pretty programming style" should not be an end in itself: effectivity of solution of concrete problem is more important.

Sincerely, Pavel

Reply by email

Michael Van Canneyt
to Peter Vreman: style, but who can say that these end in itself: effectivity of I agree here that using…
Peter Vreman wrote 12 lines
> Aleksey V. Vaneev wrote: > > to break; and continue; instructions. Like break (2); or continue > > (3); > What is the mean, using goto and labels solves this problem. Labels in pascal is a bad style, but who can say that these > "many-storied" breaks would be better? IMHO, "pretty programming style" should not be an end in itself: effectivity of > solution of concrete problem is more important. I agree here that using goto and a label is much nicer and creates less errors. Because adding an extra loop would require you to adjust all the continue(2) to continue(3), and forgetting one is easily done as it doesn't trigger a compiler error/warning

Not to mention that Break/Continue are ugly constructs, which can be easily removed by making your 'for' a 'while' or 'repeat', and adapting the while/repeat condition.

Michael.

Reply by email