Since there's no way to create refereces (is there?) I have to do it with a pointer to another pointer. This gives me an error:
type
PNode = ^TNode;
TNode = record
char: char;
next: PNode;
children: PNode;
end;
PPNode = ^PNode;
var
current_node: PPNode;
function find_or_insert_peer(var node: PNode; character: char): PNode;
current_node := @find_or_insert_peer(current_node^, character)^.children;
x.pas(121,23) Error: Incompatible types: got "<address of function(var PNode;Char):^TNode;Register>" expected "PPNode"
x.pas(121,43) Fatal: Syntax error, ";" expected but "(" found
Fatal: Compilation aborted
I also tried this but it does not compile because of SyntaxError
current_node := @(find_or_insert_peer(current_node^, character)^.children);
Edit
Please help. I've even created a demo in c++ to show you this is legal. http://cpp.sh/8mxe