coderJeff wrote:Is it possible to discuss references without discussing pointers?
I think that for the particular case of the FreeBASIC language, it is very useful to do parallel with the pointers when the references are explained:
- Under the hood, references are implemented using pointers auto-dereferenced by the compiler.
- Some FreeBASIC error messages on references involve the associated pointers under the hood.
- The FreeBASIC language leaves the user free to reassign a reference to another variable (of the same type or a compatible type):
@reference = @other_variable
(The operator '@' appears in the syntax).
- The address of the associated pointer under the hood can even be retrieved by:
@@reference
For the C language, the question may arise because the use of references is much less open and lax than for the FreeBASIC language.
For other languages that do not offer pointers to the user, the question obviously does not arise!