Paul Isaacs wrote:
On 22/01/17 11:09 AM, Waldek Hebisch wrote:
It seems that if you want you can replace type-inquiry by explicit definition.
Hello Waldek,
Thanks for the reply. I just assumed, incorrectly, that type-inquiry was a reflective construct of some sort.
It _is_ a reflective construct. Just most of time you can live without it. Maybe an example:
var a : record i : integer end;
Note that if you write:
var b : record i : integer end;
then b will be of different type than a (because each 'record' introduces entirely new type). You can solve the problem using named type:
type t = record i : integer end; var a : t;
var b : t;
Or you can use type-inquiry:
var b : typeof(a);
If you can modify declaration of 'a' you probably prefer first version. But in real life you may be unable to modify declaration of 'a'...
Note: in GPC 'typeof' is only implemented for object types (which are absent in Extended Pascal) so this does not work.