Recent

Author Topic: 'case of' block with changing of selection variable  (Read 698 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2519
    • UVviewsoft
'case of' block with changing of selection variable
« on: December 18, 2023, 08:21:10 pm »
Would be good if changing of 'case' selector will not be allowed:
Code: Pascal  [Select][+][-]
  1. program pp;
  2. var
  3.   n: word;
  4. begin
  5.   n:= 3;
  6.   case n of
  7.     1:
  8.       begin
  9.         n:= 2;
  10.         writeln(n);
  11.       end;
  12.     2:
  13.       begin
  14.         n:= 1;
  15.         writeln(n);
  16.       end;
  17.     3:
  18.       begin
  19.         writeln(n);
  20.       end;
  21.   end;
  22. end.
  23.  
« Last Edit: December 18, 2023, 08:22:45 pm by AlexTP »

cdbc

  • Hero Member
  • *****
  • Posts: 1776
    • http://www.cdbc.dk
Re: 'case of' block with changing of selection variable
« Reply #1 on: December 18, 2023, 08:26:33 pm »
Hi
Hmmmm.... I depend a lot on changeable case selectors in my various simple state-machines ~ oldschool parsers.
I would very much like them to stay the way they are!
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Thaddy

  • Hero Member
  • *****
  • Posts: 16367
  • Censorship about opinions does not belong here.
Re: 'case of' block with changing of selection variable
« Reply #2 on: December 18, 2023, 09:44:59 pm »
Currently a case should always contain an else (even if empty)to avoid warnings. Real warnings, not hints.
Jonas did not correct that after I pointed that out. I mean flatly refused to correct that.
Maybe that is your issue too... Then add to my bug report.
That "feature" was only added for ISO compliance and makes no sense in other modes.

It does not break code, though.
« Last Edit: December 18, 2023, 09:48:40 pm by Thaddy »
There is nothing wrong with being blunt. At a minimum it is also honest.

AlexTP

  • Hero Member
  • *****
  • Posts: 2519
    • UVviewsoft
Re: 'case of' block with changing of selection variable
« Reply #3 on: December 18, 2023, 10:29:02 pm »
Feel free to decline this post, developers. It's only a micro idea.

 

TinyPortal © 2005-2018