[fpc-devel] Variable can not be initialized by named constant

Daniël Mantione daniel.mantione at freepascal.org
Sun Mar 1 18:16:23 CET 2009



Op Mon, 2 Mar 2009, schreef Alexander Klenin:

> Since issue http://bugs.freepascal.org/view.php?id=13256 was marked resolved,
> I think this is quite reasonable to expect this to work.
> The writeability of constants is IMNSHO just an ugly leftover from
> Delphi history,
> and should be disabled in _both_ delphi and objfpc modes:

Making typed constants writeable has been a disputed feature of the 
Borland dialect, I agree with that, but fact of the matter is they are 
writeable and thus cannot form a constant expression. The fact that there 
exists a $J directive does not change this.

There are some estethic arguments against this: allowing them into 
initalization results in a break of the separation between declarations 
and code Pascal has: The declaration suddenly gets an assignment statement 
built-in.

I forsee also practical problems: Procedure initialization code would 
become much more complex. Rather than storing a fixed value in a variable 
one would need to take care of dynamic types, like ansistring management.

Daniël


More information about the fpc-devel mailing list