A reference has the following advantages over a pointer:
-
Easier to use:
A reference can access the contents of the referenced object directly and without dereferencing.
-
Finer and simpler syntax when passing values:
Call of a function block which passes a reference without an address operator instead of a pointer
Example:
fbDoIt(riInput:=iValue);Instead of:
fbDoIt_1(piInput:=ADR(iValue)); -
Type safety:
When assigning two references, the compiler checks whether their base types match. This is not checked in the case of pointers.