[swift-evolution] [Discussion] Seal `T.Type` into `Type<T>`
Adrian Zubarev
adrian.zubarev at devandartist.com
Fri Jul 15 12:26:07 CDT 2016
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 (antonyzhilin at gmail.com) 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160715/9dd9ed7f/attachment.html>
More information about the swift-evolution
mailing list