Recent

Author Topic: MODE ISO, rawbyte string and non local goto  (Read 1875 times)

helbig

  • New Member
  • *
  • Posts: 29
MODE ISO, rawbyte string and non local goto
« on: September 26, 2020, 04:50:37 pm »
Hi,
How do you code to jump out of a procedure which has an implicit exception frame because of the rawByteString? I tried to replace the rawByteString by a string to get rid of the exeption frame. This lets you jump out but want compile within the mode ISO.

goto.p(13,5) Error: Leaving procedures containing explicit or implicit exceptions frames using goto is not allowed

Any other suggestion?
Code: Pascal  [Select][+][-]
  1. {$MODE ISO}
  2. {$Q+}
  3. {$R+}
  4. program gt;
  5.   label 1;
  6.   procedure jump;
  7.   var
  8.     a: integer;
  9.     b: rawbytestring;
  10.   begin
  11.     b := 'nanu';
  12.     writeln('nanu');
  13.     goto 1
  14.   end;
  15. begin
  16.   jump;
  17.   writeln('not jumped!');
  18. 1:
  19. writeln('jumped!')
  20. end.
  21.  

Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
Re: MODE ISO, rawbyte string and non local goto
« Reply #1 on: September 26, 2020, 05:23:14 pm »
Well,
 - rawbytestring is not a known ISO string type (in both! modes, ISO as well as extendedpascal)
- {$implicitExceptions off} see the manual: https://www.freepascal.org/docs-html/current/prog/progsu34.html#x41-400001.2.34

[edit] If I replace it with shortstring it compiles, but that is a bug: ISO has no knowledge of shortstring, it should be just string (with optional length, like string[10] ). ISO has also no knowlegde about AnsiString at all, so {$H-} mode should be assumed in all cases.
« Last Edit: September 26, 2020, 05:44:24 pm by Thaddy »
Specialize a type, not a var.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: MODE ISO, rawbyte string and non local goto
« Reply #2 on: September 26, 2020, 06:09:18 pm »
Hi!

Use a global var  instead of a label:

Code: Pascal  [Select][+][-]
  1.     $MODE ISO}
  2.     {$OVERFLOWCHECK+}
  3.     {$R+}
  4.     {$H-}
  5. program gt;
  6.       var JumpBool: Boolean ;
  7.  
  8.       procedure jump;
  9.       var        a: integer;
  10.                   b: string;
  11.       begin
  12.         b := 'nanu';
  13.         writeln('nanu');
  14.         JumpBool := true;
  15.         exit;
  16.       end;
  17.  
  18.     begin
  19.    jumpbool := false;
  20.       jump;
  21.      if Not Jumpbool  then writeln('not jumped!');
  22.      writeln('jumped!')
  23.     end.
  24.  
     


Winni

helbig

  • New Member
  • *
  • Posts: 29
Re: MODE ISO, rawbyte string and non local goto
« Reply #3 on: September 26, 2020, 06:10:09 pm »
Thanks, Taddy. But your suggestion doesn't solve my problem:
- non-local goto
- mode ISO
- rawbytestring
I want all three of them in one procedure body!
Again the compiler complains:

goto.p(14,5) Error: Leaving procedures containing explicit or implicit exceptions frames using goto is not allowed
I use version 3.2.0, not current.

Code: Pascal  [Select][+][-]
  1. {$MODE ISO}
  2. {$implicitExceptions off}
  3. {$Q+}
  4. {$R+}
  5. program gt;
  6.   label 1;
  7.   procedure jump;
  8.   var
  9.     a: integer;
  10.     b: rawbytestring;
  11.   begin
  12.     b := 'nanu';
  13.     writeln('nanu');
  14.     goto 1;
  15.   end;
  16. begin
  17.   jump;
  18.   writeln('not jumped!');
  19. 1:
  20. writeln('jumped!');
  21. end.
  22.  

Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
Re: MODE ISO, rawbyte string and non local goto
« Reply #4 on: September 26, 2020, 06:52:16 pm »
The non-local goto needs trunk (or maybe fixes)
Rawbytestring etc are simply not part of the standards.
Specialize a type, not a var.

helbig

  • New Member
  • *
  • Posts: 29
Re: MODE ISO, rawbyte string and non local goto
« Reply #5 on: September 26, 2020, 07:03:30 pm »
I know, Thaddy. But my wish list is still open. It is not very urgent, but I am just curious.
Will Extended Pascal allow you to look at the command line? That is, what I needed the RawByteString for.

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: MODE ISO, rawbyte string and non local goto
« Reply #6 on: September 26, 2020, 07:24:52 pm »
you should be able to see the command line via the "ParamStr(0)" Will give you the line..

Is there something I am missing here?

