Peter Gerwinski wrote:
- Is the comparision with `=' or `<>' of structured variables okay in
ISO Pascal? ISO 10206 6.8.3.5 only says that the types to be compared must be compatible.
No, see the table in 6.8.3.5. And I see quite some problems in implementing this correctly. A simple byte compare won't do except in the most easiest of cases.
If you want something 'difficult' to do , implement integer and string value arrays :-)
- In GPC strings, the schema discriminant "Capacity" is accessible
as a "record field" of the string. Is this okay by ISO 10206, and should it be done for other schemata this way, too?
Certainly: see the examples in 6.8.4
And how
to tread the "length" field of a string? ISO 10206 6.4.3.3 does not say anything about that. I could imagine the string schema type to be something similar to
Type String ( Capacity: Integer ) = record length: Integer; String: packed array [ 1..Capacity ] of Char; end (* String *);
except that the "String" field is automatically dereferenced.
I think one implements it as:
Type String ( Capacity: Integer ) = record length: Integer; String: packed array [ 1..Capacity+SizeOf(Char) ] of Char; end (* String *);
+1 to allow for a trailing zero (or zero's in case of Unicode...).
However length is not specified in the standard, so it should not be accessible with Extended Pascal. You can always use length(MyStr) to achieve the same functionality.
Groetjes,
Berend.