Sign in Join

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

Mailing lists / fpc-pascal / 2023-12

More syntax questions (part 4)

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Adriaan van Os

More questions about the FreePascal Language Reference (version 3.2.0), part 4

34. Are macpas LEAVE and CYCLE statements undocumented ?

35. Are macpas ellipsis (...) parameters undocumented ?

36. Is the macpas RETURN statement undocumented ?

37. Shouldn't the macpas "mwpascal" modifier be added to ?

call-modifiers = "register" | "cdecl" | "pascal" | "stdcall" | "safecall" | "inline" | "mwpascal" . call-modifiers = "cdecl" | "inline" | "local" | "nostackframe" | "overload" | "pascal" | "register" | "safecall" | "saveregisters" | "softfloat" | "stdcall" | "varargs" | "mwpascal".

38. Is a <constref-parameter> rule missing ?

constref-parameter = "CONSTREF" identifier-list [ ":" [ "ARRAY" "OF" ] type-identifier ] .

where

parameter-declaration = value-parameter | variable-parameter | out-parameter | constant-parameter | out-parameter | constref-parameter .

39. Section 16.7 defines a rule <library> and a rule <exports-clause>

library = library-header ";" [ uses-clause ] block "." . exports-clause = "exports" exports-list ";" .

The exports-clause rule however doesn't seem to be referenced anywhere in the syntax, so it may have to be added to the <library> rule ?

40. < recordoperator-definition> = <record-operator-definition> ?

41. Is it correct that <operator-definition> is referenced only in the record <component-list> rule ? I would expect something like an <operator-declaration-part> in various declaration rules.

(to be continued)

Adriaan van Os

Michael Van Canneyt
to Adriaan van Os
Adriaan van Os wrote 5 lines
More questions about the FreePascal Language Reference (version 3.2.0), part 4 34. Are macpas LEAVE and CYCLE statements undocumented ?

Yes.

35. Are macpas ellipsis (...) parameters undocumented ?

Yes.

36. Is the macpas RETURN statement undocumented ?

Yes.

Show quoted text 8 lines
37. Shouldn't the macpas "mwpascal" modifier be added to ? call-modifiers = "register" | "cdecl" | "pascal" | "stdcall" | "safecall" | "inline" | "mwpascal" . call-modifiers = "cdecl" | "inline" | "local" | "nostackframe" | "overload" | "pascal" | "register" | "safecall" | "saveregisters" | "softfloat" | "stdcall" | "varargs" | "mwpascal".

Yes. There are even more.

Show quoted text 10 lines
38. Is a <constref-parameter> rule missing ? constref-parameter = "CONSTREF" identifier-list [ ":" [ "ARRAY" "OF" ] type-identifier ] . where parameter-declaration = value-parameter | variable-parameter | out-parameter | constant-parameter | out-parameter | constref-parameter .

Yes.

Show quoted text 8 lines
39. Section 16.7 defines a rule <library> and a rule <exports-clause> library = library-header ";" [ uses-clause ] block "." . exports-clause = "exports" exports-list ";" . The exports-clause rule however doesn't seem to be referenced anywhere in the syntax, so it may have to be added to the <library> rule ?

To the library rule, but also to the unit rule, because it can also appear in a unit...

40. < recordoperator-definition> = <record-operator-definition> ?

Yes.

41. Is it correct that <operator-definition> is referenced only in the record <component-list> rule ? I would expect something like an <operator-declaration-part> in various declaration rules.

To the best of my knowledge, only records support operator definitions.

The 'operator' chapter handles 'global' operators which are at the level of global functions/procedures.

Michael.

Adriaan van Os
to Michael Van Canneyt
Michael Van Canneyt wrote 9 lines
> 37. Shouldn't the macpas "mwpascal" modifier be added to ? > > call-modifiers = "register" | "cdecl" | "pascal" | "stdcall" | > "safecall" | "inline" | "mwpascal" . > call-modifiers = "cdecl" | "inline" | "local" | "nostackframe" | > "overload" | "pascal" | "register" | "safecall" | "saveregisters" | > "softfloat" | "stdcall" | "varargs" | "mwpascal". Yes. There are even more.

