-
Notifications
You must be signed in to change notification settings - Fork 74
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
fix(exo): allow richer behaviorMethods #1809
Conversation
55c660a
to
ebf8a11
Compare
61b2bb5
to
82f1d2c
Compare
82f1d2c
to
d113f32
Compare
d113f32
to
87f1cf8
Compare
4aa969f
to
aa5925a
Compare
5776030
to
d50a60b
Compare
d50a60b
to
1522ef7
Compare
992248d
to
7460a13
Compare
@michaelfig , reviewers, I rebased and resolved merge conflicts with #1831 |
Aside: If I convince the OCapN folks that method invocations should be case-normalized, then a method named “get interface guard” would only be addressable as |
de5766c
to
6dc17f6
Compare
fa32908
to
a315a7c
Compare
At #1809 (review) @michaelfig writes:
All quibbles resolved. PTAL.
|
a315a7c
to
2e6ed72
Compare
Reviewers, |
2e6ed72
to
f35d7de
Compare
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.
I raised some issues at the periphery with assertions and documentation.
We need at least to bikeshed from the currently awful names (
defineExoClassFromJSClass
).
I think "bikeshed" here is facetious but I want to point out that API naming in Endo merits careful consideration. They will stick around a long time and we want to avoid developers being confused by them or having misconceptions about what they do.
That said, I don't think defineExoClassFromJSClass
is awful. It's long but it says what it does. It's probably also not the end state for the dev-facing API because I expect defining the class with decorators will be the most common.
f35d7de
to
d3b9abb
Compare
I agree completely, which is why these awful names --- as well as the entirety of the That said, even as a |
f2dbf29
to
25633d6
Compare
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.
No blocking concerns. I do think the underscores are worth considering before merging.
I'd also suggest cleaning up the commits to reduce noise in the changelog. Most of the "fix" are really "fixup" that should be squashed into noteworthy commits.
Btw, if a commit shouldn't appear in the changelog, it shouldn't have conventional commit message. Noise in the commit history isn't as bad as noise in the changelog.
a9db3d8
to
336b138
Compare
Manually squashed those away before merging. Done. |
336b138
to
1f29d4a
Compare
closes: #1817
refs: #1815 #1808 #1773 #1766
Description
The intention of the exo-making methods was to be able to use a JS class'
.prototype
as a source of raw methods. This PRdefineExoClassFromJSClass
).super
and late-boundself
in inheritance among these methods, withsuper
calls bypassing guards, whileself
calls are guarded.This PR also provides tests demonstrating the use of JS classes to directly provide unguarded behavior at the
@endo/pass-style
/Far
level of abstraction. This PR makes no changes to thesrc/
code at this level, demonstrating what support is already possible. Unlike the above exo-level support, we do not recommend the coding style shown in these pass-style level tests. However, neither can we reasonably prevent it, so we need to understand it.Security Considerations
Corresponding examples at
endo/packages/pass-style/test/test-far-wobbly-point.js
Lines 132 to 144 in d50a60b
and
endo/packages/exo/test/test-exo-wobbly-point.js
Lines 183 to 193 in d50a60b
demonstrates that the demonstrated non-recommended use of class inheritance at the far level of abstraction has a security vulnerability absent from the use of class inheritance at the exo level of abstraction. This is one reason why we do not recommend the former but may recommend the latter.
Scaling Considerations
If classes had large number of methods and class inheritance chains were deep, this has somewhat worse scaling than a JS class programmer would normally expect. However, if either of these are reasonably small, there should not be any significant scaling problem.
Documentation Considerations
If we decide that we like and wish to promote the use of JS classes demonstrated by this PR, we should move some support (
defineExoClassFromJSClass
) into exported sources and we should document the whole approach. The purpose of this PR is not to establish such practice or decide on its exact shape, but merely to demonstrate that this PR makes such JS class-based practice possible.In particular, we may be able to improve of the usability shown in this PR by using JS class decorators. It is a worthy experiment. (attn @mhofman )
Testing Considerations
The
src
changes that this PR makes are only toexo-tools.js
code shared among heap, virtual, and durable exos. However, the tests only test the behavior of heap exos. Once agoric-sdk is upgraded to depend on the changes from this PR, we should reproduce these tests for virtual and durable exos. Ideally, we would use Zones to write the tests once and then reuse it to test all three types of zone.This PR makes no effort to test JS classes used for facets of exo kits. Nor does it provide any hypothetical helper functions to help write such exo kits. If we decide that this code pattern for using JS classes is attractive, a later PR should indeed extend the approach to exo kits.
Upgrade Considerations
This PR makes no changes to data. For existing exo-making code that only uses object literals for own enumerable methods, this PR should not result in any behavior change or even internal representation change. The only code it should make a difference for is code that previously did not work because it needed the fixes and features provided by this PR. We are not aware of any such code prior to this PR.