p^.rlink=q
q^.llink=p
When caret (^) appears after a pointer variable it dereferences the pointer, that is, it returns the value stored at the memory address held by the pointer. So in your case I suppose that p
is a pointer to a record that has rlink
property and q
is a pointer to a record that has llink
property. These properties are also pointers to the same structure, because p
and q
are then assigned to them. I suppose that this structure represents a binary tree data type with left and right nodes.
The pascal operator ^.
is similar to operator ->
in C and C++.
It dereferences the pointer (in your case, p
should be defined as var p: ^type
) and accesses a variable in the record, in this case, rlink
and llink
.
p and q appear to be pointers. They point to a record variables which have respectively (or probably both), a rlink and llink (guessing right link and left link).
This snippet is probably used in the context of a graph or maybe a linked list of sorts.
The caret (^) operator, in Pascal, is the dereference opertator which enables one to access the variable content not the the pointer.
The direct equivalent in C language would be
(p*).rlink=q
(q*).llink=p
but of course this would typically be expressed as
p->rlink=q
q->llink=p
with C's -> operator which does a deferencing and member access in one step.
A likely possibility is that p and q are elements in a doubly-linked list, often called a bi-directional linked list. Those two statements are attaching them together, with p on the "left" and q on the "right". An equivalent in C/C++ would be:
p->rlink = q;
q->llink = p;