<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>This thread is related to the thread I started last night about Foundation and value types. &nbsp;</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Ideally all Foundation types that are already structs would expose a more Swifty interface and those that are naturally value types but currently implemented as classes would be bridged and exposed in Swift as value types. &nbsp;</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Responses last night seem to indicate at least some appetite for doing this if an acceptable bridging strategy can be identified even though it increases scope a bit as it is not directly related to portability. &nbsp;</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">I would be extremely pleased if we are able to pull this off as it should be possible to design value types by composing Date, URL, Decimal, etc without needing to create our own value type wrappers for them.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Matthew</div><div id="AppleMailSignature"><br>Sent from my iPhone</div><div><br>On Dec 11, 2015, at 9:45 AM, Philippe Hausler via swift-corelibs-dev &lt;<a href="mailto:swift-corelibs-dev@swift.org">swift-corelibs-dev@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div class="">NSDecimalNumber is mostly just a simple object wrapper for NSDecimal that interoperates with NSNumber so that seems like a pretty sensible approach ordering.</div><div class=""><br class=""></div><div class="">Since the goal of the swift-corelibs-foundation is to as closely match the current APIs of Foundation as possible (exclusions have been made where it just isn’t possible); so I would say that option 1 would be the more appropriate way to start off.&nbsp;</div><div class=""><br class=""></div><div class=""><a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/NumbersandValues/Articles/DecimalNumbers.html" class="">https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/NumbersandValues/Articles/DecimalNumbers.html</a> might be a decent place to get a little bit of background; my suggestion however would be to write some really good unit tests to verify it’s behavior.&nbsp;</div><div class=""><br class=""></div><div class="">Eventually we would like to archive these things so keeping it the same structure is probably a good idea.</div><div class=""><br class=""></div><div class="">That all being said - NSDecimal itself seems reasonably suitable for a re-look from a swift perspective. NSDecimalAdd, NSDecimalSubtract etc all really would be more wonderful with operators and some instance methods/properties would be really useful as well. The implementation of NSDecimal and these additions are two different pieces and should be considered separately as well. In that any change that we make to diverge from usage immediately will not be directly usable on Mac OS X/iOS since we will have to work that into the foundation overlay and/or make modifications to the Foundation implementation for supporting any changes like that.&nbsp;</div><div class=""><br class=""></div><div class="">So in short: #1 is the suggested route for a pull request onto Foundation and #2 is a better route for a proposal for swift-evolution (specifically targeted at Foundation).</div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 11, 2015, at 4:32 AM, Florian Reinhart via swift-corelibs-dev &lt;<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@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="">Hi all,<div class=""><br class=""></div><div class="">Is someone already working on NSDecimal and/or NSDecimalNumber? If not I would like to help and have a few questions on how to best tackle this.</div><div class=""><br class=""></div><div class="">I think it’s best to start with NSDecimal and then use NSDecimal to create NSDecimalNumber. That’s why I want to concentrate on NSDecimal first. As far as I know there is no CF type we can utilize for NSDecimal and the existing interface is not Swift-like. I see two possible approaches here:</div><div class=""><ol class=""><li class="">We try to match the existing interface of NSDecimal as close as possible and only provide the same function interface with UnsafePointers all over the place</li><li class="">We create a Swift-like version of the NSDecimal struct. This struct stores its data in private properties and exposes methods (add, multiply, etc.) and computed properties (isNaN, etc.). Additionally, to achieve compatibility with the existing Foundation NSDecimal, we provide the same functions that take NSDecimal pointers and internally use the methods of the Swift struct.</li></ol></div><div class="">What do you think?</div><div class=""><br class=""></div><div class="">Unfortunately, I haven’t found a lot of documentation for NSDecimal, yet. Is there any documentation, which describes the NSDecimal functions?</div><div class=""><br class=""></div><div class="">—Florian</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=0mkChau6XnFV-2FCNUik62L9ZaldD0W0ziOwj-2F3jLx368di0te0jgFEb-2FNGvxpG6mC-2BhzwVB2NrhTE8ZHA66t18BjL-2BbKozUfUztSr1laAylQAwHns4DviPud0JDgdBmE-2BgPjhUgUFmo1P42DHen7wm1IcXzQHwfOuf6nKvsMNQhz-2Fh354r-2B8MpSKarCY3CB6jU9IxhlbF6-2BCMn0T1XUlT9Le-2FIigOplH1yJH2QUqFu4w-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a><br class=""></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=eLFMrKDT8iBxZ-2Fbnk-2BZqvSchNN-2FvYXdceA0T7VxwkAcoumvhdab-2FwDhZc-2Bl7xqA9O-2BlP3FTKNtUgEnNEVNtZRQQ3o7dCjqIaI8VUDpaef5l0Jadu-2BTTzC3sc5K7VqxRIH37lejVsdaaV8woqv54vaUJ6YMbWc4isdQtNoNFd2-2FJ9D1IvxDlV0aFEaqr3f1Y8S8gE5ZCHw7RwXqQaF5HP-2B5Ed6np4vWUDdxNlt3SDNXc-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-corelibs-dev mailing list</span><br><span><a href="mailto:swift-corelibs-dev@swift.org">swift-corelibs-dev@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a></span><br></div></blockquote></body></html>