Mark NSUnimplemented functions as unavailable.


(Sergej Jaskiewicz) #1

I was wondering why cannot we just mark all the methods/properties/functions in Swift Foundation that are NSUnimplemented or call a subroutine that is NSUnimplemented like this:

@available(*, unavailable, message: “foo is not implemented yet”)
func foo() { NSUnimplemented() }

In this case we can be sure at compile time that we don’t use code that will definitely crash.


(Tony Parker) #2

Hi Sergej,

This is a good idea, but there are some additional things to consider. In some cases, methods are partially unimplemented (with edge cases, or at least less common cases remaining unfinished). The availability macro can’t reflect that status.

In other cases, we want to partially implement one function but still call through to an unimplemented function. The entire call may fail with the assert, but at least we have part of the implementation in place.

- Tony

···

On May 10, 2017, at 4:01 PM, Sergej Jaskiewicz via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

I was wondering why cannot we just mark all the methods/properties/functions in Swift Foundation that are NSUnimplemented or call a subroutine that is NSUnimplemented like this:

@available(*, unavailable, message: “foo is not implemented yet”)
func foo() { NSUnimplemented() }

In this case we can be sure at compile time that we don’t use code that will definitely crash.
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Shouldn’t Foundation give off warnings when NSUnimplemented is bound to appear?
(Philippe Hausler) #3

This of course is predicated upon availability macros working appropriately on linux (which last time I checked we don’t have a version variant). It is definitely worth investigation.

···

On May 10, 2017, at 16:41, Tony Parker via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

Hi Sergej,

This is a good idea, but there are some additional things to consider. In some cases, methods are partially unimplemented (with edge cases, or at least less common cases remaining unfinished). The availability macro can’t reflect that status.

In other cases, we want to partially implement one function but still call through to an unimplemented function. The entire call may fail with the assert, but at least we have part of the implementation in place.

- Tony

On May 10, 2017, at 4:01 PM, Sergej Jaskiewicz via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

I was wondering why cannot we just mark all the methods/properties/functions in Swift Foundation that are NSUnimplemented or call a subroutine that is NSUnimplemented like this:

@available(*, unavailable, message: “foo is not implemented yet”)
func foo() { NSUnimplemented() }

In this case we can be sure at compile time that we don’t use code that will definitely crash.
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


(Sergej Jaskiewicz) #4

Well, here is what I got in IBM Swift Sandbox. http://swift.sandbox.bluemix.net/#/repl/5913a8594ee0cd258050b2fd
If I got you right, it works.

Yes, partially implemented functions is a problem. But we definitely could mark the ones that are not implemented at all and not being called.

···

On 11 May 2017, at 02:43, Philippe Hausler <phausler@apple.com> wrote:

This of course is predicated upon availability macros working appropriately on linux (which last time I checked we don’t have a version variant). It is definitely worth investigation.

On May 10, 2017, at 16:41, Tony Parker via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

Hi Sergej,

This is a good idea, but there are some additional things to consider. In some cases, methods are partially unimplemented (with edge cases, or at least less common cases remaining unfinished). The availability macro can’t reflect that status.

In other cases, we want to partially implement one function but still call through to an unimplemented function. The entire call may fail with the assert, but at least we have part of the implementation in place.

- Tony

On May 10, 2017, at 4:01 PM, Sergej Jaskiewicz via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

I was wondering why cannot we just mark all the methods/properties/functions in Swift Foundation that are NSUnimplemented or call a subroutine that is NSUnimplemented like this:

@available(*, unavailable, message: “foo is not implemented yet”)
func foo() { NSUnimplemented() }

In this case we can be sure at compile time that we don’t use code that will definitely crash.
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


(Philippe Hausler) #5

It might be also useful to keep track of each one of these so we can make sure there are bugs for each one. (Even if it is a list that a script could create tickets). Many of the NSUnimplemented methods are good points to start contributing.

···

On May 10, 2017, at 16:59, Sergej Jaskiewicz via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:

Well, here is what I got in IBM Swift Sandbox. http://swift.sandbox.bluemix.net/#/repl/5913a8594ee0cd258050b2fd
If I got you right, it works.

Yes, partially implemented functions is a problem. But we definitely could mark the ones that are not implemented at all and not being called.

On 11 May 2017, at 02:43, Philippe Hausler <phausler@apple.com <mailto:phausler@apple.com>> wrote:

This of course is predicated upon availability macros working appropriately on linux (which last time I checked we don’t have a version variant). It is definitely worth investigation.

On May 10, 2017, at 16:41, Tony Parker via swift-corelibs-dev <swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>> wrote:

Hi Sergej,

This is a good idea, but there are some additional things to consider. In some cases, methods are partially unimplemented (with edge cases, or at least less common cases remaining unfinished). The availability macro can’t reflect that status.

In other cases, we want to partially implement one function but still call through to an unimplemented function. The entire call may fail with the assert, but at least we have part of the implementation in place.

- Tony

On May 10, 2017, at 4:01 PM, Sergej Jaskiewicz via swift-corelibs-dev <swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>> wrote:

I was wondering why cannot we just mark all the methods/properties/functions in Swift Foundation that are NSUnimplemented or call a subroutine that is NSUnimplemented like this:

@available(*, unavailable, message: “foo is not implemented yet”)
func foo() { NSUnimplemented() }

In this case we can be sure at compile time that we don’t use code that will definitely crash.
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev