<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=""><div><blockquote type="cite" class=""><div class="">On Jul 31, 2017, at 10:23 PM, Daryle Walker via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</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="">Could we do better than simple repetition? What if we define a “$$n” unit, where “n” is a nonnegative integer. For each comma-separated item, the unit will be replaced by increasing compiler-constant integers from zero. If using an expression, maybe you can call a function on the double-dollar value to get your own custom values there. This can be expanded to types once value-based generic parameters get added.</div><div class=""><br class=""></div><div class="">When there are nested #dup calls, the double-dollar unit refers to the counter for the innermost #dup. Maybe there can be a triple-dollar unit for the immediately enclosing #dup. Even quadruple- or more-dollar units for the outer levels. (Hopefully, nothing more that one level would be needed.)</div></div></div></blockquote><br class=""></div><div>Upon waking up, I realized I got this part of the idea completely wrong. Within the right side of a #dup, there is only one counter, so numbers wouldn’t be necessary after the “$$”.</div><div><br class=""></div><div>However, we could use numbers to replace the triple-, quadruple-, etc. dollar-sign idea. So “$$0” is the counter for the current #dup, “$$1” is the counter for the immediately surrounding #dup, and higher numbers go for outer layers. Upon expansion, “$$0” goes to the index number of the comma-separated entity, while “$$n” goes to “$$(n - 1)”. It’s an error to still have double-dollar symbols remaining after the outermost #dup is expanded.</div><div><br class=""></div><div>Oh, the right side of the #dup can take a type, an expression, or a comma-separated list of one of those.</div><div><br class=""></div><div>Here’s an example using theoretical fixed-size arrays:</div><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Monaco" class="">let tupleOf12 = ( (2, 3, 5, 7), (4, 6, 8, 9), (10, 11, 12, 1) )</font></div><div class=""><font face="Monaco" class="">let arrayOf12 = { 3, 4 ; #dup(3; #dup(4; tupleOf12 . $$1 . $$0 ) ) }</font></div><div class=""><font face="Monaco" class="">assert( tupleOf12.0.0 == arrayOf12[0, 0] ) &nbsp;// 2</font></div><div class=""><font face="Monaco" class="">//…</font></div><div class=""><font face="Monaco" class="">assert( tupleOf12.2.3 == arrayOf12[2, 3] ) &nbsp;// 1</font></div></blockquote><div class=""><br class=""></div><div class="">So resolving the inner #dup gives:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Monaco" class="">#dup(3; tupleOf12 . $$0 . 0, tupleOf12 . $$0 . 1, tupleOf12 . $$0 . 2, tupleOf12 . $$0 . 3 )</font></div></blockquote><div class=""><br class=""></div><div class="">And doing the remaining #dup gives:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Monaco" class="">tupleOf12 . 0 . 0, tupleOf12 . 0 . 1, tupleOf12 . 0 . 2, tupleOf12 . 0 . 3, tupleOf12 . 1 . 0, tupleOf12 . 1 . 1, tupleOf12 . 1 . 2, tupleOf12 . 1 . 3, tupleOf12 . 2. 0, tupleOf12 . 2 . 1, tupleOf12 . 2 . 2, tupleOf12 . 2 . 3</font></div></blockquote><div class=""><br class=""></div><div class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">—&nbsp;</div><div class="">Daryle Walker<br class="">Mac, Internet, and Video Game Junkie<br class="">darylew AT mac DOT com&nbsp;</div></div></div><br class=""><div><blockquote type="cite" class=""></blockquote></div></div></body></html>