Skip to content

[RFC] OOP Components #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions considered/rfc-oop-fields.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
- Feature Name: Standard OOP model
- Start Date: May 5th 2020
- RFC PR:
- RFC Issue:

Summary
=======

Motivation
==========

Guide-level explanation
=======================

Components declarations
-----------------------

A record and tagged record type can now have 2 declarative regions where fields
can be declared:

- the package public view
- the package private view

A public view that allows for additional fields to be declared is denoted by
`with private` after its declaration. The private view of a record type can
then be split between its own public and private sections:

For example:

.. code-block:: ada

package P is
type R is record
Pub : Integer;
end record
with private; -- There are more fields in the private view

type T is tagged record
Pub : Integer;
end record
with private; -- There are more fields in the private view

private

type R is record
Priv : Integer;
end record;

type T is tagged record
Priv : Integer;
end record;
end P;

Visibilty rules of these fields are following the usual package-visibilty rules.

It is possible to declare empty public or private views either with an empty `record end record` section, or the shorthands `null record` syntax.

For example, all of the following type declarations are legal:

.. code-block:: ada

package Legal is
type R1 is null record with private; -- This syntax is supported for declaring an empty public view

type R2 is record
Pub : Integer;
end record
with private;

type R3 is record
null;
end record with private; -- This record type has both public and private views empty

-- Same as R1, R2, R3 in tagged type forms

type T1 is tagged null record with private;

type T2 is tagged record
Pub : Integer;
end record
with private;

type T3 is tagged null record with private;

private

type R1 is record
Priv : Integer;
end record;

type R2 is record
null;
end record;

type R3 is null record; -- This record type has both public and private views empty

type T1 is tagged record
Priv : Integer;
end record;

type T2 is tagged null record;

type T3 is tagged null record;

end Legal;

As outlined in the example, it is legal to declare both public and private views as empty.

Reference-level explanation
===========================

Rationale and alternatives
==========================

Drawbacks
=========

Prior art
=========

Unresolved questions
====================

Future possibilities
====================