Frank Heckenbach wrote:
While I'm wishing, how about: Astring = string() value "<some string>"; It compiles,
... without the parentheses and with `:' instead of `=' ...
but assumes capacity = 255 rather than the length of <some string>.
`String' used as a type means `String(255)' for BP compatibility (with a warning, normally).
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.
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);
Regards,
Adriaan van Os