[Lazarus] Tooltip shows value of some but not all const items....

Sven Barth pascaldragon at googlemail.com
Sat Jan 2 12:36:06 CET 2021


Am 02.01.2021 um 12:09 schrieb Bo Berglund via lazarus:
> Is there some Lazarus setting that will enable always showing the
> value?

You would probably need to do a feature request for that.

> Another question:
> -----------------
> Is there a difference between the two types of declarations?
> I think that the # specifier of the value also declares the const as a
> char in the first place, or not?

The first is a "untyped constant". It takes its type implicitely from 
the right side and not everything can be a constant (e.g. you can't use 
records). So in your case, yet's it's a Char due to the right side being 
a character constant.

The second is a so called "typed constant". They are essentially 
variables that might be readonly (they are readonly if {$J-} is set 
which is *not* the default). They were originally introduced in Turbo 
Pascal to allow for static variables inside functions (cause that is how 
they behave).

The main difference is that an untyped constant can be used inside 
constant expressions (e.g. to declare a static array with certain 
bounds) while a typed constant can not. On the other hand you can take 
the address of a typed constant (as it's essentially a variable with 
readonly data) while you can't do that for untyped constants.

And yes, it behaves this way in Delphi, too.

Regards,
Sven


More information about the lazarus mailing list