Add get-*
prefix to getters
#170
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As proposed in the last WASI meeting, this PR prefixes the following property-like methods with
get-
:request.method
request.path-with-query
request.scheme
request.authority
request-options.connect-timeout
request-options.first-byte-timeout
request-options.between-bytes-timeout
response.status-code
I don't foresee any trouble with emitting these as properties in source languages.
However, the interface also contains:
fields.entries
request.options
request.headers
&response.headers
request.body
&response.body
I haven't prefixed these yet. Their names are standalone nouns so my OOP brain wants these to follow the property conventions too. E.g., I'd expect a Java binding generator to produce
getEntries
,getOptions
,getHeaders
&getBody
.But using the property convention/syntax generally comes with the implicit assumption that accessing it is cheap, idempotent and/or side-effect free. That's not the case here. For example, the following snippet would normally be idiomatic JavaScript code:
but actually, this creates two new owned
fields
handles that are never disposed of. And all theentries
are copied over fully twice as well. So this seemingly fine code is actually inefficient & leaking resources.I'm ignoring the existence of the
fields.get
method to get the point across :)Ideas on this are welcome. Concretely I want to know how to proceed:
get-*
anyway and leave it for future selves to figure out?@lukewagner Thoughts?