<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://dev.eiffel.com/index.php?action=history&amp;feed=atom&amp;title=Definition-site_variance</id>
		<title>Definition-site variance - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://dev.eiffel.com/index.php?action=history&amp;feed=atom&amp;title=Definition-site_variance"/>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Definition-site_variance&amp;action=history"/>
		<updated>2026-05-05T10:26:11Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>https://dev.eiffel.com/index.php?title=Definition-site_variance&amp;diff=8921&amp;oldid=prev</id>
		<title>Peter gummer: /* Conclusion */</title>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Definition-site_variance&amp;diff=8921&amp;oldid=prev"/>
				<updated>2007-06-24T20:57:12Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Conclusion&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 20:57, 24 June 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 191:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 191:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Conclusion ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Conclusion ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This solution requires that the libraries are designed in a way which separates reading and writing to generic &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;datastructes&lt;/del&gt;. It allows full use of comparator objects but does not fully support agents.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This solution requires that the libraries are designed in a way which separates reading and writing to generic &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;data structures&lt;/ins&gt;. It allows full use of comparator objects but does not fully support agents.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;On the plus side, the client of a library does not need to put variance markers as in the [[usage-site variance]] proposal which makes the use of the solution easier for the normal programmer.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;On the plus side, the client of a library does not need to put variance markers as in the [[usage-site variance]] proposal which makes the use of the solution easier for the normal programmer.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Peter gummer</name></author>	</entry>

	<entry>
		<id>https://dev.eiffel.com/index.php?title=Definition-site_variance&amp;diff=8914&amp;oldid=prev</id>
		<title>Juliant: /* Agents */</title>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Definition-site_variance&amp;diff=8914&amp;oldid=prev"/>
				<updated>2007-06-24T19:05:03Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Agents&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 19:05, 24 June 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 177:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 177:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Again, the fact that the generic tuple parameters are novariant causes that a safe assignment is prohibited.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Again, the fact that the generic tuple parameters are novariant causes that a safe assignment is prohibited.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==== Covariant tuples ====&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The agent mechanism in definition-site variance is not as expressive as it can be because the generic &amp;lt;e&amp;gt;TUPLE&amp;lt;/e&amp;gt; parameters cannot be specified as covariant in the class definition of &amp;lt;e&amp;gt;PROCEDURE&amp;lt;/e&amp;gt;. Since &amp;lt;e&amp;gt;TUPLE&amp;lt;/e&amp;gt; is a special case, you could think about allowing a special notation to denote totally covariant tuples. If this would be available, the mechanism would allow all possible assignments and calls for the agents.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;A possible syntax to designate that the generic tuple arguments will be contravariant would be:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;e&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;class PROCEDURE [+BASE_TYPE, -OPEN_ARGS -&amp;gt; TUPLE[+]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;end&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/e&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Conclusion ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Conclusion ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Juliant</name></author>	</entry>

	<entry>
		<id>https://dev.eiffel.com/index.php?title=Definition-site_variance&amp;diff=8905&amp;oldid=prev</id>
		<title>Juliant at 18:41, 24 June 2007</title>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Definition-site_variance&amp;diff=8905&amp;oldid=prev"/>
				<updated>2007-06-24T18:41:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 18:41, 24 June 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:ECMA]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:ECMA]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Catcall]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Catcall]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Research}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Introduction ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Introduction ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Juliant</name></author>	</entry>

	<entry>
		<id>https://dev.eiffel.com/index.php?title=Definition-site_variance&amp;diff=8821&amp;oldid=prev</id>
		<title>Seilerm at 01:55, 23 June 2007</title>
		<link rel="alternate" type="text/html" href="https://dev.eiffel.com/index.php?title=Definition-site_variance&amp;diff=8821&amp;oldid=prev"/>
				<updated>2007-06-23T01:55:09Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:ECMA]]&lt;br /&gt;
