[swift-corelibs-dev] incomplete implementation warning functions
willstanton1 at yahoo.com
Thu Jan 21 16:27:55 CST 2016
In my view, crashing immediately isn’t best when ‘most’ of the implementation is present. A function could work most of the time but still need some work – no need to always crash.
Is it possible to conditionally call NSUnimplemented, in the cases where something doesn’t work? Maybe, but it might not be worth the time to write the potentially numerous checks.
Also, I would rather see messages in the console about something which might not work over nothing (i.e. a partial implementation).
I like the current rate of review and merges, but ex. NSDateFormatter doesn’t fully implement its time/date style properties, and this appears to have led to confusion: The submitter of SR-208 https://bugs.swift.org/browse/SR-208 spent time writing up cases and investigating the Swift toolchain, when there’s a telling line in NSDateFormatter.swift saying // TODO: Set up attributes here
A function like NSWarnIncompleteImplementation(“Date formatter attributes not set”) could have saved some time (presuming the console message was understood)!
> On Jan 21, 2016, at 1:04 PM, Tony Parker via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
> Hi Will,
> The reason we chose fatalError() was that we felt that the safest course of action when reaching unimplemented code was to immediately crash. If we continue instead, aren’t we putting the app into an unknown state?
> - Tony
>> On Jan 21, 2016, at 2:55 AM, Will Stanton via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
>> I would like to propose functions that warn about incomplete implementations without calling NSUnimplemented/fatalError. They could provide a standard interface for reminding/warning about incomplete implementations while things are being built.
>> I was thinking of two utility functions:
>> 1) NSWarnIncompleteImplementation: Prints a warning message once. Can make potential issues clear (without flooding the console), particularly for classes where most of the implementation is there, but something could fail for certain parameters/configurations.
>> 2) NSWarnUnimplemented: prints a warning on each call, ex. in a setter that doesn’t do anything
>> Something like:
>> Are there are any recommendations/thoughts about incorporating these functions?
>> Will Stanton
More information about the swift-corelibs-dev