[Proposal] Shadowing imported functions


(Anton Zhilin) #1

As promised, I've created a proposal to add @shadowing attribute. Link to
the proposal:

https://github.com/Anton3/swift-evolution/blob/shadowing-imported-functions/proposals/NNNN-shadowing-imported-functions.md

Example:

// Imported function (implicit declaration)func dispatch_sync(queue:
dispatch_queue_t, block: (@convention(block) () -> Void)!)
@shadowing(dispatch_sync(queue, block))func sync(queue:
dispatch_queue_t, @noescape block: @convention(block) () -> Void)

- Anton


(Anton Zhilin) #2

As a side effect, we will be able to purge IUO from Swift abolutely,
completely.
And add a rule that we can shadow Optional<T> parameter with T for some T.
But it is the theme of a separate proposal.

- Anton

···

2016-04-14 18:28 GMT+03:00 Антон Жилин <antonyzhilin@gmail.com>:

As promised, I've created a proposal to add @shadowing attribute. Link to
the proposal:

https://github.com/Anton3/swift-evolution/blob/shadowing-imported-functions/proposals/NNNN-shadowing-imported-functions.md

Example:

// Imported function (implicit declaration)func dispatch_sync(queue: dispatch_queue_t, block: (@convention(block) () -> Void)!)
@shadowing(dispatch_sync(queue, block))func sync(queue: dispatch_queue_t, @noescape block: @convention(block) () -> Void)

- Anton


#3

It is unclear to me, if you plan to allow re-labelling, during the shadowing process.

Could the:
dispatch_sync(_,block:)
Be shadowed as either (if one disregard the API Guideline)
sync(_,block:)
sync(list:,task:)
sync(_,_)

If the import got the function name wrong, and missed the annotations like @noescape; it may also mislabel the parameters.

Dany

···

Le 14 avr. 2016 à 11:28, Антон Жилин via swift-evolution <swift-evolution@swift.org> a écrit :

As promised, I've created a proposal to add @shadowing attribute. Link to the proposal:

https://github.com/Anton3/swift-evolution/blob/shadowing-imported-functions/proposals/NNNN-shadowing-imported-functions.md

Example:

// Imported function (implicit declaration)
func dispatch_sync(queue: dispatch_queue_t, block: (@convention(block) () -> Void)!)

@shadowing(dispatch_sync(queue, block))
func sync(queue: dispatch_queue_t, @noescape block: @convention(block) () -> Void)


(Anton Zhilin) #4

Yes, re-labelling is allowed, as well as reordering. I will add that to the
proposal.

···

2016-04-15 5:01 GMT+03:00 Dany St-Amant <dsa.mls@icloud.com>:

Le 14 avr. 2016 à 11:28, Антон Жилин via swift-evolution < > swift-evolution@swift.org> a écrit :

As promised, I've created a proposal to add @shadowing attribute. Link to
the proposal:

https://github.com/Anton3/swift-evolution/blob/shadowing-imported-functions/proposals/NNNN-shadowing-imported-functions.md

Example:

// Imported function (implicit declaration)func dispatch_sync(queue: dispatch_queue_t, block: (@convention(block) () -> Void)!)
@shadowing(dispatch_sync(queue, block))func sync(queue: dispatch_queue_t, @noescape block: @convention(block) () -> Void)

It is unclear to me, if you plan to allow re-labelling, during the
shadowing process.

Could the:
dispatch_sync(_,block:)
Be shadowed as either (if one disregard the API Guideline)
sync(_,block:)
sync(list:,task:)
sync(_,_)

If the import got the function name wrong, and missed the annotations like
@noescape; it may also mislabel the parameters.

Dany