-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] proof of concept for TraitModifiable generics #8
base: master
Are you sure you want to change the base?
[WIP] proof of concept for TraitModifiable generics #8
Conversation
so the list of restricted classes was there just so we can have multiple different types while preventing mistakes, this approach is better if live reloading, and code injection still work 👍 |
(finally, I have some free time :)) The idea is falling apart :D
AFAIK, Swift protocols require static linking. IMO, this is a minor drawback, I personally wouldn't mind restarting an app every time I had to implement a new
I guess, the runtime doesn't "load" all the classes immediately after start. It looks like it occurs arbitrarily, in my case it breaks only when I convert
When I converted
Implicitly unwrapped optionals are ugly, |
So I couldn't remember why I didn't go with the protocol idea from the start, but I remember thinking it would provide issues when you want to leverage runtime, which is confirmed by your research here
I think it stops being reliable when we start incorporating Swift specific features like the generic protocol approach.
public protocol FontModifiable: class {
var modifableFont: UIFont? { get set }
} And just extending each type with conformance to the protocol and using computed variable that forwards to the corresponding methods. I think that using protocols is much nicer / safer, but with loosing auto-registration and injection together I wonder if its worth it, what are your thoughts here? |
Auto-registration could be replaced with NSStringFromClass/NSClassFromString. It adds a "namespace" prefix, so I think it's rather an advantage. If someone wanted to have their own implementation of What do you think? |
good idea 👍 |
Issue #7
Work in progress, this is just a 'proof of concept' for the idea (all tests are passing, live reloading works).
One question before I can move forward :).
Do you want to keep the original type checking method (list of restricted classes) or we can substitute it with generics?
TypedTrait
is a temporary thing.