[[Category:Catcall]]&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The defintion-site variance allows the programmer to choose which kind of variance he wants to use in the defintion of a generic class. Unlike the [[usage-site variance]], this fixes a specific class to the kind of variance which it supports.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&lt;br /&gt;
The syntax used here to specify the variance of a generic is simple and may be changed to something more verbose but also clearer:&lt;br /&gt;
&lt;br /&gt;
* To specify a novariant generic, the normal syntax can be used: &amp;lt;e&amp;gt;class LIST [G] end&amp;lt;/e&amp;gt;&lt;br /&gt;
* To specify a covariant generic, we use a plus sign: &amp;lt;e&amp;gt;class READ_LIST [+G] end&amp;lt;/e&amp;gt;&lt;br /&gt;
* To specify a contravariant generic, we use a minus sign: &amp;lt;e&amp;gt;class WRITE_LIST [-G] end&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Semantics ==&lt;br /&gt;
&lt;br /&gt;
See the [[introduction to examples]] for information about the classes used.&lt;br /&gt;
&lt;br /&gt;
=== Conformance rules ===&lt;br /&gt;
&lt;br /&gt;
Depending on the variance of the generic, the conformance rules differ:&lt;br /&gt;
&lt;br /&gt;
* If a generic class is declared novariant, two generics conform if their base class conforms and the generic parameters match exactly. Thus &amp;lt;e&amp;gt;LIST [T]&amp;lt;/e&amp;gt; only conforms to &amp;lt;e&amp;gt;LIST [T]&amp;lt;/e&amp;gt;.&lt;br /&gt;
* If a generic class is declared covariant, a generic conforms to another if its base class conforms and the generic parameter conforms to the other. Thus &amp;lt;e&amp;gt;READ_LIST [U]&amp;lt;/e&amp;gt; conforms to &amp;lt;e&amp;gt;READ_LIST [T]&amp;lt;/e&amp;gt;.&lt;br /&gt;
* If a generic class is declared contravariant, a generic conforms to another if its base class conforms and the generic parameter is an ancestor of the other. Thus &amp;lt;e&amp;gt;WRITE_LIST [U]&amp;lt;/e&amp;gt; conforms to &amp;lt;e&amp;gt;WRITE_LIST [T]&amp;lt;/e&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Tuples are problematic in this solution as have to declare the generic tuple parameters as invariant. For the conformance of tuples, we keep that a tuple with more elements conforms to a tuple with less elements. The common elements have to match exactly due to their invariance:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;e&amp;gt;TUPLE [T, U]&amp;lt;/e&amp;gt; conforms to &amp;lt;e&amp;gt;TUPLE [T]&amp;lt;/e&amp;gt;&lt;br /&gt;
* &amp;lt;e&amp;gt;TUPLE [U]&amp;lt;/e&amp;gt; does not conform to &amp;lt;e&amp;gt;TUPLE [T]&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Applicable features ===&lt;br /&gt;
&lt;br /&gt;
Depending on the variance of a generic, it can only occur in certain places:&lt;br /&gt;
&lt;br /&gt;
* A novariant generic can be used as argument or result type.&lt;br /&gt;
* A covariant generic can only be used as a result type.&lt;br /&gt;
* A contravariant generic can only be used as an argument type.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
See the [[introduction to examples]] for information about the classes used.&lt;br /&gt;
&lt;br /&gt;
=== A simple generic algorithm ===&lt;br /&gt;
&lt;br /&gt;
In order to use lists as read-only lists, the library design has to be adapted. &amp;lt;e&amp;gt;LIST [G]&amp;lt;/e&amp;gt; needs to inherit from &amp;lt;e&amp;gt;READ_LIST [+G]&amp;lt;/e&amp;gt;. That way you can assign a &amp;lt;e&amp;gt;LIST [STRING]&amp;lt;/e&amp;gt; to a &amp;lt;e&amp;gt;READ_LIST [STRING]&amp;lt;/e&amp;gt; and, through transitivity of conformance, to a &amp;lt;e&amp;gt;READ_LIST [ANY]&amp;lt;/e&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
class PERSON_PRINTER&lt;br /&gt;
feature&lt;br /&gt;
  print_all (a_list: READ_LIST [PERSON])&lt;br /&gt;
      -- Print all attributes of each person in the list.&lt;br /&gt;
    do&lt;br /&gt;
      from&lt;br /&gt;
        a_list.start&lt;br /&gt;
      until&lt;br /&gt;
        a_list.after&lt;br /&gt;
      do &lt;br /&gt;
          -- Reading is valid on a covariant list&lt;br /&gt;
        a_list.item.print&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
class EXAMPLE&lt;br /&gt;
feature&lt;br /&gt;
  make&lt;br /&gt;
    local&lt;br /&gt;
      l_students: LIST [STUDENT]&lt;br /&gt;
      l_professors: LIST [PROFESSOR]&lt;br /&gt;
      l_person_printer: PERSON_PRINTER&lt;br /&gt;
    do&lt;br /&gt;
      create l_person_printer&lt;br /&gt;
        -- LIST [STUDENT] conforms to READ_LIST [PERSON]&lt;br /&gt;
      l_person_printer.print_all (l_students)&lt;br /&gt;
        -- LIST [PROFESSOR] conforms to READ_LIST [PERSON]&lt;br /&gt;
      l_person_printer.print_all (l_professor)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Comparator ===&lt;br /&gt;
&lt;br /&gt;
For the comparator example to work, the comparator class has to be declared as contravariant generic: &amp;lt;e&amp;gt;class COMPARATOR [-G]&amp;lt;/e&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
class SORTER [G]&lt;br /&gt;
feature&lt;br /&gt;
  sort (a_list: LIST [G]; a_comparator: COMPARATOR [G])&lt;br /&gt;
    do&lt;br /&gt;
        -- Somewhere in the loop:&lt;br /&gt;
      a_comparator.compare (l_string_1, l_string_2)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class EXAMPLE&lt;br /&gt;
