SYSTEM.TYP - Why is it even there?

All except GUI problems

SYSTEM.TYP - Why is it even there?

Postby adimetrius » Wed Aug 04, 2021 1:32 pm

Colleagues,

In keeping my work on Herschel, the amd64 compiler for CP, I have encountered the following.

Platform-Specific issues defines the module SYSTEM, including procedures TYP and ADR. Their definition in PSI is limited compared to what they actually do.

SYSTEM.TYP expects, according to PSI, a variable v of record type and returns the type tag of v (presumably the actual, or dynamic, type of v).
First, What the PSI does not define, is that SYSTEM.TYP can also accept T: a record type, and will return the type tag of T, or T: a pointer to record type, and will return the type tag of the record type (NOT the pointer type!). This notation, despite being undocumented, is widely used in module Kernel.

SYSTEM.ADR has three documented notations, the last expecting T: a record type and returning the address of Descriptor of T.
Second, What the PSI does not define, is that SYSTEM.ADR can also accept A: an array type, P: a procedural type, PTR: a pointer type, and in all these cases will return the address of Descriptor of the type. In other words, SYSTEM.ADR(T) expects a structural, pointer or procedural type (all these are descriptored in BB) and returns the address of the descriptor of T.

Third, there is a duplicity of terms: TYP definition talks about the type tag, while ADR definition talks about the address of Decriptor - which in essense is the same thing, isn't it?

Fourth, and last, There is a duplicity of function: for T: a record type, SYSTEM.TYP(T) = SYSTEM.ADR(T).

I think that dropping SYSTEM.TYP(T) from the compiler would make it and the PSI slightly simpler and cleaner; while documenting all notations of SYSTEM.ADR would make PSI more truthful and exact - like so for example:
ADR(T) T: a record, array, pointer or procedural type INTEGER address of descriptor of T (type tag)

What do you think?
User avatar
adimetrius
 
Posts: 60
Joined: Sun Aug 04, 2019 1:02 pm

Re: SYSTEM.TYP - Why is it even there?

Postby Josef Templ » Thu Sep 09, 2021 7:18 pm

according to PSI it seems to me that TYP(v) gives you the dynamic type of record variable v (or some p^) while ADR(T) gives you the type of the statically known type T.

- Josef
Josef Templ
 
Posts: 256
Joined: Tue Sep 17, 2013 6:50 am


Return to BlackBox Framework

Who is online

Users browsing this forum: No registered users and 1 guest

cron