<div dir="ltr">for "historical record" sake that silly trick works even in a more meaningful way with RegExp replacements  :-)<div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">```js</div><div style="font-size:12.8px">// before</div><div style="font-size:12.8px"><div>'str'.replace(/(some)(thing)/, function ($0, $1, $2) {</div><div>  //  boring $1 $2 like RegExp.$1 and  RegExp.$2</div><div>});</div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">// now</div><div style="font-size:12.8px">'str'.replace(/(some)(thing)/, (...$) => {</div><div style="font-size:12.8px">  // we have $[1], $[2] ... yaiiii</div><div style="font-size:12.8px">});</div></div><div style="font-size:12.8px">```</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Regards</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 12, 2015 at 7:40 AM, Isiah Meadows <span dir="ltr"><<a href="mailto:isiahmeadows@gmail.com" target="_blank">isiahmeadows@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Interesting trick, Andrea. Never thought of that before. </p><div class="HOEnZb"><div class="h5">
<br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 12, 2015, 02:31 Andrea Giammarchi <<a href="mailto:andrea.giammarchi@gmail.com" target="_blank">andrea.giammarchi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">... sort of (no  pun intended)<div><br></div><div>```js</div><div>let sorted = names.sort((...$) => $[0] > $[1]);<br></div><div>```</div><div><br></div><div>Regards</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 12, 2015 at 2:58 AM, Frankie Bagnardi <span dir="ltr"><<a href="mailto:f.bagnardi@gmail.com" target="_blank">f.bagnardi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I don't think there's much value in this. Also sort is a bad example because it'd look like this, and there's no nifty shortcut answer to it.<div><br></div><div>```js</div><div>names.sort((a, b) => a < b ? 1 : a > b ? -1 : 0);<br></div><div>```</div><div><br></div><div>In most cases you save a couple characters, but you can just use x/y/a/b/f/g/n/xs/xss for variable names in arrow functions instead of the $0 (which would likely be \0 in js).</div><div><br></div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 11, 2015 at 3:26 PM, Caitlin Potter <span dir="ltr"><<a href="mailto:caitpotter88@gmail.com" target="_blank">caitpotter88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>In the case of sorting, are arrow functions not good enough? Or are we really asking for full continuation support</div><div><div><div><br>On Oct 11, 2015, at 5:51 PM, Alexander Jones <<a href="mailto:alex@weej.com" target="_blank">alex@weej.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">IMO this is a good idea. When it's abundantly clear from context, I've already been naming my arrow function params _ if singular, and _1, _2 etc if several. As always, picking some punctuation straight from the scarce and sacred set of remaining ASCII symbols is going to be tricky. (If only we could just go APL on this!)</div><div class="gmail_extra"><br><div class="gmail_quote">On 11 October 2015 at 16:45, Mohsen Azimi <span dir="ltr"><<a href="mailto:me@azimi.me" target="_blank">me@azimi.me</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Is it possible to extend JavaScript syntax to support Swift style block syntax[1]?<div><br></div><div>In Swift it's possible to omit return keyword </div><div>```</div><div><ol style="border:0px;font-size:14px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;line-height:1.6em;list-style:none;color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;background-image:initial;background-repeat:initial"><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;color:rgb(255,255,255);list-style-type:none;background:transparent"><code style="border:0px;font-size:0.85em;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,0,0);font-family:Menlo,monospace;word-wrap:break-word;background:transparent"><span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">reversed</span> = <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">names</span>.<span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">sort</span>( { <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">s1</span>, <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">s2</span> <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145);background:transparent">in</span> <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">s1</span> > <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">s2</span> } )</code></li></ol></div><div>```</div><div><br></div><div>or omit argument declaration like this:</div><div><br></div><div>```</div><div><ol style="border:0px;font-size:14px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;line-height:1.6em;list-style:none;color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;background-image:initial;background-repeat:initial"><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;color:rgb(255,255,255);list-style-type:none;background:transparent"><code style="border:0px;font-size:0.85em;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,0,0);font-family:Menlo,monospace;word-wrap:break-word;background:transparent"><span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">reversed</span> = <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">names</span>.<span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">sort</span>( { <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">$0</span> > <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">$1</span> } )</code></li></ol></div><div>```</div><div><br></div><div>or apply an operator to arguments of a function </div><div><br></div><div>```</div><div><ol style="border:0px;font-size:14px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;line-height:1.6em;list-style:none;color:rgb(0,0,0);font-family:Helvetica,Arial,sans-serif;background-image:initial;background-repeat:initial"><li style="border-width:0px 0px 0px 18px;border-left-style:solid;border-left-color:transparent;margin:0px;outline:0px;padding:0px 10px 0px 0px;vertical-align:baseline;white-space:pre-wrap;color:rgb(255,255,255);list-style-type:none;background:transparent"><code style="border:0px;font-size:0.85em;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,0,0);font-family:Menlo,monospace;word-wrap:break-word;background:transparent"><span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">reversed</span> = <span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">names</span>.<span style="border:0px;font-size:11.9px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(63,110,116);background:transparent">sort</span>(>)</code></li></ol></div><div>```</div><div>We have the first feature in ES2015 already:</div><div><br></div><div>```</div><div>let sorted = names.sort((a, b)=> a > b);</div><div>```</div><div><br></div><div>But for omitting argument declaration we need to find an alternative to $0, $1... since those are valid variable names in JS. Maybe we can use #0, #1... instead. </div><div><br></div><div>This is very useful for functional programming aspect of JS. For example in a filter function:</div><div><br></div><div>```</div><div>let passed = objs.filter(#0.passed)</div><div>```</div><div><br></div><div><br></div><div><br></div><div><br></div><div>[1][<a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Closures.html" target="_blank">https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Closures.html</a>]</div></div>
<br>_______________________________________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/listinfo/es-discuss</a><br>
<br></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>es-discuss mailing list</span><br><span><a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a></span><br><span><a href="https://mail.mozilla.org/listinfo/es-discuss" target="_blank">https://mail.mozilla.org/listinfo/es-discuss</a></span><br></div></blockquote></div></div></div><br>_______________________________________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/listinfo/es-discuss</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/listinfo/es-discuss</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/listinfo/es-discuss</a><br>
</blockquote></div>
</div></div></blockquote></div><br></div>