Skip to content

Caller.TryCallFunction#233

Closed
martindevans wants to merge 1 commit into
bytecodealliance:mainfrom
martindevans:caller_TryCallFunction
Closed

Caller.TryCallFunction#233
martindevans wants to merge 1 commit into
bytecodealliance:mainfrom
martindevans:caller_TryCallFunction

Conversation

@martindevans
Copy link
Copy Markdown
Contributor

@martindevans martindevans commented Mar 16, 2023

Added TryCallFunction methods to Caller. This allows functions to be called without allocating a Function object. An alternative solution would be to convert Function into a struct, but this is a much larger change!

The main shortcoming with this is that ValueBox cannot be stack allocated. So this API is really just passing the buck on allocating anything - the caller can avoid allocations (rent an array) but it's not very ergonomic. See the unit tests for example.

Another implementation could have generic arguments for all possible call/return combinations (and then use ValueBox.Converter<T>().Box(value)). This would be a fairly nice API to use, but would require generating yet more huge blobs of code.

I'm open to other suggestions on a better way to pass arguments and results.

… be called without allocating a `Function` object.
@martindevans
Copy link
Copy Markdown
Contributor Author

Superseded by #235

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant