<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 7, 2017, at 23:37, Derrick Ho <<a href="mailto:wh1pch81n@gmail.com" class="">wh1pch81n@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I think pattern matching is the most compelling reason to keep tuples.<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span></span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">If they were gone, how would we replace the following?</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">switch (a, b) {</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">case (value1, value2):</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">case (value3, value4):</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">}</span></div></blockquote></div><br class=""><div class="">I meant to mention this: Smalltalk - Objective C's mother language - has no switch statement (or 'if' or loops either). The language is incredibly malleable because it only does one thing - send messages to objects and all the language constructs are in the library. It would take very little time to add one. Off and on someone does it as an exercise but it never sticks.</div><div class=""><br class=""></div><div class="">Instead, you just use a dictionary of closures. An Objective C equivalent might be:</div><div class=""><br class=""></div><div class="">NSDictionary* switch = @{</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>@[@0,@1]: ^{ NSLog(@"zero one"); },<span class="Apple-tab-span" style="white-space: pre;">        </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>@[@1,@1]: ^{ NSLog(@"one one"); }</div><div class="">};</div><div class=""><br class=""></div><div class="">NSArray* pair = @[@3, @5];</div><div class=""><br class=""></div><div class="">(switch at:pair ifAbsent:^{})(); //where at:ifAbsent: is added in the Smalltalk style as an extension.</div><div class=""><br class=""></div><div class="">The Smalltalk equivalent (much less ugly because of the lack of @'s) is</div><div class=""><br class=""></div><div class=""> switch := {</div><div class=""> #(0 1) -> [ Transcript nextPutAll: 'zero one' ] .</div><div class=""> #(1 1) -> [ Transcript nextPutAll: 'one one' ] . </div><div class=""> #(1 2) -> [ Transcript nextPutAll: 'one two' ] .</div><div class="">} asDictionary.</div><div class=""><br class=""></div><div class="">(switch at: pair ifAbsent:[ [] ]) value.</div><div class=""><br class=""></div><div class="">So its not like this is some kind of key feature. Switch's vs dictionaries of closures - pretty much the same thing as pattern matching goes. The only thing you have to do is put an object at key that identifies itself as equal to the pattern you will throw at it.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>