Peter N Lewis wrote:
... snip ...
New(s,57) gives a runtime error on failure, and so the compiler knows that it need not bother checking.
s := New(String,57) potentially returns nil, so the compiler checks.
I'm not sure if that is reasonable. It makes a certain kind of sense in some respects - New as a procedure has no return value and thus nothing to report, New as a function returns a pointer (even for reference objects anyway) and therefore can return a success/failure result.
To start with, new is a standard PROCEDURE, not a function. The constants following the argument specify variants and allow assignment of space for a particular variant of the actual type. You can only do the sort of thing you recommend if you override the level 0 predeclaration of new, which in turn makes memory allocation unavailable to the remainder of the program. In your example above string would have had to be declared similarly to:
TYPE string = RECORD ..... CASE integer OF 57: ( somevariant ); 22: ( othervariant); END;
which is one of the reasons case variants must be the last portions of records.