mixed comments

Frank Heckenbach ih8mj at fjf.gnu.de
Mon Jun 7 01:11:51 CEST 2010

Rugxulo wrote:

> With apologies if this has already been mentioned. (I don't feel like
> searching the mailing list archives right now, and I haven't checked
> the test suite.) I just thought it was funny / interesting.    ;-)
> {
>   using GPC 20070904 / GCC 3.4.4 via DJGPP
>   (gpc.info) :
>   "GPC's default behaviour is (like BP) not to allow mixed comments"
>   ... except that it allows it by ignoring it, not reporting an error
>   (which is what was implied, or so I thought!)
> }
> { $ extended-pascal} { says "Hello, mixed!" }
> { $ standard-pascal} { says "Hello, mixed!" }
> {GPC default}        { says "Hello" }
> {FPC default}        { says "Hello" }
> program comment(output);
> begin
> write('Hello'); { *) write(', mixed!'); (* } writeln;
> end.

Perhaps the formulation is unclear, but the behaviour is correct. In
default and BP modes, GPC "does not allow" mixed comments, i.e.,
treats "(*" and "*)" in a "{ ... }" comment (and vice versa) as
normal characters and therefore as part of the comment. (This can be
useful to write comments that contain either "*)" or "}", though
"nested-comments" may sometimes be more useful for this, however
this is a GPC extension, not available in BP.)

Therefore it sees one longer command and the program says just
"Hello". The program would also work if you omit either "*)" or

In contrast, in standard Pascal mode, "(*" is completely equivalent
to "{" (and "*)" to "}"), so there are two empty comments, and the
program says "Hello, mixed!". If you omit "(*", the
program becomes invalid, because there is a mismatched "}".


Frank Heckenbach, f.heckenbach at fh-soft.de, http://fjf.gnu.de/, 7977168E
GPC To-Do list, latest features, fixed bugs:
GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE  D101 CD02 4C9D 0FE0 E5E8

More information about the Gpc mailing list