feature&lt;br /&gt;
  make&lt;br /&gt;
    local&lt;br /&gt;
      l_list: LIST [STRING]&lt;br /&gt;
      l_string_sorter: SORTER [STRING]&lt;br /&gt;
      l_string_comparator: COMPARATOR [STRING]&lt;br /&gt;
      l_any_comparator: COMPARATOR [ANY]&lt;br /&gt;
    do&lt;br /&gt;
        -- COMPARATOR [STRING] conforms to COMPARATOR [STRING]&lt;br /&gt;
      l_string_sorter.sort (l_list, l_string_comparator)&lt;br /&gt;
        -- COMPARATOR [ANY] conforms to COMPARATOR [STRING]&lt;br /&gt;
      l_string_sorter.sort (l_list, l_any_comparator)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Agents ===&lt;br /&gt;
&lt;br /&gt;
Again, to use definition-site variance you have to adapt the library design. The procedure class has to be defined as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
class PROCEDURE [+BASE_TYPE, -OPEN_ARGS -&amp;gt; TUPLE]&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Calling agents ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
local&lt;br /&gt;
  an_agent: PROCEDURE [ANY, TUPLE [T]]&lt;br /&gt;
    -- An agent which takes an argument of type T.&lt;br /&gt;
do&lt;br /&gt;
    -- The following calls are surely permitted as the generic &lt;br /&gt;
    -- parameter in the tuple is novariant since it is not specified&lt;br /&gt;
    -- further in the procedure class.&lt;br /&gt;
  an_agent.call ([T])&lt;br /&gt;
  an_agent.call ([T, ...])&lt;br /&gt;
&lt;br /&gt;
    -- Because the tuple is novariant, the following calls are&lt;br /&gt;
    -- illegal although they would be safe.&lt;br /&gt;
  an_agent.call ([U])&lt;br /&gt;
  an_agent.call ([U, ...])&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In contrast to [[usage-site variance#Agents|usage-site variance]] you cannot express that the generic parameters of the tuple are covariant. Because of that, the call with a subtype of the actual parameter is not permitted by the type system.&lt;br /&gt;
&lt;br /&gt;
==== Assigning agents ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e&amp;gt;&lt;br /&gt;
local&lt;br /&gt;
  an_agent: PROCEDURE [ANY, TUPLE [T]]&lt;br /&gt;
    -- An agent which takes an argument of type T.&lt;br /&gt;
do&lt;br /&gt;
  agent_empty := agent () do end --&amp;gt; PROCEDURE [ANY, TUPLE []]&lt;br /&gt;
  agent_any := agent (a: ANY) do end --&amp;gt; PROCEDURE [ANY, TUPLE [ANY]]&lt;br /&gt;
  agent_t := agent (t: T) do end --&amp;gt; PROCEDURE [ANY, TUPLE [T]]&lt;br /&gt;
  agent_u := agent (u: U) do end --&amp;gt; PROCEDURE [ANY, TUPLE [U]]&lt;br /&gt;
  agent_tt := agent (t: T; t2: T) do end --&amp;gt; PROCEDURE [ANY, TUPLE [T, T]]&lt;br /&gt;
&lt;br /&gt;
    -- This assignment is naturally allowed.&lt;br /&gt;
  an_agent := agent_t&lt;br /&gt;
&lt;br /&gt;
    -- This assignment is allowed since the tuple is declared contravariant&lt;br /&gt;
    -- and the empty tuple is an ancestor of TUPLE [T]&lt;br /&gt;
  an_agent := agent_empty&lt;br /&gt;
&lt;br /&gt;
    -- This assignment is not allowed although it would be correct. The reason &lt;br /&gt;
    -- is that TUPLE [ANY] is not an ancestor of TUPEL [T].&lt;br /&gt;
  an_agent := agent_any&lt;br /&gt;
&lt;br /&gt;
    -- The following assignments are not permitted by the solution. This is the correct&lt;br /&gt;
    -- behaviour  as you could either create a catcall by passing a T argument to the &lt;br /&gt;
    -- `agent_u' or pass the wrong number of arguments by passing a [T] tuple to the &lt;br /&gt;
    -- `agent_tt'.&lt;br /&gt;
  an_agent := agent_u&lt;br /&gt;
  an_agent := agent_tt&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/e&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, the fact that the generic tuple parameters are novariant causes that a safe assignment is prohibited.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
This solution requires that the libraries are designed in a way which separates reading and writing to generic datastructes. It allows full use of comparator objects but does not fully support agents.&lt;br /&gt;
&lt;br /&gt;
On the plus side, the client of a library does not need to put variance markers as in the [[usage-site variance]] proposal which makes the use of the solution easier for the normal programmer.&lt;/div&gt;</summary>
		<author><name>Seilerm</name></author>	</entry>

	</feed>