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.
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