<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="">Hello Ilya, <div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 6, 2015, at 3:05 PM, ilya <<a href="mailto:ilya.nikokoshev@gmail.com" class="">ilya.nikokoshev@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="white-space:pre-wrap" class="">Yes, I meant for the email to go to the list. <br class=""><br class="">> Nope, that doesn't work because of my comment above. That's the change to Swift I am hoping will be adopted for 3.0.<br class=""><br class="">Did you try this? The idea is to write a function for multiplying a Number and an Int, so the rhs will create a Number which will then be set to the variable. It should work actually. </div></div></blockquote><div><br class=""></div><div><div>Yes, I've written a class named Number with many "func <operator> ( ... ) { ... }" implementations for the various permutations of Number, Double and operators. They all work except for when <operator> is the equal sign.</div></div><div><br class=""></div><div>Don</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Dec 7, 2015 at 00:47 Don Wills <<a href="mailto:don.wills@portablesoftware.com" class="">don.wills@portablesoftware.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hello Ilya,<div class=""><br class=""></div><div class=""></div></div><div style="word-wrap:break-word" class=""><div class="">On Dec 6, 2015, at 1:09 PM, ilya <<a href="mailto:ilya.nikokoshev@gmail.com" target="_blank" class="">ilya.nikokoshev@gmail.com</a>> wrote:<br class=""></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div>On Sun, Dec 6, 2015 at 5:26 PM, Don Wills via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Silvan,</div><div class=""><br class=""></div>Yes, I understand the concern you raise. I too have held that general opinion of overloading operators in other languages for many years. That said, overloading arithmetic and other operators causes the same opportunity for abuse. </div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">For example, overloading + for integers to do something different (like rounding instead of truncation) would make maintenance of existing programs into a giant guessing game.<div class=""><br class=""></div><div class="">That said, once the cat is out of the bag to overload operators, I don't see how adding support for = makes things any worse.</div><div class=""><br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">This is not really the same. You only use + explicitely, but the compiler must insert some assigments automatically, for example by copying when the function closes over some variables. It must know exactly what the semantics in this case is to be able to compile correct program.</div></div></div></div></div></blockquote><div class=""><br class=""></div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class="">My example wasn't the best. IMO, there is almost no conceptual difference between "amount = 5.5;" and "amount += 5.5;". The second example works (that is += can be overloaded) where the first example is not allowed because when I try to define the "func = (...) {...}" overload implementation, the compiler squawks.</div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><br class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""></div><div class="">FYI, the reason for my suggestion is to add support for fixed decimal arithmetic just like that available in COBOL. Yeh I can hear the groans now. </div></div></blockquote><div class=""><br class=""></div><div class="">I'm with you.</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">However, for business applications, fixed decimal arithmetic is a basic feature that has been tossed away in new languages by language designers who don't actually labor in the trenches. </div></div></blockquote><div class=""><br class=""></div><div class="">I didn't look into the new Foundation, but doesn't it contain NSDecimalNumber? </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""> </div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""> I've built a simple class to do just that - here is some sample code that uses my Number class that gives an idea of what the code does:</div><div class=""><br class=""></div><div class="">var amount = Number(left: 6, right: 2);</div><div class="">var result = Number(left: 9, right: 2);</div><div class="">amount <- 3.9;</div><div class="">amount += 1;</div><div class="">result <- amount * 4;</div><div class="">print(result)</div><div class=""><br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">I'm not sure why you feel the need to overload = in this example. If Number * Int -> Number is defined, you can just use</div><div class=""><br class=""></div><div class="">result = amount * 4</div></div></div></div></div></blockquote><div class=""><br class=""></div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class="">Nope, that doesn't work because of my comment above. That's the change to Swift I am hoping will be adopted for 3.0.</div><div class=""><br class=""></div><div class="">Did you mean to not post your email to me only? I haven't figured out the protocol for this email list yet.</div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class=""><br class=""></div><div class="">Don Wills</div><div class=""><br class=""></div></div></div></div></blockquote></div>
</div></blockquote></div><br class=""></div></body></html>