-
Notifications
You must be signed in to change notification settings - Fork 20
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
extension NodeInitializable should be public? #15
Comments
@UberJason the edit is correct, the extension isn't a default, but rather a convenience method since context is only used in practice for a few different use cases. A lot of the time |
So my question I guess would be, since context is only really used for a few different use cases, would it make sense to expose the |
@UberJason I'm not sure I follow, the default initializer is public, is it not? Maybe I'm missing something if you have more info. |
Sorry, I misspoke. I meant, would it make sense to expose the NodeInitializable extension and its convenience method as public. Since, as you said, that convenience method is often enough. It's a minor thing, just wondering. |
@UberJason all of the methods are exposed, I think what you're asking for is to put them both on the protocol so that you can choose which one to override, like:
Unfortunately, there's no good way to say "Use one of these functions, but not both", so it's difficult to know which is implemented, and it'd require both. To get around this, everyone is required to implement the full initializer w/ Context, and the convenience can be used after that point. Sorry it can't just be the clean and simple way only for now, but this little addition helps us broaden our support for some of the more complex situations. |
No worries, it was minor. :) Also I was working from 0.17 at the time, it may have changed in 0.18 (haven't had a chance to go back and check). |
@UberJason it hasn't unfortunately, but if something changes that we're able to achieve this, we'll definitely revisit! |
I'm trying to make a data type conform to
NodeConvertible
.NodeConvertible
is made up ofNodeInitializable
andNodeRepresentable
, where the methodmakeNode()
is defined inNodeRepresentable
, and the methodinit(node: Node, in context: Context)
is defined inNodeInitializable
.NodeInitializable
has a protocol extension which defines a default initializer, so that I should only need to implementmakeNode()
, if I'm understanding correctly. However, when I do this, my data type still doesn't conform toNodeConvertible
.I believe the problem is that the
NodeInitializable
extension should be public, but it isn't. Thus, my own data type in my project which imports Node can't see that there's actually a default implementation of the initializer already there. Is my analysis correct, and would you be willing to make that change?EDIT: The other possibility is that the
NodeInitializable
extension actually only definesinit(node: Node)
, and notinit(node: Node, in context: Context)
, so my data type still needs to implement the latter.The text was updated successfully, but these errors were encountered: