<?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: Scala Goodness: Tuples</title>
	<atom:link href="http://codemonkeyism.com/tuples-scala-goodness/feed/" rel="self" type="application/rss+xml" />
	<link>http://codemonkeyism.com/tuples-scala-goodness/</link>
	<description></description>
	<lastBuildDate>Fri, 30 Jul 2010 06:49:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Graham Lea</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-287472</link>
		<dc:creator>Graham Lea</dc:creator>
		<pubDate>Thu, 29 Apr 2010 12:47:38 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-287472</guid>
		<description>I use tuples quite a bit internally - i.e. in private functions - especially when it is necessary to return two or more values from one function to another. However, I avoid using tuples at the interfaces between components (classes/objects) because I think the interfaces at these boundaries need to be more self-descriptive than just &quot;a pair of things&quot;. I&#039;d use a strong type at these points, and would always try to avoid returning two things from a public function.</description>
		<content:encoded><![CDATA[<p>I use tuples quite a bit internally &#8211; i.e. in private functions &#8211; especially when it is necessary to return two or more values from one function to another. However, I avoid using tuples at the interfaces between components (classes/objects) because I think the interfaces at these boundaries need to be more self-descriptive than just &#8220;a pair of things&#8221;. I&#8217;d use a strong type at these points, and would always try to avoid returning two things from a public function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: usr</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-265048</link>
		<dc:creator>usr</dc:creator>
		<pubDate>Fri, 15 Jan 2010 01:02:28 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-265048</guid>
		<description>That certainly should have been:

&quot;If i’d have to chose between Tuple2[Bar, Baz] and case class Foo(bar:Int, baz:Int) i’d take the tuple variant without hesitation, all the time.&quot;

The rest of the post was meandering ramblings anyway.</description>
		<content:encoded><![CDATA[<p>That certainly should have been:</p>
<p>&#8220;If i’d have to chose between Tuple2[Bar, Baz] and case class Foo(bar:Int, baz:Int) i’d take the tuple variant without hesitation, all the time.&#8221;</p>
<p>The rest of the post was meandering ramblings anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: usr</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-265044</link>
		<dc:creator>usr</dc:creator>
		<pubDate>Fri, 15 Jan 2010 00:53:15 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-265044</guid>
		<description>@&quot;tuple fear&quot;:

Using tuples instead of proper domain classes isn&#039;t that much of a problem - as long as your tuple members are proper domain types and not just raw primitives.

If i&#039;d have a choice between Pair[Bar, Baz] than class Foo(bar:Int, baz:Int) i&#039;d take the tuple without hesitation.

Most value-carrier classes are defined pretty well by the types of their members, provided the member types are meaningful. Slapping a name tag to that composition of member types is only a convenience (or waste of time, some might argue), as long as that specific composition of member types is unique in that there is no need to partition the set of instances of that specific composition of member types into multiple classes.

It even happened on this blog: http://codemonkeyism.com/never-never-never-use-string-in-java-or-at-least-less-often/

Thinking further along this line i think it really is sad that Scala does not provide a way to specialize from final classes (or maybe that possibility exists and i just don&#039;t know about it, which would give the sadness a more local scope). Of course subtyping from final types would have to be limited to &quot;straight&quot; subclassing (not adding or changing structure or behaviour), but it would be just so very handy for semantic types like FirstName or LastName. It wouldn&#039;t even be a big loss if those &quot;straight subtypes&quot; would fall victim to erasure, as their main utility would be at compile time (and this limitation could make it possible to keep the instances-of-primitive-classes-are-primitives-at-runtime magic in place for subtypes of, say, Int, which would certainly be of biggest importance).

I&#039;m sure Scala has some very nice tricks to emulate subtyping from from finals (just think of what RichString does), but that would open the gates for structural/behavioral changes as well which might not be so good. Also, there is little chance for transparent suptyped primitives that way.</description>
		<content:encoded><![CDATA[<p>@&#8221;tuple fear&#8221;:</p>
<p>Using tuples instead of proper domain classes isn&#8217;t that much of a problem &#8211; as long as your tuple members are proper domain types and not just raw primitives.</p>
<p>If i&#8217;d have a choice between Pair[Bar, Baz] than class Foo(bar:Int, baz:Int) i&#8217;d take the tuple without hesitation.</p>
<p>Most value-carrier classes are defined pretty well by the types of their members, provided the member types are meaningful. Slapping a name tag to that composition of member types is only a convenience (or waste of time, some might argue), as long as that specific composition of member types is unique in that there is no need to partition the set of instances of that specific composition of member types into multiple classes.</p>
<p>It even happened on this blog: <a href="http://codemonkeyism.com/never-never-never-use-string-in-java-or-at-least-less-often/" rel="nofollow">http://codemonkeyism.com/never-never-never-use-string-in-java-or-at-least-less-often/</a></p>
<p>Thinking further along this line i think it really is sad that Scala does not provide a way to specialize from final classes (or maybe that possibility exists and i just don&#8217;t know about it, which would give the sadness a more local scope). Of course subtyping from final types would have to be limited to &#8220;straight&#8221; subclassing (not adding or changing structure or behaviour), but it would be just so very handy for semantic types like FirstName or LastName. It wouldn&#8217;t even be a big loss if those &#8220;straight subtypes&#8221; would fall victim to erasure, as their main utility would be at compile time (and this limitation could make it possible to keep the instances-of-primitive-classes-are-primitives-at-runtime magic in place for subtypes of, say, Int, which would certainly be of biggest importance).</p>
<p>I&#8217;m sure Scala has some very nice tricks to emulate subtyping from from finals (just think of what RichString does), but that would open the gates for structural/behavioral changes as well which might not be so good. Also, there is little chance for transparent suptyped primitives that way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264654</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Wed, 13 Jan 2010 09:13:08 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264654</guid>
		<description>@Dave: I consider the ._1 syntax also ugly</description>
		<content:encoded><![CDATA[<p>@Dave: I consider the ._1 syntax also ugly</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264653</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Wed, 13 Jan 2010 09:12:41 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264653</guid>
		<description>@Mirko: +1</description>
		<content:encoded><![CDATA[<p>@Mirko: +1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mirko</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264513</link>
		<dc:creator>Mirko</dc:creator>
		<pubDate>Tue, 12 Jan 2010 20:54:07 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264513</guid>
		<description>Coming from a python background I know the power of lists and tuples. However nowadays I consider them as a bit dangerous having seen tuples abused in constructs like:
if e[6][7][8] == 2:
   do something
where a real object would have been a better solution.
Regards
Mirko</description>
		<content:encoded><![CDATA[<p>Coming from a python background I know the power of lists and tuples. However nowadays I consider them as a bit dangerous having seen tuples abused in constructs like:<br />
if e[6][7][8] == 2:<br />
   do something<br />
where a real object would have been a better solution.<br />
Regards<br />
Mirko</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264480</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Tue, 12 Jan 2010 17:59:04 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264480</guid>
		<description>The ._1 syntax is pretty ugly, IMO but there wasn&#039;t much that could be done, I suppose.  I think Tuples are great when you need multiple return values; the Java way is an array of Object (ugh).

Also, FWIW, I wrote a blog post deconstructing how the &quot;map literal&quot; works, wrt to ArrowAssoc and Tuples, for anyone interested:

http://www.naildrivin5.com/blog/2009/11/12/deconstructing-scala-map-literal.html

http://www.naildrivin5.com/blog/2009/11/24/scalas-map-literal-as-a-prezi.html</description>
		<content:encoded><![CDATA[<p>The ._1 syntax is pretty ugly, IMO but there wasn&#8217;t much that could be done, I suppose.  I think Tuples are great when you need multiple return values; the Java way is an array of Object (ugh).</p>
<p>Also, FWIW, I wrote a blog post deconstructing how the &#8220;map literal&#8221; works, wrt to ArrowAssoc and Tuples, for anyone interested:</p>
<p><a href="http://www.naildrivin5.com/blog/2009/11/12/deconstructing-scala-map-literal.html" rel="nofollow">http://www.naildrivin5.com/blog/2009/11/12/deconstructing-scala-map-literal.html</a></p>
<p><a href="http://www.naildrivin5.com/blog/2009/11/24/scalas-map-literal-as-a-prezi.html" rel="nofollow">http://www.naildrivin5.com/blog/2009/11/24/scalas-map-literal-as-a-prezi.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264460</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Tue, 12 Jan 2010 15:45:30 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264460</guid>
		<description>Stephan - Yep.  I will admit that I do use tuples (because they&#039;re darned handy), I just felt a little dirty doing it.

Also, I was wrong.  It&#039;s connascence of position.  Here&#039;s Jim Weirich&#039;s definition:  http://onestepback.org/articles/connascence/conposition.html

I&#039;d never heard of connascence until Jim&#039;s presentation at the Software Craftsmanship NA conference in August.

Good stuff.  Thanks.</description>
		<content:encoded><![CDATA[<p>Stephan &#8211; Yep.  I will admit that I do use tuples (because they&#8217;re darned handy), I just felt a little dirty doing it.</p>
<p>Also, I was wrong.  It&#8217;s connascence of position.  Here&#8217;s Jim Weirich&#8217;s definition:  <a href="http://onestepback.org/articles/connascence/conposition.html" rel="nofollow">http://onestepback.org/articles/connascence/conposition.html</a></p>
<p>I&#8217;d never heard of connascence until Jim&#8217;s presentation at the Software Craftsmanship NA conference in August.</p>
<p>Good stuff.  Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luc</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264408</link>
		<dc:creator>Luc</dc:creator>
		<pubDate>Tue, 12 Jan 2010 10:55:41 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264408</guid>
		<description>Tuple rocks !
What a shame to return a List when you know you will always return two elements !</description>
		<content:encoded><![CDATA[<p>Tuple rocks !<br />
What a shame to return a List when you know you will always return two elements !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264340</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Tue, 12 Jan 2010 05:29:52 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264340</guid>
		<description>@Dan, @Jamie: As I worte: &quot;Side note: Contrary to others I think you should consider creating a class as the return type, if it does contain semantic value and you reuse the type.&quot;</description>
		<content:encoded><![CDATA[<p>@Dan, @Jamie: As I worte: &#8220;Side note: Contrary to others I think you should consider creating a class as the return type, if it does contain semantic value and you reuse the type.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dan</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264316</link>
		<dc:creator>dan</dc:creator>
		<pubDate>Tue, 12 Jan 2010 03:26:50 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264316</guid>
		<description>handy for scripting/glue code, but i really don&#039;t like the idea of using this sort of construct in any language where you can define an object.

in your examples above, it really isn&#039;t ever clear what those numbers actually represent. a lot nicer to make a Vector2 class, or a ReturnValues class or something, to actually represent what each of those numbers mean.</description>
		<content:encoded><![CDATA[<p>handy for scripting/glue code, but i really don&#8217;t like the idea of using this sort of construct in any language where you can define an object.</p>
<p>in your examples above, it really isn&#8217;t ever clear what those numbers actually represent. a lot nicer to make a Vector2 class, or a ReturnValues class or something, to actually represent what each of those numbers mean.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264231</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Mon, 11 Jan 2010 22:25:56 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264231</guid>
		<description>I do enjoy coding in Scala, and I&#039;m fortunate enough to be employed on a project that utilizes the language.  However, I think tuples are a dangerous toy.  Anyone using a tuple is inherently coupled with the entity that returned it, because you have to know exactly what is in it at each of its values.

This is a form of execution connascence, and that bothers me.</description>
		<content:encoded><![CDATA[<p>I do enjoy coding in Scala, and I&#8217;m fortunate enough to be employed on a project that utilizes the language.  However, I think tuples are a dangerous toy.  Anyone using a tuple is inherently coupled with the entity that returned it, because you have to know exactly what is in it at each of its values.</p>
<p>This is a form of execution connascence, and that bothers me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264212</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Mon, 11 Jan 2010 20:34:36 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264212</guid>
		<description>@Richard: And thanks for &quot;Keep up the excellent writing!&quot;</description>
		<content:encoded><![CDATA[<p>@Richard: And thanks for &#8220;Keep up the excellent writing!&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264211</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Mon, 11 Jan 2010 20:34:05 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264211</guid>
		<description>@Richard: Shame on me, I will try harder in the future. When thinking about it I know the when to use &quot;its&quot; vs. &quot;it&#039;s&quot; - but not when I&#039;m writing. More quality next time. Promised.</description>
		<content:encoded><![CDATA[<p>@Richard: Shame on me, I will try harder in the future. When thinking about it I know the when to use &#8220;its&#8221; vs. &#8220;it&#8217;s&#8221; &#8211; but not when I&#8217;m writing. More quality next time. Promised.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephan</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264176</link>
		<dc:creator>stephan</dc:creator>
		<pubDate>Mon, 11 Jan 2010 17:35:38 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264176</guid>
		<description>&quot;ArrowAssoc also has a → method which should render as a Unicode arrow, which is interesting.&quot;

Didn&#039;t know - nice.</description>
		<content:encoded><![CDATA[<p>&#8220;ArrowAssoc also has a → method which should render as a Unicode arrow, which is interesting.&#8221;</p>
<p>Didn&#8217;t know &#8211; nice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zach Cox</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264156</link>
		<dc:creator>Zach Cox</dc:creator>
		<pubDate>Mon, 11 Jan 2010 15:09:01 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264156</guid>
		<description>There&#039;s an implicit method in Predef that provides the a-&gt;b Tuple2 creation trick:

http://www.scala-lang.org/docu/files/api/scala/Predef$object.html#any2ArrowAssoc%28A%29

any2ArrowAssoc wraps a in a new ArrowAssoc object, and then ArrowAssoc&#039;s -&gt; method returns Tuple2(a,b).  Pretty slick!

ArrowAssoc also has a → method which should render as a Unicode arrow, which is interesting.</description>
		<content:encoded><![CDATA[<p>There&#8217;s an implicit method in Predef that provides the a-&gt;b Tuple2 creation trick:</p>
<p><a href="http://www.scala-lang.org/docu/files/api/scala/Predef$object.html#any2ArrowAssoc%28A%29" rel="nofollow">http://www.scala-lang.org/docu/files/api/scala/Predef$object.html#any2ArrowAssoc%28A%29</a></p>
<p>any2ArrowAssoc wraps a in a new ArrowAssoc object, and then ArrowAssoc&#8217;s -&gt; method returns Tuple2(a,b).  Pretty slick!</p>
<p>ArrowAssoc also has a → method which should render as a Unicode arrow, which is interesting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard</title>
		<link>http://codemonkeyism.com/tuples-scala-goodness/comment-page-1/#comment-264155</link>
		<dc:creator>Richard</dc:creator>
		<pubDate>Mon, 11 Jan 2010 15:02:25 +0000</pubDate>
		<guid isPermaLink="false">http://codemonkeyism.com/?p=1395#comment-264155</guid>
		<description>Hi Stephan, since your English is already so good, you might as well aim for 100% by correcting your use of &quot;its&quot; versus &quot;it&#039;s&quot;

http://www.askoxford.com/asktheexperts/faq/aboutgrammar/apostrophe

Keep up the excellent writing!</description>
		<content:encoded><![CDATA[<p>Hi Stephan, since your English is already so good, you might as well aim for 100% by correcting your use of &#8220;its&#8221; versus &#8220;it&#8217;s&#8221;</p>
<p><a href="http://www.askoxford.com/asktheexperts/faq/aboutgrammar/apostrophe" rel="nofollow">http://www.askoxford.com/asktheexperts/faq/aboutgrammar/apostrophe</a></p>
<p>Keep up the excellent writing!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 4/27 queries in 0.019 seconds using disk

Served from: codemonkeyism.com @ 2010-07-30 12:35:13 -->