[fpc-pascal] constant records as default parameters

David Emerson dle3ab at angelbase.com
Thu Dec 30 20:40:33 CET 2010


I'd like to use a constant record as a default parameter. Is there some way to 
do this? Here's my use case:

type
  lt_ints = record
    left, top : longint;
    end;

const
  lt_zero : lt_ints = (left:0; top:0);

procedure do_something (const offset_lt : lt_ints = lt_zero);


The procedure declaration gives an error ("illegal expression").

I assume the trouble is that lt_zero cannot be used as a default parameter 
value, because it is not truly a constant: it is an initialized variable.

Perhaps my real question is: how do I make a constant record which is truly 
constant, rather than an initialized variable?

Thoughts?

Thanks :-)
~David.




More information about the fpc-pascal mailing list