I haven’t noticed the difference between those to at first glance.

Okay but do we need public initializer at all?

I’d put this into the alternative section so the core team can decide how to 
implement it (if this gets accepted).

I’ll prepare a second implementation gist for this suggestion. Feel free to 
update the proposal for both versions. (I see what you meant - COW optimized 
type like Foundation types.)

I’m to tired right now, I’ll do it tomorrow. It seems that we’re almost there. 
Maybe we can PR tomorrow so the review will kick off ASAP.



-- 
Adrian Zubarev
Sent with Airmail

Am 15. Juli 2016 um 21:49:29, Anton Zhilin ([email protected]) schrieb:

I suggested it because now we can’t call any initializers on  
Type<T>. If we add  
_Type<T>, we can add public initializers and keep  
Type<T> instances unique.

// No uniqueness guarantee
internal final class _Type<T> {
    var _metatype: Metatype<T>

    init()
    init(_: AnyMetatype)
    init?<U>(casting: Type<U>)
}

internal var _typeStorage = Set<_Type<Any>>()

// Uniqueness guarantee
// 'final class' is an implementation detail
public struct Type<T> {
    internal var _impl: _Type<T>

    // Notice 'public'
    public init()
    public init(_: AnyMetatype)
    public init?<U>(casting: Type<U>)
}
There will be no  
=== operator for  
Type<T>, because it does not add value.  
Type<T> is a wrapper of typeless identifier with value semantics. It is 
singleton pattern that makes us use classes.

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to