[swift-users] Sampling collections
Dave at Yost.com
Sun Apr 10 18:36:01 CDT 2016
Every package that wraps C functions should be accompanied by a higher-level package that wraps the raw interface in best Swift fashion, IMO.
A C package without higher-level Swift wrappers is an invitation to chaos as a zillion people publish competing higher-level wrappers.
> On 2016-04-10, at 3:12 PM, Jens Alfke via swift-users <swift-users at swift.org> wrote:
>> On Apr 10, 2016, at 1:00 PM, Milos Rankovic <milos at milos-and-slavica.net> wrote:
>> The ObjC–Swift bridge is relevant here only in the sense that I would also like sampling methods added to `NSArray`, `NSSet` or `NSDictionary`…
> Any library or program can add methods to any class using extensions. You can easily implement your own `sample` property. There may be a Swift library somewhere that provides one; all you’d have to do is import it.
> If you want to implement it yourself, you can call the C functions `random` or `arc4random` directly from Swift. (You may need to add an #include to your bridging header in Xcode.)
>> What I would personally like to see, however (and what I was wondering the community feels about), is that one of these frameworks extends Standard Library data types and protocols with this functionality
> So far Apple hasn’t added Swift-specific functionality to system frameworks; the frameworks are in Objective-C or C, and the Swift compiler and runtime bridge to that. What you’re suggesting would go the other direction, with a framework offering custom API wrappers. Maybe that will happen in the near future.
> swift-users mailing list
> swift-users at swift.org
More information about the swift-users