[fpc-pascal] Constants in generics

Sven Barth pascaldragon at googlemail.com
Tue Nov 27 14:08:56 CET 2018

Am Di., 27. Nov. 2018, 12:03 hat Mattias Gaertner via fpc-pascal <
fpc-pascal at lists.freepascal.org> geschrieben:

> On Tue, 27 Nov 2018 11:35:22 +0100
> Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> >[...]
> > > const
> > >         kSomeDays:TDays = [Mon, Wed];
> >[...]
> > The difference between typed and untyped constants are available
> > everywhere else in the language as well, so I have no qualms (at
> > least for now?) to error out on them.
> What about
> {$WritableConst off}
> const kSomeDays:TDays = [Mon, Wed];
> ?
> BTW, how do you name this? "proper typed const"?

For the compiler it makes no difference whether a typed const is writable
or not. A typed const is a typed const and can't be used for some things
that untyped consts can be used for.

One further difference: untyped consts might not even be part of the
binary's data section in case of ordinal, float or set consts as they
simply become part of the code section. Typed consts always reside in the
data section.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20181127/16f75463/attachment.html>

More information about the fpc-pascal mailing list