<?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: Dangerous new Language Features: Indexing access syntax for Lists and Maps</title>
	<atom:link href="http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/</link>
	<description></description>
	<lastBuildDate>Thu, 11 Mar 2010 16:23:01 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Frits Jalvingh</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-92050</link>
		<dc:creator>Frits Jalvingh</dc:creator>
		<pubDate>Fri, 10 Jul 2009 12:05:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-92050</guid>
		<description>All of this is kind of nonsense. Of course the &quot;contract&quot; of the assignment operation (returning the assigned value) may not change (that point is validly made) - and it is trivial for the compiler to make that so.

This discussion wrongly assumes that the compiler /must/ use the return value of a put as the &quot;result&quot; of the assignment which is nonsense; it can easily generate trivial code to drop (pop) the result of the put and use it&#039;s second parameter as the &quot;return value&quot;. Using another &quot;method&quot; in whatever map is just nonsense and unnecessary: this requires only a few extra bytecode instrutions to be emitted (a dup and a pop, gee).</description>
		<content:encoded><![CDATA[<p>All of this is kind of nonsense. Of course the &#8220;contract&#8221; of the assignment operation (returning the assigned value) may not change (that point is validly made) &#8211; and it is trivial for the compiler to make that so.</p>
<p>This discussion wrongly assumes that the compiler /must/ use the return value of a put as the &#8220;result&#8221; of the assignment which is nonsense; it can easily generate trivial code to drop (pop) the result of the put and use it&#8217;s second parameter as the &#8220;return value&#8221;. Using another &#8220;method&#8221; in whatever map is just nonsense and unnecessary: this requires only a few extra bytecode instrutions to be emitted (a dup and a pop, gee).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shams</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-91944</link>
		<dc:creator>Shams</dc:creator>
		<pubDate>Tue, 23 Jun 2009 13:54:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-91944</guid>
		<description>The mailing list at Project Coin (http://openjdk.java.net/projects/coin/) would be a nice place to discuss too.</description>
		<content:encoded><![CDATA[<p>The mailing list at Project Coin (<a href="http://openjdk.java.net/projects/coin/" rel="nofollow">http://openjdk.java.net/projects/coin/</a>) would be a nice place to discuss too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian Mueller</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-91942</link>
		<dc:creator>Sebastian Mueller</dc:creator>
		<pubDate>Tue, 23 Jun 2009 12:19:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-91942</guid>
		<description>@Maarten: I saw the proposal and I clearly object to that part of it. it should be rewritten like this, IMHO:

m2[l1[2]] = m2[m1[1]] = 4; // same as HelperClass.assignmentOperator(m2, l1.get(2), HelperClass.assignmentOperator(m2, m1.get(1), 4));

And HelperClass.assignmentOperator should be implemeted as shown earlier to return the assigned value unconditionally. (Of course the compiler could directly inline the code from HelperClass, but at least conceptually it should be done like this.)

I don&#039;t think the the getter should be invoked so that the map gets a chance to &quot;replace&quot; the value as proposed by javer. I think the result should be the same if you do: 
m2[l1[2]] = m2[m1[1]] = 4; 
and
m2[m1[1]] = 4; 
m2[l1[2]] = 4;

(note the order) - the right-most assignment should be &quot;executed&quot; first.

If a developer needs the different (and less common, IMHO) behavior, she can use the slightly more verbose syntax using the put/get methods.</description>
		<content:encoded><![CDATA[<p>@Maarten: I saw the proposal and I clearly object to that part of it. it should be rewritten like this, IMHO:</p>
<p>m2[l1[2]] = m2[m1[1]] = 4; // same as HelperClass.assignmentOperator(m2, l1.get(2), HelperClass.assignmentOperator(m2, m1.get(1), 4));</p>
<p>And HelperClass.assignmentOperator should be implemeted as shown earlier to return the assigned value unconditionally. (Of course the compiler could directly inline the code from HelperClass, but at least conceptually it should be done like this.)</p>
<p>I don&#8217;t think the the getter should be invoked so that the map gets a chance to &#8220;replace&#8221; the value as proposed by javer. I think the result should be the same if you do:<br />
m2[l1[2]] = m2[m1[1]] = 4;<br />
and<br />
m2[m1[1]] = 4;<br />
m2[l1[2]] = 4;</p>
<p>(note the order) &#8211; the right-most assignment should be &#8220;executed&#8221; first.</p>
<p>If a developer needs the different (and less common, IMHO) behavior, she can use the slightly more verbose syntax using the put/get methods.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maarten Winkels</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-91941</link>
		<dc:creator>Maarten Winkels</dc:creator>
		<pubDate>Tue, 23 Jun 2009 10:45:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-91941</guid>
		<description>@Sebastian: I completely agree. The current proposal, however, states:

&lt;pre lang=&quot;java&quot;&gt;
  m2[l1[2]] = m2[m1[1]] = 4; // same as m2.put(l1.get(2), m2.put(m1.get(1), 4));
&lt;/pre&gt;

(see ADVANCED EXAMPLE section)</description>
		<content:encoded><![CDATA[<p>@Sebastian: I completely agree. The current proposal, however, states:</p>
<pre lang="java">
  m2[l1[2]] = m2[m1[1]] = 4; // same as m2.put(l1.get(2), m2.put(m1.get(1), 4));
</pre>
<p>(see ADVANCED EXAMPLE section)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: javer</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-91940</link>
		<dc:creator>javer</dc:creator>
		<pubDate>Tue, 23 Jun 2009 10:32:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-91940</guid>
		<description>better way is to use special interface for &quot;indexed&quot; access - this will work for all collections and lists and all other stuff.</description>
		<content:encoded><![CDATA[<p>better way is to use special interface for &#8220;indexed&#8221; access &#8211; this will work for all collections and lists and all other stuff.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: javer</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-91939</link>
		<dc:creator>javer</dc:creator>
		<pubDate>Tue, 23 Jun 2009 10:08:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-91939</guid>
		<description>residence[&quot;Maarten Winkels&quot;] = residence[&quot;Koningin Beatrix&quot;] = “Palace”;

i think better is to do this way:
residence.put(”Koningin Beatrix”, “Palace”);
residence.put(”Maarten Winkels”, residence.get(”Koningin Beatrix”));

because correct order is from left to right, and semantic of 
residence[&quot;Maarten Winkels&quot;] = residence[&quot;Koningin Beatrix&quot;]; 

have to be transformed into:
residence.put(”Maarten Winkels”, residence.get(”Koningin Beatrix”));</description>
		<content:encoded><![CDATA[<p>residence["Maarten Winkels"] = residence["Koningin Beatrix"] = “Palace”;</p>
<p>i think better is to do this way:<br />
residence.put(”Koningin Beatrix”, “Palace”);<br />
residence.put(”Maarten Winkels”, residence.get(”Koningin Beatrix”));</p>
<p>because correct order is from left to right, and semantic of<br />
residence["Maarten Winkels"] = residence["Koningin Beatrix"]; </p>
<p>have to be transformed into:<br />
residence.put(”Maarten Winkels”, residence.get(”Koningin Beatrix”));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: javer</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-91938</link>
		<dc:creator>javer</dc:creator>
		<pubDate>Tue, 23 Jun 2009 10:04:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-91938</guid>
		<description>how should work int x, y;
x = y = 5;
print(x);
print(y);

what is the result?

let&#039;s change x and y to List.

List x = ...;
List y = ...;

x[0] = y[0] = 5;

This MUST work same way as x = y = 5; And use same semantic.

For my it does not matter will it use put method or any other.
residence[&quot;Maarten Winkels&quot;] = residence[&quot;Koningin Beatrix&quot;] = “Palace”;

should workas:
residence.put(&quot;Koningin Beatrix&quot;, “Palace”);
residence.put(&quot;Maarten Winkels&quot;, “Palace”);</description>
		<content:encoded><![CDATA[<p>how should work int x, y;<br />
x = y = 5;<br />
print(x);<br />
print(y);</p>
<p>what is the result?</p>
<p>let&#8217;s change x and y to List.</p>
<p>List x = &#8230;;<br />
List y = &#8230;;</p>
<p>x[0] = y[0] = 5;</p>
<p>This MUST work same way as x = y = 5; And use same semantic.</p>
<p>For my it does not matter will it use put method or any other.<br />
residence["Maarten Winkels"] = residence["Koningin Beatrix"] = “Palace”;</p>
<p>should workas:<br />
residence.put(&#8221;Koningin Beatrix&#8221;, “Palace”);<br />
residence.put(&#8221;Maarten Winkels&#8221;, “Palace”);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian Mueller</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-91935</link>
		<dc:creator>Sebastian Mueller</dc:creator>
		<pubDate>Tue, 23 Jun 2009 07:46:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-91935</guid>
		<description>Who says that the assignment operator has to directly map to the put/set methods? Why not map to these methods and nevertheless make the expression (that&#039;s what it is conceptually, its not a method call) evaluate to the assigned value. This can be done using the static method I outlined above. 
In Java an assignment expression always evaluates to the assigned value. A method may return whatever it wants. If the language supports the assignment expression as a convenience method for the put/set methods, it should use the assignment semantics and evaluate to the value being assigned. 
This does not make it any more complicated: With the current proposal the developers needs to know that directly the method maps to the put method *and* returns the return value of the put method. Using the other proposal the developer needs to know that it maps to the put method (which is rather obvious) and behaves like the assignment operator does everywhere else in Java (which should be obvious).
If a developer comes across this kind of code without knowing that it maps to the put method, my guess would be that she takes the &quot;assignment-expression-evaluates-to-assigned-value&quot; part for granted, because that is what they *already know*. 
Also think about (hand-)refactoring consequences if change the type of the variable from array to arraylist and forget to adjust the double assignments.</description>
		<content:encoded><![CDATA[<p>Who says that the assignment operator has to directly map to the put/set methods? Why not map to these methods and nevertheless make the expression (that&#8217;s what it is conceptually, its not a method call) evaluate to the assigned value. This can be done using the static method I outlined above.<br />
In Java an assignment expression always evaluates to the assigned value. A method may return whatever it wants. If the language supports the assignment expression as a convenience method for the put/set methods, it should use the assignment semantics and evaluate to the value being assigned.<br />
This does not make it any more complicated: With the current proposal the developers needs to know that directly the method maps to the put method *and* returns the return value of the put method. Using the other proposal the developer needs to know that it maps to the put method (which is rather obvious) and behaves like the assignment operator does everywhere else in Java (which should be obvious).<br />
If a developer comes across this kind of code without knowing that it maps to the put method, my guess would be that she takes the &#8220;assignment-expression-evaluates-to-assigned-value&#8221; part for granted, because that is what they *already know*.<br />
Also think about (hand-)refactoring consequences if change the type of the variable from array to arraylist and forget to adjust the double assignments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RFletch</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-91933</link>
		<dc:creator>RFletch</dc:creator>
		<pubDate>Tue, 23 Jun 2009 06:47:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-91933</guid>
		<description>Noone is ever going to use it in the double assignment case. In fact, I&#039;d be for removing double assignment and getting this feature if people are worried about it given how infrequently double assignment is actually useful to me rather than decoration.</description>
		<content:encoded><![CDATA[<p>Noone is ever going to use it in the double assignment case. In fact, I&#8217;d be for removing double assignment and getting this feature if people are worried about it given how infrequently double assignment is actually useful to me rather than decoration.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kaj</title>
		<link>http://blog.xebia.com/2009/06/20/dangerous-new-language-features-indexing-access-syntax-for-lists-and-maps/comment-page-1/#comment-91932</link>
		<dc:creator>Kaj</dc:creator>
		<pubDate>Tue, 23 Jun 2009 06:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xebia.com/?p=2081#comment-91932</guid>
		<description>I don&#039;t see this a huge problem. There will always be developers that write code that is hard to understand, and I really really doubt that you often will see code like:

residence[&quot;Maarten Winkels&quot;] = residence[&quot;Koningin Beatrix&quot;] = &quot;Palace&quot;;

(And I actually read that correct when I read it, since I knew that put returns the previous value). Boxing/Unboxing is far more dangerous.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t see this a huge problem. There will always be developers that write code that is hard to understand, and I really really doubt that you often will see code like:</p>
<p>residence["Maarten Winkels"] = residence["Koningin Beatrix"] = &#8220;Palace&#8221;;</p>
<p>(And I actually read that correct when I read it, since I knew that put returns the previous value). Boxing/Unboxing is far more dangerous.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
