What is standard, and what isn't?_(re)

Wed, 30 Apr 1997 03:19:28 -0400



Peter Gerwinski wrote:

>1) 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 :-)


>2) 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.


Berend de Boer (berend@compuserve.com)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es