1.2 Comments

Free Pascal supports the use of nested comments. The following constructs are valid comments:
(* This is an old style comment *)  
{  This is a Turbo Pascal comment }  
// This is a Delphi comment. All is ignored till the end of the line.

The following are valid ways of nesting comments:

{ Comment 1 (* comment 2 *) }  
(* Comment 1 { comment 2 } *)  
{ comment 1 // Comment 2 }  
(* comment 1 // Comment 2 *)  
// comment 1 (* comment 2 *)  
// comment 1 { comment 2 }

The last two comments must be on one line. The following two will give errors:

 // Valid comment { No longer valid comment !!  
    }

and

 // Valid comment (* No longer valid comment !!  
    *)

The compiler will react with a 'invalid character' error when it encounters such constructs, regardless of the -So switch.

Difference between Turbo and Free

I found out the lines like this:
{write(x); {for debugging}
work in Turbo Pascal (because it ignores all text between '{' and the next '}'), but in Free Pascal they produce the compiler-error "unexpected end of file" (and cursor at the end of your program), so if you port your old Turbo-Pascal programs and encounter the same problem, look out for comments like this !
(@ the people more involved in this project: perhaps this should be posted also at some other place, that people, who encounter that compiler-error, find the solution for their problem quickly !)

-- Unregistered Visitor on May 16, 2007 12:13 PM (view details)