On Mon, 27 Apr 2020 04:23:49 +0200, Bernd Oppolzer wrote:

>I would like to add:
>
>as explained, the types integer and char are incompatibel in Pascal.
>Furthermore, char in Pascal is NOT a computational type; you cannot do
>arithmetic with chars, and there is no sign with chars (much the same as
>in PL/1,
>for example). To do arithmetic with chars, you need the conversion
>functions ORD and CHR.
> 
But pred() and succ() operate on any ordinal type.

>This all seems quite natural to me; the C idea that chars are small
>integers and therefore have a sign is strange IMO.
>
UCSD Pascal introduced a strange convention.
AND and OR operated bitwise on 16-bit boolean operands.
ODD() simply returned its 16-bit argument, unmasked,
and ORD(boolean) did likewise.  IF tested only the lowest
bit, so it interacted properly with ODD.  But I encountered
a problem when I used ARRAY [BOOLEAN] and used
the value of ODD(integer) as a subscript.  Apple patched
the problem by masking when a boolean was used as a
subscript.  But this left misbehaviors such as
    ORD(ODD(2))>ORD(ODD(1))

>On the other hand, Pascal supports ANY standard or scalar or subrange
>type as index type
>for arrays, for example:
>
>var howoften : array [char] of integer ;
>    ch: char;
>...
>read (ch);
>howoften [ch] := howoften [ch]  + 1;
>
>the array howoften is used to count the occurence of chars in an input
>file, for example.
> 
But can you use a char as a control variable of DO to
step through the howoften array?

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to