I met something in Delphi that I had not noticed before. Consider a simple entry and a pointer to this entry:
TRecord = record value : double; end; PTRecord = ^TRecord;
Now declare a variable of type PTRecord:
var x : PTRecord;
and create some space:
x := new (PTRecord);
I noticed that I can access the value field using how. designation and "^". notation. Thus, the following two lines seem to be functionally equivalent, the compiler does not complain, and the runtime works fine:
x.value := 4.5; x^.value := 2.3;
I would have thought that "^". is the correct and only way to access the value? My question is, is it good to use simpler dot notation or will I run into a problem if I don't use the "^." Pointer? This may be a well-known behavior, but the first time I came across this.
rhody source share