[swift-evolution] [swift-evolution-announce] [Review] SE-0166: Swift Archival & Serialization

Marco Masser lists at duckcode.com
Mon Apr 10 06:16:37 CDT 2017


Proposal link:

https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md <https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md>


I’m not giving a complete review here, but this proposal seems like a fantastic solution to me.
There’s one thing I either missed or that is actually missing that I would like to discuss.

NSObject defines the following method:
func awakeAfter(using aDecoder: NSCoder) -> Any?

I can find no discussion in the proposal about the intended replacement for the functionality this method provides. This method probably counts to the more obscure parts of Foundation and is probably almost never implemented. But there’s a use case in the code base I’m working on and I would like to discuss the intended replacement mechanism for it in the context of this proposal.

We have an Objective-C class that represents a single DNS name (e.g. a host name or a domain name). Instances are cached so whenever such an object is created (for e.g. “apple.com”), the same instance is returned (this is done using factory methods).
These DNS name objects are also encoded using NSCoding (for distributed object calls and for archiving to disk) and when decoding them, the same instance is returned every time. The decoding mechanism cannot take care of this because it cannot know whether such an instance exists already (created by a previous call to the aforementioned factory method). Using awakeAfter(using:) provides this functionality by looking up the cache and returning the already existing instance.

I suspect that the replacement for such a use case in Swift are structs and value types where there is no concept of identity. I would like to know if that is the answer the proposal author would give or if I’m missing something.


Similarly, I can’t find a replacement for the functionality following method of NSObject:
- (nullable id)replacementObjectForCoder:(NSCoder *)aCoder;

… but I think this is only used for DO calls and proxy objects and the intended replacement is XPC.


Regards,

Marco



> On 2017-04-06, at 20:10, Douglas Gregor <dgregor at apple.com> wrote:
> 
> Hello Swift community,
> 
> The review of SE-0166 "Swift Archival & Serialization" begins now and runs through April 12, 2017. The proposal is available here:
> 
> https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md <https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md>
> Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at
> 
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
> or, if you would like to keep your feedback private, directly to the review manager. When replying, please try to keep the proposal link at the top of the message:
> 
> Proposal link:
> 
> https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md <https://github.com/apple/swift-evolution/blob/master/proposals/0166-swift-archival-serialization.md>
> Reply text
> Other replies
>  <https://github.com/apple/swift-evolution/blob/master/process.md#what-goes-into-a-review-1>What goes into a review?
> 
> The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:
> 
> What is your evaluation of the proposal?
> Is the problem being addressed significant enough to warrant a change to Swift?
> Does this proposal fit well with the feel and direction of Swift?
> If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> More information about the Swift evolution process is available at
> 
> https://github.com/apple/swift-evolution/blob/master/process.md <https://github.com/apple/swift-evolution/blob/master/process.md>
> Thank you,
> 
> -Doug
> 
> Review Manager
> 
> _______________________________________________
> swift-evolution-announce mailing list
> swift-evolution-announce at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution-announce

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170410/e6fcd4d7/attachment.html>


More information about the swift-evolution mailing list