INPUT /  OUTPUT /  LANGUAGE






Reference pointers

Suppose you want to write some code to perform an action on a tag or field, but the specific tag or field to be acted on might vary. How could you write your code so that a different tag could be acted on each time, without writing several copies of the same code? If you were to use the name of a tag and store the result in a field, that would only give you that tag's current primary field value, it would not point to the tag itself.

The reference operator

The .& operator is called the reference operator. It gets a special reference to where a tag or field is actually stored in memory. You can store this reference pointer like any other value in ioL.

The dereference operator

A reference pointer value is not very useful by itself. It is like a token that represents an address where a tag or field can be found. If you only had the address of a building on a piece of paper, that would not be the same as being inside that building and being able to access its furniture. You would need to actually go to the address on your piece of paper in order to access that building. The .* operator is called the dereference operator. It takes you to the actual tag or field so you can access and manipulate it. The dereference operator is only present in scalar fields, and only when a reference poiner has been assigned to that field. Vector fields have no such operator. It does not make sense to dereference a vector field when a vector might contain multiple reference pointers or none at all. While you can store one or more reference pointers inside a vector, you will need to assign the desired reference pointer to a scalar in order to dereference it.