Replies: 1 comment 4 replies
-
|
The referenced PRs have merged; can this be closed? I don't know how to address a discussion that has concluded... do we convert to an issue and close, migrate to docs and delete, apply some kind of "done" label? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Prior to #5960, virtual and durable far objects could be written using the various "kind" definers
defineKind*vsdefineDurableKind*)define*Kindvsdefine*KindMulti)defineDurableKind*vsvivifyKind*)vivifySingleton)In practice we expect only three to be common (See #5708 )
vivifyDurableKindvivifyDurableKindMultivivifySingleton#5960 introduces replacements for these, in order to address two problems:
contextfirst argument for receiving the objectstateand access toselfor cohort offacets. This shifts the argument types by one, which creates a painful IDE experience (See fix: far classes with interface guards, used by ERTP #5960 (comment) below. (Note that singletons do not have this problem.)The replacements
defineVirtualFarClass*vsdefineDurableFarClass*)define*FarClassvsdefine*FarClassKit)defineDurableFarClass*vsvivifyFarClass*)vivifyFarInstance)Its worth noting that we expect conversion from Kind style to Far Class style not to effect which are common in practice:
vivifyFarClassvivifyFarClassKitvivifyFarInstanceIt addresses the two problems mentioned above
contextas theirthisargument, leaving their function type unaffected. This requires that these methods be written as functions that receive theirthisbinding dynamically. We chose to use concise method syntax, where all these methods are written inline within the call to the FarClass definer. Note that these constraints are familiar to JSclassprogrammers, whose methods must also be written in concise method syntax that must appear inline within theclassdefinition.M.interfaceand helpersM.call,M.callWhen, andM.awaitfor defining protective interfaceGuards that can express and enforce type-like constraints on incoming arguments and return results. This sublanguage needs to be separately documented. The FarClass definer functions all take aninterfaceGuardargument. The methods exposed as the API will check all their incoming arguments before calling the raw methods provided in the same call to the FarClass definer.The raw methods can thus assume that all the validation expressed by the interfaceGuard for this method has already been checked. It is still the responsibility of the raw method to validate all issues that remain after the interfaceGuard has done its part of the job. For example, for a payment argument, the interfaceGuard can only validate that it is a remotable. It remains to the raw method to manually check, for example, that it is a live payment of the correct brand containing enough assets.
This raises the other reason we need to write these methods inline: By themselves, they are fragile. Also, by themselves, they are
this-sensitive functions. For both of those reasons, we'd like to avoid the possibility of them floating around as first-class values. By having them appear inline in the FarClass definer call, we successfully encapsulate them. Afterward, they can only be reached by the protective outer shell described by the interfaceGuard.After #5960 is merged and we have experience using it, we hope to decide to deprecate the Kind functions and style in favor of the Far Class style. But since this decision should follow experience, we leave it to the follow on PR #6106 .
Beta Was this translation helpful? Give feedback.
All reactions