-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome! 🦄
@Chriscbr this is great work. I feel like there are some gaps in the readme, and maybe a poc in the SDK repo could help highlight the APIs and their usage? |
Signed-off-by: github-actions <github-actions@github.com>
- Make sure `Polycon` extends `Construct` to ensure that languages that use nominal typing (such as Java, .NET, etc) will accept a polycon everywhere constructs are accepted (add a test). - Refactor the constructor path and use a marker on the scope to distinguish between polycon construction and the construction of the concrete type. - Add a few tests to verify some assumptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some random notes
This is a proposal based on [this comment](https://github.com/monadahq/polycons/pull/15/files#r933560022). The basic idea is that both the polycon class (e.g. `Dog`) and the concrete class (`Poodle`) extend a common abstract base type (e.g. `DogBase`). This has the following effects: 1. No need to protect against stack overflow (the concrete class doesn't actually extend the polycon). 2. It is now possible to instantiate any concrete type directly (added a test that instantiates a `Labrador` even if when `Dog` resolves to `Poodle`. 3. We can still share common implementation at the base. 4. Enforce that concrete classes actually implement all abstract methods and properties (previously this was only by convention). The polycon constructor has a quirky pattern: ```ts constructor(scope, id, props) { super(null as any, id, props); return Polycons.create(QUALIFIER, scope, id, props); } ``` The call to `super()` with `null` as the `scope` does two things: 1. The base construct is not attached to our tree. 2. The `null` can be used by the base class to bail out early: ```ts class DogBase { public readonly foo: number; constructor(scope, id, props) { super(scope, id); if (!scope) { // initialize all readonly props with dummy values, this obj is thrown away this.foo = -1; return; } this.foo = 7947; // <-- the real thing } } ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is ready to publish. Just a few minor comments left.
Conditionally approved.
(added |
@@ -0,0 +1 @@ | |||
TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbonig can you help with this?
Setting up an initial version of the polycons API. Based on several iterations of the RFC, Mark's POC, my spinoff of Mark's POC, the team's code from our last hackathon, and many team members' feedback.
TODO:
Add contributing guidefuture