Skip to content

Commit

Permalink
Renamed destructors to deinitializers throughout the spec.
Browse files Browse the repository at this point in the history
Thanks Lydia for a good suggestion!
  • Loading branch information
vasslitvinov committed Feb 9, 2017
1 parent 0346d4f commit bdb94ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions spec/Classes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ \subsection{Implicit Class Conversions}

%TODO: Move memory management explanation up, closer to class constructors.
% Perhaps make the memory management part of the introduction, and then let the
% description of destructors appear naturally at the same indentation level as
% description of deinitializers appear naturally at the same indentation level as
% constructors.
\section{Dynamic Memory Management}
\label{Dynamic_Memory_Management}
Expand Down Expand Up @@ -1154,19 +1154,19 @@ \section{Dynamic Memory Management}
\end{openissue}


\subsection{Class Destructor}
\label{Class_Destructor}
\index{classes!destructor}
\index{destructor!classes}
\subsection{Class Deinitializer}
\label{Class_Deinitializer}
\index{classes!deinitializer}
\index{deinitializer!classes}

A class author may specify additional actions to be performed before a class object is
reclaimed, by defining a class destructor. A class destructor is a method named
\chpl{deinit}. A class destructor takes no arguments (aside from
the implicit \chpl{this} argument). If defined, the destructor is called each time
reclaimed, by defining a class deinitializer. A class deinitializer is a method
named \chpl{deinit}. A class deinitializer takes no arguments (aside from
the implicit \chpl{this} argument). If defined, the deinitializer is called each time
a \chpl{delete} statement is invoked with a valid instance of that class type. The
destructor is not called if the argument of \chpl{delete} evaluates to \chpl{nil}.
deinitializer is not called if the argument of \chpl{delete} evaluates to \chpl{nil}.

\begin{chapelexample}{classDestructor.chpl}
\begin{chapelexample}{classDeinitializer.chpl}
\begin{chapel}
class C {
var i,j,k: int;
Expand Down
24 changes: 12 additions & 12 deletions spec/Records.tex
Original file line number Diff line number Diff line change
Expand Up @@ -335,34 +335,34 @@ \subsection{Record Initialization}
(\rsec{User_Defined_Constructors}). If any user-defined constructors are
supplied, the default initializer cannot be called directly.

\subsection{Record Destructor}
\label{Record_Destructor}
\index{records!destructor}
\index{destructor!records}
\subsection{Record Deinitializer}
\label{Record_Deinitializer}
\index{records!deinitializer}
\index{deinitializer!records}

A record author may specify additional actions to be performed before record storage is
reclaimed by defining a record destructor. A record destructor is a method named
\chpl{deinit}. A record destructor takes no arguments
(aside from the implicit \chpl{this} argument). If defined, the destructor is called
reclaimed by defining a record deinitializer. A record deinitializer is a method named
\chpl{deinit}. A record deinitializer takes no arguments
(aside from the implicit \chpl{this} argument). If defined, the deinitializer is called
on a record object after it goes out of scope and before its memory is reclaimed.

% TODO: The above ambiguous language is intended to allow optimizations involving extending
% the lifetime of an object. However, we leave unspecified the means by which a user may
% demand avid running of the destructor and reclamation of memory (as in C\#). We need to
% demand avid running of the deinitializer and reclamation of memory (as in C\#). We need to
% specify this so the above language can be tightened up for that case.

% For now, the actual lifetime of a record object is under the control of the compiler. For
% example, as an optimization, ownership of an object may be transferred between variables with
% non-overlapping lifetimes. When this happens, there will be no observable destruction of
% non-overlapping lifetimes. When this happens, there will be no observable deinitialization of
% one of those variables. The compiler may also choose to insert temporary copies e.g. of
% record formals or of a record return value.

% The compiler guarantees that every record constructor call will have exactly one
% corresponding record destructor call. However, the exact number of constructor-destructor
% corresponding record deinitializer call. However, the exact number of constructor-deinitializer
% pairs is determined by the compiler, and may also be influenced by various compiler
% options.

\begin{chapelexample}{recordDestructor.chpl}
\begin{chapelexample}{recordDeinitializer.chpl}
\begin{chapel}
class C { var x: int; } // A class with nonzero size.
// If the class were empty, whether or not its memory was reclaimed
Expand All @@ -380,7 +380,7 @@ \subsection{Record Destructor}
var r: R; // Initialized using default constructor.
writeln(r);
// r will go out of scope here.
// Its destructor will be called to free the C object it contains.
// Its deinitializer will be called to free the C object it contains.
}

foo();
Expand Down

0 comments on commit bdb94ab

Please sign in to comment.