Michael Daniluk
2009-04-21 22:18:33 UTC
Hello All,
Very New to Modula 2 and I am getting a compiler error while trying
to assign one pointer to another. The purpose of this code is to
implement my own little "dynamic array" abstract data type. Here is a
snippet of the Implementation Module:
TYPE String = POINTER TO CharArr;
(*This Record Defines The String Type*)
TYPE CharArr = RECORD;
value : POINTER TO CHAR;
size : INTEGER;
capacity : INTEGER;
END;
PROCEDURE ReallocArr (VAR s : String; newCapacity : INTEGER);
VAR OldPointer, NewPointer, run_1, run_2 : POINTER TO CHAR;
VAR counter : INTEGER;
BEGIN
OldPointer := s^.value; (*ERROR OCCURS HERE*)
As indicated, my error occurs in the last line of code I posted. The
error is "expression is not assignment compatible." It is my
understanding that both 'OldPointer' and 's^.value' are of the type
POINTER TO CHAR, and therefore the assignment operation should work.
What insight is eluding me here? Thanks in Advance.
truly,
Michael
Very New to Modula 2 and I am getting a compiler error while trying
to assign one pointer to another. The purpose of this code is to
implement my own little "dynamic array" abstract data type. Here is a
snippet of the Implementation Module:
TYPE String = POINTER TO CharArr;
(*This Record Defines The String Type*)
TYPE CharArr = RECORD;
value : POINTER TO CHAR;
size : INTEGER;
capacity : INTEGER;
END;
PROCEDURE ReallocArr (VAR s : String; newCapacity : INTEGER);
VAR OldPointer, NewPointer, run_1, run_2 : POINTER TO CHAR;
VAR counter : INTEGER;
BEGIN
OldPointer := s^.value; (*ERROR OCCURS HERE*)
As indicated, my error occurs in the last line of code I posted. The
error is "expression is not assignment compatible." It is my
understanding that both 'OldPointer' and 's^.value' are of the type
POINTER TO CHAR, and therefore the assignment operation should work.
What insight is eluding me here? Thanks in Advance.
truly,
Michael