<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Gem #62: C++ constructors and Ada 2005</title>
	<atom:link href="http://www.adacore.com/2009/04/06/gem-62/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adacore.com/2009/04/06/gem-62/</link>
	<description>AdaCore technology and news</description>
	<lastBuildDate>Mon, 06 Feb 2012 18:59:19 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Brad Moore</title>
		<link>http://www.adacore.com/2009/04/06/gem-62/comment-page-1/#comment-3558</link>
		<dc:creator>Brad Moore</dc:creator>
		<pubDate>Mon, 13 Apr 2009 14:42:59 +0000</pubDate>
		<guid isPermaLink="false">http://www2.adacore.com/?p=2743#comment-3558</guid>
		<description>function New_Rec2 above, if declared as a primitive operation of type Rec2, would be a dispatching operation, and if a new type were derived from Rec2, (say Rec3) it would require that Rec3 provide an overloaded version of New_Rec2. This may not be appropriate (naming issues aside). Supposing the Rec3 type adds further discriminants. The New_Rec2 function may not be able to determine the values to use for the new discriminants of Rec3. It would be helpful to show how to declare the New_Rec2 function so that it is not inherited by derivations of Rec2.
My understanding is that one of the best ways to do this is to declare such constructor functions in a nested package. This way they cannot be primitive functions, and cannot be inherited. eg
package Recs is
  type Rec1 is limited ...
  type Rec2 is limited ...
  package Constructors is
     function New_Rec2 (V : Integer) return Rec2;
  end Constructors;
end package Recs;

Are there other approaches to consider?</description>
		<content:encoded><![CDATA[<p>function New_Rec2 above, if declared as a primitive operation of type Rec2, would be a dispatching operation, and if a new type were derived from Rec2, (say Rec3) it would require that Rec3 provide an overloaded version of New_Rec2. This may not be appropriate (naming issues aside). Supposing the Rec3 type adds further discriminants. The New_Rec2 function may not be able to determine the values to use for the new discriminants of Rec3. It would be helpful to show how to declare the New_Rec2 function so that it is not inherited by derivations of Rec2.<br />
My understanding is that one of the best ways to do this is to declare such constructor functions in a nested package. This way they cannot be primitive functions, and cannot be inherited. eg<br />
package Recs is<br />
  type Rec1 is limited &#8230;<br />
  type Rec2 is limited &#8230;<br />
  package Constructors is<br />
     function New_Rec2 (V : Integer) return Rec2;<br />
  end Constructors;<br />
end package Recs;</p>
<p>Are there other approaches to consider?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul F. Pearson</title>
		<link>http://www.adacore.com/2009/04/06/gem-62/comment-page-1/#comment-3527</link>
		<dc:creator>Paul F. Pearson</dc:creator>
		<pubDate>Tue, 07 Apr 2009 18:07:55 +0000</pubDate>
		<guid isPermaLink="false">http://www2.adacore.com/?p=2743#comment-3527</guid>
		<description>Will a future gem discuss destructors?  I presume that they are handled in a similar fashion.</description>
		<content:encoded><![CDATA[<p>Will a future gem discuss destructors?  I presume that they are handled in a similar fashion.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

