Done. Personally I don’t care much if it’s .cast(from:) or .cast(_:).

Now whenever Type<T> is created and if there is no reference in type storage 
(which I updated to be a Set instead of a Dictionary) that contains the dynamic 
metatype from our current instance, it automatically downcasts itself to 
Type<Any> and insert itself into the type storage.

There is one more thing I’d like to discuss before we finally move to size etc.

Consider what I said above, I feel like we should tackle this:

drop init(_ copy: Type<T>) - to keep equality of Type<T> references
make all initializer internal and as exchange make sharedInstance public.
This would ensure that you will always get a reference from the type storage, 
and that there can only exist one for each (dynamic) metatype.

I can’t foresee the future, so I’m wondering if the type may mutate somehow 
when reflections are added? If so, I don’t see why we should lock references 
inside a single storage and care about ===.



-- 
Adrian Zubarev
Sent with Airmail

Am 15. Juli 2016 um 19:05:56, Anton Zhilin ([email protected]) schrieb:

Brilliant! But I disagree with 
from label. “Cast from type” means that we somehow use 
Type<U> statically. But we need to cast 
optionalType itself to 
Type<T>. I suggest to use 
cast(_:) signature.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to