<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">It has probably been 6 months since I have had time to do anything interesting (JDK6 + Oracle SQL recently for contracts recently) so if I am messing up terminology or syntax - please excuse me. &nbsp;I messed a few things up and had to open up an old Scala project to remind me what I was doing.<div class=""><br class=""></div><div class=""><br class=""></div><div class="">The standard map syntax for Scala is:</div><div class=""><br class=""></div><div class=""><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>a.map(x =&gt; x + 5)</div><div class=""><br class=""></div><div class="">or using a placeholder (very limited shorthand - cannot use a placeholder twice for the same value):</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>a.map(_ + 5)</div><div class=""><br class=""></div><div class="">if it is a tuple then</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>a.map(x =&gt; f(x._1, x._2))</div><div class=""><br class=""></div><div class="">or you can pass in a function block (with pattern matching case)</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>a.map { case (x, y) =&gt; (y, x) }</div><div class=""><br class=""></div><div class="">there might be some mathematical reason behind the “in” keyword - but it is lost on me as well (it has been a good 30 years since University) and gets lost on me. &nbsp;If I had more time I might get use to it.</div><div class=""><br class=""></div><div class="">I hope I did not mess up those examples as bad.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">&nbsp;</div><div class=""><br class=""></div><div class=""><div class=""><div><blockquote type="cite" class=""><div class="">On 2015-12-23, at 9:52:46, Andrey Tarantsov &lt;<a href="mailto:andrey@tarantsov.com" class="">andrey@tarantsov.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="">foo.map( bar =&gt; bar.boz) // single line<br class=""></div></div></blockquote><div class=""><br class=""></div>Well how important is it to use () instead of {} here?</div><div class=""><br class=""></div><div class="">If you make it</div><div class=""><br class=""></div><div class="">foo.map { bar =&gt; bar.boz }</div><div class=""><br class=""></div><div class="">then it's like it is now, but with "in" replace by "=&gt;".</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div class="">foo.map { (x, y) =&gt; x * 5 + y }<br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">I actually like the bare version:</div><div class=""><br class=""></div><div class="">foo.map { x, y =&gt; x * 5 + y }</div><div class=""><br class=""></div><div class="">but not in your example (here it looks atrocious). Take this real code, though:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; constrain(topBlock, tableView, view) { top, tbl, sup <span style="font-variant-ligatures: no-common-ligatures; color: #35568a" class="">in</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top.left&nbsp; == sup.left + horizPadding</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top.right == sup.right - horizPadding</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top.top &nbsp; == sup.top&nbsp; + topPadding</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tbl.top&nbsp; &nbsp; == top.bottom + <span style="font-variant-ligatures: no-common-ligatures; color: #35568a" class="">16</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tbl.bottom == sup.bottom</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><br class=""></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tbl.left&nbsp; == sup.left + horizPadding - horizTableHang</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tbl.right == sup.right - horizPadding + horizTableHang</div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class=""><br class=""></div><div class="">I think the lack of parens is beneficial in reducing the visual noise here.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">And yes, I certainly would prefer `=&gt;` rather than `in`.</blockquote><div class=""><br class=""></div><div class="">It seems like the community can actually agree on this.</div><div class=""><br class=""></div><div class="">Does anyone know if it has any parsing problems / grammar implications right now?&nbsp;</div><br class=""><blockquote type="cite" class=""> I think a big problem with `in` is that it’s textual, and doesn’t provide a clear visual separation from keywords/names at the start of the body or the end of the type specifier.</blockquote><div class=""><br class=""></div><div class="">Yes, agreed. “Not delimited enough”.</div><br class=""><blockquote type="cite" class=""> (Are the [parentheses] around `bar` in your example required? I’m ambivalent to them.)<br class=""></blockquote><div class=""><br class=""></div><div class="">No, they are not, as shown above.</div><br class=""><blockquote type="cite" class="">To be clear, I’m still not a fan of the Ruby syntax. I think it makes the parsing easier for a compiler but harder for a human…</blockquote><div class=""><br class=""></div><div class="">Depends on the human. To this specific human, the Ruby-style one is the easiest to parse (and mind you, I had <i class="">very</i> limited experience with Ruby compared to other languages, so it's not just being used to it, but rather an honest love and preference).</div><div class=""><br class=""></div><div class="">A.</div></div><div class=""><br class=""></div></div></div></div></div></blockquote></div><br class=""></div></div></div></body></html>