-
Notifications
You must be signed in to change notification settings - Fork 34
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
Rename HostImports to ExternalValues #527
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
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.
Thanks for the proposal, I like it overall!
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.
This makes sense to me. Although it might create some dissonance with our use of "host" in other places (like the docs). Actually you might want to do a quick search for "host" to make sure you've covered all the docs as well. Maybe all of them don't need to change and they make sense in context, but some might.
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
Signed-off-by: Edoardo Vacchi <[email protected]>
@bhelx I think the docs look good, from what I can see the only place where we still used "host" "improperly" (so to speak) was a line of the WASI readme: e774e26#diff-2a0f73c29b5710acc7ebe0330361345e74a05b4e51a027012ccbf9862ed6779a |
Signed-off-by: Edoardo Vacchi <[email protected]>
FYI I have pushed the other refactor I have mentioned in the top post Using I can create another PR once this gets merged or just push it here. The changes are related, but they don't need to be shipped together; but if we agree on this rename too, then it makes sense to ship them in the same release. |
a.k.a. The Big Rename™️. This follows an offline discussion with @andreaTP. The idea would be to finalize naming before the future 1.0 release.
The class
HostImports
and the related dependenciesHostFunction
,HostTable
,HostGlobal
,HostMemory
are currently being used with two different purposes:However, name "Host" makes most sense for the first case, while it feels slightly off and ambiguous in the second case: are those Host-defined values, or are those just values belonging to another instance?
The spec in this regard is not ambiguous, and generally refers to External Types and External Values. Specifically:
ExternalType
under packagecom.dylibso.chicory.wasm.types
.Thus, with this change, I propose the following renames:
FromHost
->ExternalValue
FromHost.FromHostType
->ExternalValue.Type
notice that we could also reusecom.dylibso.chicory.wasm.types. ExternalType
, but this would require exposing to the end users packagecom.dylibso.chicory.wasm.types
from packagecom.dylibso.chicory.runtime
HostImports
->ExternalValues
HostGlobal
->ExternalGlobal
HostTable
->ExternalTable
HostMemory
->ExternalMemory
HostFunction
still exists, as a subtype ofExternalFunction
: this allows to keep a distinction that might be useful in the future; in fact, the constructor toExternalFunction
could be even package-local.Notice that, I have not re-defined
Host{Global,Table,Memory}
as subtypes ofExternal{Global,Table,Memory}
, because I feel like there is no meaningful distinction:HostFunction
s implement logic using the host language, whileExternalFunction
s are otherwise just the exported image of an instance of aFunction
defined in a Wasm module. So, even though their interface might be the same, they are different concepts.Even if we decided to drop the concrete type
HostFunction
altogether, it might still make sense to expose a factoryExternalFunction.createHostFunction() for an
ExternalFunction` because the term "host function" is generally known to refer to a host-defined function.It might be now feel slightly more awkward to import host functions directly through an
Instance.Builder
; e.g.:but consider that, on the other hand, the
Instance.Builder
interface is a lower-level interface, so it might be acceptable for it to expose "lower-level" naming; in the future, I would expect users to interact with the runtime using higher level interfaces, such as theStore
. In this case, users would write:Notes
Will follow-up with another, conceptually unrelated rename, but with the same goal of improved clarity; i.e.:
fieldName()
->symbolName()
reason being
fieldName()
to me sounds too much like "name of a property", that is, it makes me think "Global" but we also use it for "Function"s. "Symbol" is more generic and should avoid ambiguity.Signed-off-by: Edoardo Vacchi [email protected]