The only true wisdom is knowing you know nothing

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: MODE ISO, rawbyte string and non local goto
« Reply #7 on: September 27, 2020, 01:14:26 am »
Hi!

I found the ISO  paper about Extended Pascal ISO 10206 on my HD. In the attachment because of reading the preface(again) I see no copyright problems to put it in the attachment.


Remarkable Preface:

Code: Text  [Select][+][-]
  1. This online copy of the Extended Pascal standard is provided only as an aid to standardization. In
  2. the case of di erences between this online version and the printed version, the printed version takes
  3. precedence.
  4. Do not modify this document. Do not include this document in another software product. You may
  5. print this document for personal use only. Do not sell this document.
  6. Use this information only for good; never for evil. Do not expose to re. Do not operate heavy
  7. equipment after reading, may cause drowsiness. Do not read under the in uence of alcohol (although
  8. there have been several uncon rmed reports that alcohol actually improves the readability). The
  9. standard is written in English. If you have trouble understanding a particular section, read it again
  10. and again and again... Sit up straight. Eat your vegatables. Do not mumble.
  11. c ISO/IEC 1991
  12.  

Winni

PS.: Attachment is "too big". Welcome to the new millenium to the limit designers!

I attached it to my mail to the german forum:

https://www.lazarusforum.de/viewtopic.php?f=9&t=13146

PPS.: Same problem with very old PDFs: Sometimes copy and paste swallows some chars - as I just see.  And remember. 
« Last Edit: September 27, 2020, 01:39:22 am by winni »

Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
Re: MODE ISO, rawbyte string and non local goto
« Reply #8 on: September 27, 2020, 07:16:38 am »
Most standards are here: http://www.pascal-central.com/standards.html
(these pdf's are not really old, not the years the standards were published,both also come as html, word, postscript and more)
« Last Edit: September 27, 2020, 07:20:12 am by Thaddy »
Specialize a type, not a var.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: MODE ISO, rawbyte string and non local goto
« Reply #9 on: September 27, 2020, 11:28:52 am »
goto.p(14,5) Error: Leaving procedures containing explicit or implicit exceptions frames using goto is not allowed
I use version 3.2.0, not current.

It seems that the compiler does not correctly check against $ImplicitExceptions Off when checking the gotos. Please report a bug.

The non-local goto needs trunk (or maybe fixes)
Rawbytestring etc are simply not part of the standards.

Non local Gotos are supported since 2.6.0.

I know, Thaddy. But my wish list is still open. It is not very urgent, but I am just curious.
Will Extended Pascal allow you to look at the command line? That is, what I needed the RawByteString for.

Extended Pascal does not define anything regarding access to the command line. You need to continue to use FPC's ParamStr and ParamCount, however these return ordinary ShortString in case of mode ISO, so you shouldn't need to use RawByteString anyway.

helbig

  • New Member
  • *
  • Posts: 29
Re: MODE ISO, rawbyte string and non local goto
« Reply #10 on: September 27, 2020, 12:17:17 pm »
Thanks PascalDragon,
The shortstring instead of the rawbytestring solved the problem.
Before asking the forum, I tried string, but in ISO mode the compiler says
goto.p(10,8) Error: Identifier not found "string"
goto.p(10,14) Error: Error in type definition
goto.p(13,14) Error: Can't read or write variables of this type

But fpc accepts rawbytestring and shortstring in ISO mode. Strange.

The command line is one of the examples for binding in the standards document of Extended Pascal.
Greetings,
Wolfgang


PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: MODE ISO, rawbyte string and non local goto
« Reply #11 on: September 27, 2020, 01:20:12 pm »
Thanks PascalDragon,
The shortstring instead of the rawbytestring solved the problem.
Before asking the forum, I tried string, but in ISO mode the compiler says
goto.p(10,8) Error: Identifier not found "string"
goto.p(10,14) Error: Error in type definition
goto.p(13,14) Error: Can't read or write variables of this type

That is strange, cause String should be a defined type for ISO Pascal... Please report a bug.

But fpc accepts rawbytestring and shortstring in ISO mode. Strange.

Because unlike String both RawByteString and ShortString are types provided by the system unit, thus the mode is irrelevant for them.

The command line is one of the examples for binding in the standards document of Extended Pascal.

Hadn't seen that this is provided as an example for the binding. Though the standard didn't show how this might be implemented.

helbig

  • New Member
  • *
  • Posts: 29
Re: MODE ISO, rawbyte string and non local goto
« Reply #12 on: September 27, 2020, 03:20:59 pm »
Character strings are part of ISO Pascal, the identifier "string" is not. So this is not a bug of Free Pascal in ISO Mode. At least if ISO means: Don't accept extensions. If that were true, I couldn't migrate Donald E. Knuth's TeX and METAFONT to Free Pascal.

 

TinyPortal © 2005-2018