-
Notifications
You must be signed in to change notification settings - Fork 30
[DRAFT] Composing by-constructor and non-by constructor types #185
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments below.
One thing that needs to be assessed, is that once a by-constructor type is component of a type T, then T becomes "implicitly" a by-constructor type. This is essential because then an implicitly by-constructor type might be used as component of other types, and in turn influence their kind of initialization. Also I think the same rules should apply to parent types, not only to components, no?
As a side note, I think we need to clear the implicit/explicit constructors. There are several differences that I didn't get when first reading the rfc, for instance that default initialization is permitted if a type only have implicit constructors, thus that type is not per se "by-constructor" but still we might be able to build it with both 'Make parameterless and default initialization. Or again that a regular type could be an implicit by-constructor, and as a consequence to forbid default initialization. I just wanted to point out that this difference isn't clear in the rfc but I'm not asking for any edit about it now.
features/rfc-oop-constructors.rst
Outdated
| In this case, the rules are as follows: | ||
|
|
||
| - [1] If the by-constructor type provides both a by-copy and a parameterless |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better using rst lists? using 1. , 2. , and so on. Note that you will need to add a space to maintain the correct indentation then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
features/rfc-oop-constructors.rst
Outdated
| procedure Non_Tagged'Constructor (Self : in out Non_Tagged) is abstract; | ||
| This does require to describe how constructors are expressed on non-tagged | ||
| types which is not part of this proposal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rfc starts with "Constructors are available to both tagged and untagged records." I think the fact that we do not handle untagged types is unclear.
We should remove all references to untagged records, and specify that untagged records are not part of this proposal closer to the beginning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed - this is a leftover from an initial version of the proposal. Untagged record needs to be handled separately. I'll clean.
features/rfc-oop-constructors.rst
Outdated
| Note that the above also says that allocation of such object without a copy | ||
| or aggregate is illegal. E.g.: | ||
|
|
||
| . code-block:: ada |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a dot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix.
features/rfc-oop-constructors.rst
Outdated
| Composing by-constructors types with non by-constructor types | ||
| ------------------------------------------------------------- | ||
|
|
||
| By-constructor types can be included in types that are not build by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the exact definition of a "by-constructor type"? a type declared via a tagged record that has explicitly declared a constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - or that is derived from a by-constructor type. I'll make that explicit.
|
A few more comments I've been thinking about (I can't comment on lines that are not modified by this PR but I think these are relevant):
|
There's indeed an issue of composition here. So we could take two stances - we can indeed implicitly propagate the "by constructor" aspect of types. This has impact on what you can do with types in particular with regards to default initialization - you should not be able to have a controlled be by constructor. The alternative is to only propagate whether or not a type has default initialization. E.g. in : type X is tagged record
null;
end record;
procedure X'Constructor (Self : in out X; V : Integer);
type C is record
F: X;
end record;
-- C is not by constructor, but doesn't have default initialization
type C2 is record
F2 : C;
end record
-- C2 is not by constructor, but doesn't have default initialization eitherI believe that as far as limited goes (ie types without copy constructors), this propagation is already there.
Ok - requires clarification indeed - I'll work on that. There's a difference between tagged and class types here:
Does that make sense? |
Agreed - will fix. |
No description provided.