-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add constructor pseudo-method #13
Comments
Also, I'm generally opposed to the idea of a protocol being notified when it is implemented. I prefer explicit notification using existing mechanisms instead. |
I was thinking something along the lines of a parent "constructor",
executed to initialize `this` for the protocol. Likewise, it doesn't run
anything when used via `implements` in classes, much like how classes don't
run anything when used via `extends`.
Being notified of extension/implementation and potentially modifying
classes I agree belongs in the realm of decorators, not protocols. Sorry if
I wasn't clear enough initially.
…On Tue, Sep 19, 2017, 22:01 Michael Ficarra ***@***.***> wrote:
Also, I'm generally opposed to the idea of a protocol being notified when
it is implemented. I prefer explicit notification using existing mechanisms
instead.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AERrBFFCdfNcF0w8OmKyc8ijWAorcBGsks5skHISgaJpZM4PN_y->
.
|
@michaelficarra Could you give a code example to show how to provide protocol own states via decorator? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Kind of like how classes have constructors to run on initialization, it'd be nice to add a way to run code "on implement", since interfaces/protocols might wish to have their own state (for example, for caching) and/or branding that's more specific than just "this implements me" or "this implements that".
Notes:
Reflect.implement
call or right aftersuper
on its result, in order of appearance in classes.The text was updated successfully, but these errors were encountered: