Home>

Problem
The result of evaluating p = p ^ [true] for a pointer variable p is true, but
One example of a situation where p = p ^ [p = p ^ [false]] evaluates to false is
Use a box and arrows to represent it

This is a problem, but there is [] after p ^ ... Is this an array? What is it?

  • Answer # 1

    I can't confirm because there is no Pascal environment.

    An array whose index is Boolean type
    var a: array [Boolean] of Boolean;

    Since the element is Boolean type and the index is Boolean type, you can substitutea [false]: = true;. Since you can substitute, you can compare.

    Pointer to an array whose index is Boolean type
    var p: ^ array [Boolean] of Boolean;
    I think that I can apply this, so I can writep ^ [true]: = false;etc. by assigning the address asp: = @a;.

    In short,p ^ [true]etc. represents access to an array element using a pointer variable p to the array.