Re: type-inquiry

Waldek Hebisch <[email protected]> Mon, 23 Jan 2017 00:39:04 +0100 (CET)
Newsgroups gmane.comp.compilers.gpc
Message-ID <[email protected]>
I wrote:
> 
> 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.

Oops.  I should write:

var b : type of(a);

'typeof' is a Borland Pascal stuff, 'type of' is Extended Pascal.
Both are obscure enough that I confused them.

-- 
                              Waldek Hebisch

_______________________________________________
Gpc mailing list
[email protected]
https://www.g-n-u.de/mailman/listinfo/gpc