Skip to content

spec: class: add __ctor, __dtor and __xdtor aliases #3125

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 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions glossary.dd
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ void test()
syntax) refers to the ability to call a function as if it were a method of
its first argument. For example `funct(arg)` may be written as
`arg.funct()`.)

$(DT $(LNAME2 inclusive_destructor, inclusive-destructor, Inclusive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$(DT $(LNAME2 inclusive_destructor, inclusive-destructor, Inclusive
$(DT $(LNAME2 inclusive-destructor, Inclusive

Destructor))
$(DD An inclusive destructor is a destructor that includes destruction
of the object itself and its fields, if reaching its lifetime.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
of the object itself and its fields, if reaching its lifetime.)
of the object itself and its fields.)

Destructors can be called early (for example, by destroy), and this definition applies regardless of when it is called.

)

)
Expand Down
8 changes: 8 additions & 0 deletions spec/class.dd
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ $(GNAME Constructor):
}
------

$(P The compiler generate a $(D __ctor) alias that matches with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$(P The compiler generate a $(D __ctor) alias that matches with
$(P The compiler generates a $(D __ctor) alias that matches with

constructors definitions.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constructors definitions.)
constructor definitions.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand what you mean by this sentence. Could you please elaborate?


$(H3 $(LNAME2 delegating-constructors, Delegating Constructors))

$(P A constructor can call another constructor for the same class
Expand Down Expand Up @@ -729,6 +732,11 @@ $(GNAME Destructor):
by the gc.
)

$(P The compiler generates $(D __dtor) and $(D __xdtor) aliases that
matches the class destructor definition and inclusive destructors,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the term "inclusive destructor" defined elsewhere in the spec? If not I think it should have a definition somewhere.

I note that __xpostblit()'s description in the struct page of the spec mentions the creation of aliases.

void __xpostblit(). The field and aggregated postblits, although generated for a struct, are not actual struct members. In order to be able to call them, the compiler internally creates an alias, called __xpostblit which is a member of the struct and which points to the generated postblit that is the most inclusive.

However, I note that this wording seems to be descriptive rather than prescriptive, which isn't ideal for the language specification.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the inclusive destructor concept to the glossary. Please review it.

About the __xpostblit(), I think it is a bit out of scope of this PR, although I can write a separate one fixing that wording.

respectively.)


$(H2 $(LNAME2 static-constructor, Static Constructors))

$(GRAMMAR
Expand Down