And, according to Appendix D.6 of the Programmer's manual:

7. The cdecl modifier keyword can be abbreviated to C.

in macpas mode.

Regards,

Adriaan van Os

Adriaan van Os
to Michael Van Canneyt: Yes. Yes. Yes. Yes. There are even more. Yes. To the library rule, but also to the unit…
Michael Van Canneyt wrote 11 lines
On Sat, 16 Dec 2023, Adriaan van Os via fpc-pascal wrote: > > More questions about the FreePascal Language Reference (version > 3.2.0), part 4 > > 34. Are macpas LEAVE and CYCLE statements undocumented ? Yes.

Well, according to Appendix D.6 of the Programmer's Manual, CYCLE is equivalent to CONTINUE and LEAVE to BREAK. Contrary to the information presented there, the CYCLE and LEAVE statements have been implemented for macpas mode.

I don't see BREAK and CONTINUE in the syntax diagrams either. I put together some examples (stressing that I am not a proponent of these C constructs).

procedure test;
begin
   while true do leave;
   writeln( 'leave makes true=false');
   while true do break;
   writeln( 'break makes true=false');
   writeln( 'cycle forever');
   while true do begin cycle; leave end;
   writeln( 'continue forever');
   while true do begin continue; break end;
end;
> 36. Is the macpas RETURN statement undocumented ?

In MetroWerks Pascal, we have

return-statement = "RETURN" [ expression ] .

In a procedure the [ expression ] part is skipped, in a function it assigns the function-result and then jumps to the end of the function. In a procedure, it just jumps to the end of the procedure. FreePascal allows RETURN in macpas mode to be used in a function only, so the following compiles only in a function.

  repeat return until false;
   writeln( 'the point of no return');

Ceterum censeo C esse delendam.

Regards,

Adriaan van Os

Michael Van Canneyt
to Adriaan van Os: And, according to Appendix D.6 of the Programmer's manual: 7. The cdecl modifier keyword…
Adriaan van Os wrote 17 lines
Michael Van Canneyt via fpc-pascal wrote: >> 37. Shouldn't the macpas "mwpascal" modifier be added to ? >> >> call-modifiers = "register" | "cdecl" | "pascal" | "stdcall" | >> "safecall" | "inline" | "mwpascal" . >> call-modifiers = "cdecl" | "inline" | "local" | "nostackframe" | >> "overload" | "pascal" | "register" | "safecall" | "saveregisters" | >> "softfloat" | "stdcall" | "varargs" | "mwpascal". > > Yes. There are even more. And, according to Appendix D.6 of the Programmer's manual: 7. The cdecl modifier keyword can be abbreviated to C. in macpas mode.

Added to the docs.

Michael.

Michael Van Canneyt
to Adriaan van Os: Well, according to Appendix D.6 of the Programmer's Manual, CYCLE is equivalent to…
Adriaan van Os wrote 21 lines
Michael Van Canneyt via fpc-pascal wrote: > > > On Sat, 16 Dec 2023, Adriaan van Os via fpc-pascal wrote: > >> >> More questions about the FreePascal Language Reference (version 3.2.0), >> part 4 >> >> 34. Are macpas LEAVE and CYCLE statements undocumented ? > > Yes. Well, according to Appendix D.6 of the Programmer's Manual, CYCLE is equivalent to CONTINUE and LEAVE to BREAK. Contrary to the information presented there, the CYCLE and LEAVE statements have been implemented for macpas mode. I don't see BREAK and CONTINUE in the syntax diagrams either. I put together some examples (stressing that I am not a proponent of these C constructs).

That is because "break" and "continue" as well as leave are not keywords: you can use them as identifiers.

As such they are considered normal procedure calls and are documented in the system unit.

That explains why they're not in the syntax diagrams: when they appear, they are treated as procedure calls.

Michael.