-
Notifications
You must be signed in to change notification settings - Fork 157
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
Complementary use of implements
#297
Comments
Another improvement 😄 allowing classes to implement other classes: ITest1 =
foo: (x)->
class ITest2
foo: (x)->
@bar = (x,y)->
class Test1 implements ITest1
class Test2 implements ITest2 It would call the following function instead of calling implement$ = (cls, itf) ->
cls import all itf
if typeof itf is \function
cls.prototype import all itf.prototype |
currently we have class A
foo: 'bar'
class B
import A::
console.log B.foo #=> 'bar'
class C implements A::
console.log C::foo #=> 'bar' |
Yes but the static properties are not inherited, am I wrong? |
Bump! What about allowing declare functions with the name |
The |
Ok, I agree 😃 I am only asking for allowing the use of |
Oh I see. Yes potentially. |
I am proposing a complementary use of the
implements
keyword, out of the class definition.It would check if the properties of the given class matches with the interface properties.
Here is an example:
The last three lines should compile to something like:
This function checks if the properties of the given class matches with the interface properties.
What do you think?
In first place, I tried to name this function as
implements
and use it with an infix function call:But currently the compiler throws an
Unexpected identifier
error when I define the function with that name. Then I realized that it would be an interesting feature forLiveScript
😋.At least, would it be possible to allow the use of
implements
outside the class definition?The text was updated successfully, but these errors were encountered: