Availability checking of libraries (weak linking?)


(Fastmail) #1

Say I have an awesome type, and I provide some extensions that makes it work really well with a few other packages.

I don't want to force those packages on my users, but if they have them, I want to extend them with my awesome type/function/whatever convenience.

What can be done in code and package manager to weakly link (not literally, I just mean have that behaviour) my awesome type with all these other libraries?

This is a prelude to a pitch, if there isn't a decent alternative.

Tom

···

Sent from my iPhone


(Slava Pestov) #2

Extending availability to support library versioning would be a great proposal.

You should also take a look at the library evolution proposal, where this functionality will be required to implement the resilience model: https://github.com/apple/swift/blob/master/docs/LibraryEvolution.rst

Slava

···

On Jan 18, 2017, at 4:24 PM, Swizzlr via swift-evolution <swift-evolution@swift.org> wrote:

Say I have an awesome type, and I provide some extensions that makes it work really well with a few other packages.

I don't want to force those packages on my users, but if they have them, I want to extend them with my awesome type/function/whatever convenience.

What can be done in code and package manager to weakly link (not literally, I just mean have that behaviour) my awesome type with all these other libraries?

This is a prelude to a pitch, if there isn't a decent alternative.

Tom

Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Ben Rimmington) #3

<https://github.com/apple/swift-evolution/blob/master/proposals/0075-import-test.md>

#if canImport(...) should be available in Swift 4, thanks to Robert Widmann.

<https://github.com/apple/swift/pull/5778>
<https://github.com/apple/swift/pull/6547>

-- Ben

···

On 19 Jan 2017, at 00:24, Swizzlr wrote:

Say I have an awesome type, and I provide some extensions that makes it work really well with a few other packages.

I don't want to force those packages on my users, but if they have them, I want to extend them with my awesome type/function/whatever convenience.

What can be done in code and package manager to weakly link (not literally, I just mean have that behaviour) my awesome type with all these other libraries?

This is a prelude to a pitch, if there isn't a decent alternative.

Tom


(Fastmail) #4

Thanks all, Ben's answer was exactly what I was looking for; Slava's suggestion merits discussion perhaps when canImport is available.

Thanks again!

Tom

···

Sent from my iPhone

On 19 Jan 2017, at 02:07, Ben Rimmington <me@benrimmington.com> wrote:

On 19 Jan 2017, at 00:24, Swizzlr wrote:

Say I have an awesome type, and I provide some extensions that makes it work really well with a few other packages.

I don't want to force those packages on my users, but if they have them, I want to extend them with my awesome type/function/whatever convenience.

What can be done in code and package manager to weakly link (not literally, I just mean have that behaviour) my awesome type with all these other libraries?

This is a prelude to a pitch, if there isn't a decent alternative.

Tom

<https://github.com/apple/swift-evolution/blob/master/proposals/0075-import-test.md>

#if canImport(...) should be available in Swift 4, thanks to Robert Widmann.

<https://github.com/apple/swift/pull/5778>
<https://github.com/apple/swift/pull/6547>

-- Ben