Replies: 3 comments
-
Hi, thanks for the feedback! A primary goal of Civet is to stick to JS semantics as much as possible. In the case of mixins we'll probbaly converge on ESDecorators when/if it becomes a standard. Civet currently supports decorators using Thanks for sharing the code sample it looks pretty close to the direction that JS/TS is heading with decorators and I'm always happy to find inspiring ways to make syntax nicer. I'm glad you like Civet and hope that it will make your wildest dreams come true. |
Beta Was this translation helpful? Give feedback.
-
Besides decorators, a common pattern for mixins in ts is to use a function that extends an input class (Real world example). Using this pattern in civet, the linked example (abbreviated) would look like:
which imho is not too bad |
Beta Was this translation helpful? Give feedback.
-
@lorefnon I agree that class factories are an elegant and easy way to implement a mixin style. Just that they miss one thing: Constructors (and respective call hierarchies). Decorators did not even exist as proposal at that time. I think that they would provide a cleaner integration, I agree. Maybe I would give it a try and port my library to be based on decorators. I just wonder how the type system can be informed about additional supertypes introduced via a decorator. Any ideas on that? |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your efforts on Civet. I am intrigued because I used to love CoffeeScript and wrote various projects with it.
I built a small library to make CoffeeScript support Mixins or Traits in an idiomatic way.
Maybe check out this code and tell me if you like the style of it and if it's worth porting it to Civet.
https://github.com/bennidi/coffee-latte/blob/master/src/mixins.spec.coffee
Beta Was this translation helpful? Give feedback.
All reactions