Adriaan van Os wrote:
Frank Heckenbach wrote:
What you suggest is a way to determine the capacity from the initial value. More generally, this could also be applied to arrays (where I'd find it useful sometimes).
This may be quite useful. For example, these innocent looking declarations:
const ResultMessage: array [TWaitPIDResult] of TString = ('did not terminate with status ', 'terminated with status ', 'was teminated by signal ', 'was stopped by signal ', 'did something unexpected with status ');
now take up 10 KByte in the resulting executable.
But it would work only for the outer array (otherwise, how to index an array with elements of varying size?). This case would get smaller with reference-strings as described in my previous mail.
Implementing it might not be too hard, but I don't yet have a good idea for the syntax. Empty parentheses look strange to me. Besides, for arrays (not for strings) somehow the lower bound must be specified. Something like `...' perhaps:
var s: String (...) = 'Hi'; a: array [1 ...] of Integer = (42, 17, 99);
A bit strange at first glance (as it is something new) but it does the job. It takes the implicit length/upper bound constant from the attached value. We may add that constant to the construct, something like this:
var s: String ( const len ) = 'Hi'; a: array [1 ... const n ] of Integer = (42, 17, 99);
What I like about this is that it's (IMHO) more similar to Pascal syntax (assuming you mean `..' instead of `...').
What I don't like is that another identifier is introduced within some other declarations. Enum types do the same, and this has caused some extra work in the compiler. Since it's possible to get the upper bound as `High (s)' or `High (a)' (BP compatible feature), I think it's not necessary to introduce a new identifier in the declaration.
Frank