Recent

Author Topic: break, exit, continue sintaxhighlight and documentation  (Read 6957 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: break, exit, continue sintaxhighlight and documentation
« Reply #15 on: August 16, 2017, 05:52:03 pm »
Indeed, for the docs I always do approach Michael via mantis. The wiki is free to edit.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: break, exit, continue sintaxhighlight and documentation
« Reply #16 on: August 16, 2017, 06:43:59 pm »
https://bugs.freepascal.org/view.php?id=32281

He said they are compiler intrisics.
Be mindful and excellent with each other.
https://github.com/cpicanco/

ASerge

  • Hero Member
  • *****
  • Posts: 2242
Re: break, exit, continue sintaxhighlight
« Reply #17 on: August 17, 2017, 01:24:47 am »
Sorry, my bad, only break and continue are reserved words:
https://www.freepascal.org/docs-html/rtl/system/break.html
https://www.freepascal.org/docs-html/rtl/system/continue.html
Strange, but the documentation is wrong. In Delphi docs Break and Continue these are procedures from that perform the necessary actions in the context of the loop. Accordingly, there are no restrictions. In FPC this also, the following code is normally compiled.
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. procedure Test;
  4. var
  5.   i, Break, Continue: Integer;
  6. begin
  7.   Break := 10;
  8.   Continue := 5;
  9.   for i := 0 to Break - 1 do
  10.   begin
  11.     if i = Continue then
  12.       System.Continue;
  13.     if i = Break - 1 then
  14.       System.Break;
  15.   end;
  16. end;
  17.  
  18. begin
  19.   Test;
  20. end.

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: break, exit, continue sintaxhighlight
« Reply #18 on: August 17, 2017, 03:26:22 pm »
Maybe it should not compile. I have a feeling taht the following code is more readable:
Code: Pascal  [Select][+][-]
  1.     program Project1;
  2.      
  3.     procedure Test;
  4.     var
  5.       i : integer;
  6.       EndOfList : integer = 10;
  7.       MustJump: Integer = 5;
  8.     begin
  9.       for i := 0 to EndOfList - 1 do
  10.       begin
  11.         if i = MustJump then
  12.           Continue;
  13.         if i = EndOfList - 1 then
  14.           Break;
  15.       end;
  16.     end;
  17.      
  18.     begin
  19.       Test;
  20.     end.
« Last Edit: August 17, 2017, 03:28:16 pm by cpicanco »
Be mindful and excellent with each other.
https://github.com/cpicanco/

ASerge

  • Hero Member
  • *****
  • Posts: 2242
Re: break, exit, continue sintaxhighlight
« Reply #19 on: August 17, 2017, 05:12:48 pm »
I have a feeling taht the following code is more readable:
My code was not intended for training, it is useless and does not require improvements. It simply demonstrates the ability to use Break and Continue as ordinary identifiers.

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
Re: break, exit, continue sintaxhighlight and documentation
« Reply #20 on: August 17, 2017, 07:34:42 pm »
Hi ASerge, please, don't get me wrong. I was not assuming your code was intended for training. I just wrote training code based on your code. I was trying to make a point not about your code, but your well received results.
Be mindful and excellent with each other.
https://github.com/cpicanco/

 

TinyPortal © 2005-2018