Access Types to the same type

Problem

Currently access types are types. This makes some data structures and use models more complicated than they ought to be.

Current Use Model

For example, to create a pointer to a record, one must first create a incomplete type, create a pointer to the incomplete type, and then complete the record type declaration:

    type ListType ;
    type ListPointerType is access ListType ;
    type ListType is record
      Element        : ElementType ;
      NextPtr        : ListPointerType ;
    end record ;

    variable HeadPointer, TailPointer : ListPointerType ; 

The problem is that we need the type ListPointerType defined so that other items that point to this list can do the same.

Proposed Use Model:

    type ListType is record
      Element        : ElementType ;
      NextPtr        : access ListType ;
    end record ;

    variable HeadPointer, TailPointer : access ListType ; 

Key Problem

The problem is that each access type of the same given type is a separate type rather than related to each other - such as subtypes.

How?

First, when a type is declared, the language could also create an implicit, nameless access type declaration to that type.

Next, the use of keyword "access" creates a subtype of the nameless access type.

The question would be then, how to handle the old syntax.

    type ListPointerType is access ListType ;

Will it peacefully co-exist with the new syntax? Will it intermingle or do you need to use one or the other?

If access ListType creates a subtype, then with the new syntax, the following will also be supported:

    subtype ListPointerType is access ListType ;

Can we do more?

Can we create a class structure of access types where access types can embed type information into them and, hence, support something like printf in VHDL?

Could we implement unions this way?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information