Delphi Constant

Posted on admin
Delphi Constant 5,5/10 1728 votes
Delphi const array

Error Unit1.pas(33): E2026 Constant expression expected. 'Loren Pechtel' wrote Values is a typed constant. It's treated as a read-only (or read-write depending on the compiler settings) variablenot as a constant. Al, One could easily conclude that a Delphi 'typed constant' was just a sub-class of 'constant'. Sivaji blu ray movie download. Does there needs to be a different name for the sub-class of constants that can be used 'const' expressions? BTW, I remember, when studying Ada 30 years ago, that there was the concept of 'universal integer' (and maybe universal other things, too) that avoided the problem of assigning or assuming an exact type for literals when using them in constant expressions.

Dynamic Arrays in Delphi XE7 In the TwoDesk blog that you have linked in your post, it states the following: 'NEVER increase the length of your array by 1, or 2, or any constant amount.

This seemed to me to be quite useful when writing constants or constant expressions. One could avoid the question of when to use '-$7FFF' or '$FFFF'. John Herbster wrote: One could easily conclude that a Delphi 'typed constant' was just a sub-class of 'constant'. Does there needs to be a different name for the sub-class of constants that can be used 'const' expressions? There is: true constants. The difference is: a true constant is really just a symbolic name for a literal.

IOW, each time you use that name, it is effectively replaced by the literal, and the type of that literal can depend on the context. Also, sich literals do not necessarily have an address or occupy memory. A typed constant already has a type and occupies memory, which is not necessarily true for a true constant.

Like Loren said, a typed constant is in effect a read-only variable. Rudy Velthuis (TeamB) 'I have often regretted my speech, never my silence.' - Xenocrates (396-314 B.C.).

'John Herbster' wrote in message news. One could easily conclude that a Delphi 'typed constant' was just a sub-class of 'constant'. Does there needs to be a different name for the sub-class of constants that can be used 'const' expressions? 'Rudy Velthuis (TeamB)' wrote There is: true constants. Thanks Rudy, Even D7 has a 'true constants' page in the help.

Delphi

Why do integer true constants need to be typed? See following table from the D7 Help. Rgds, JohnH Types for integer constants Range of constant(hexadecimal) Range of constant(decimal) Type -$000000.-$80000001 -2^63.- Int64 -$80000000.-$8001.-32769 Integer -$8000.-$81 -32768.-129 SmallInt -$80.-1 -128.-1 SmallInt 0.$7F 0.127 0.127 $80.$FF 128.255 Byte $0100.$7FFF 256.32767 0.32767 $8000.$FFFF 5 Word $10000.$7FFFFFFF 483647 0. Cardinal $100000000.$7FFFFFFFFFFFFFFF.2^63-1 Int64. John Herbster wrote: 'John Herbster' wrote in message news.

Delphi Constant Array

One could easily conclude that a Delphi 'typed constant' was just a sub-class of 'constant'. Does there needs to be a different name for the sub-class of constants that can be used 'const' expressions? 'Rudy Velthuis (TeamB)' wrote There is: true constants. Thanks RudyEven D7 has a 'true constants' page in the help. Why do integer true constants need to be typed?

Delphi Constants

They don't have to be, although it makes it easier for the compiler to assume a default type for certain values, especially if these constants are used in enumerations or range types. ISTM that the compiler simply assumes the smallest possible type that can accomodate the integer value. Note that the compiler has no problem converting between integer types, so it is not a big deal, since the correct type will be used. Rudy Velthuis (TeamB) 'A man can't be too careful in the choice of his enemies.' - Oscar Wilde (1854-1900).